MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / build_library

Method build_library

test/common.py:1604–1668  ·  view source on GitHub ↗

Build a library and cache the result. We build the library file once and cache it for all our tests. (We cache in memory since the test directory is destroyed and recreated for each test. Note that we cache separately for different compilers). This cache is just during the test run

(self, name, build_dir, generated_libs, configure, make, make_args, cache_name, env_init, native)

Source from the content-addressed store, hash-verified

1602 return rtn
1603
1604 def build_library(self, name, build_dir, generated_libs, configure, make, make_args, cache_name, env_init, native):
1605 """Build a library and cache the result.
1606
1607 We build the library file once and cache it for all our tests. (We cache
1608 in memory since the test directory is destroyed and recreated for each
1609 test. Note that we cache separately for different compilers). This
1610 cache is just during the test runner. There is a different concept of
1611 caching as well, see |Cache|.
1612 """
1613 if type(generated_libs) is not list:
1614 generated_libs = [generated_libs]
1615 source_dir = test_file(name.replace('_native', ''))
1616
1617 project_dir = Path(build_dir, name)
1618 if os.path.exists(project_dir):
1619 shutil.rmtree(project_dir)
1620 # Useful in debugging sometimes to comment this out, and two lines above
1621 shutil.copytree(source_dir, project_dir)
1622
1623 generated_libs = [os.path.join(project_dir, lib) for lib in generated_libs]
1624
1625 if native:
1626 env = clang_native.get_clang_native_env()
1627 else:
1628 env = os.environ.copy()
1629 env.update(env_init)
1630
1631 if not native:
1632 # Inject emcmake, emconfigure or emmake accordingly, but only if we are
1633 # cross compiling.
1634 if configure:
1635 if configure[0] == 'cmake':
1636 # Some tests have very old cmake_minimum_version settings which is not supported by cmake 4+.
1637 # Forcing a slighly more recent cmake_minimum_version works around this issue.
1638 configure = [EMCMAKE] + configure + ['-DCMAKE_POLICY_VERSION_MINIMUM=3.5']
1639 else:
1640 configure = [EMCONFIGURE] + configure
1641 else:
1642 make = [EMMAKE] + make
1643
1644 if configure:
1645 self.run_process(configure, env=env, cwd=project_dir)
1646 # if we run configure or cmake we don't then need any kind
1647 # of special env when we run make below
1648 env = None
1649
1650 def open_make_out(mode='r'):
1651 return open(os.path.join(project_dir, 'make.out'), mode)
1652
1653 def open_make_err(mode='r'):
1654 return open(os.path.join(project_dir, 'make.err'), mode)
1655
1656 if EMTEST_VERBOSE:
1657 # VERBOSE=1 is cmake and V=1 is for autoconf
1658 make_args += ['VERBOSE=1', 'V=1']
1659
1660 self.run_process(make + make_args, env=env, cwd=project_dir)
1661

Callers 1

get_libraryMethod · 0.95

Calls 9

run_processMethod · 0.95
read_binaryFunction · 0.90
test_fileFunction · 0.85
existsMethod · 0.80
updateMethod · 0.80
appendMethod · 0.80
typeEnum · 0.50
joinMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected