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

Function generate_modules

system/lib/update_libcxx.py:62–92  ·  view source on GitHub ↗
(cmake_version: str)

Source from the content-addressed store, hash-verified

60
61
62def generate_modules(cmake_version: str):
63 dst = os.path.join(local_modules, 'prebuilt')
64 lib = 'lib/emscripten'
65 share = 'share/libc++/v1'
66
67 build_dir = f'{emscripten_root}/out/libcxx/modules'
68 binary_dir = f'{build_dir}/out'
69 dist = f'{binary_dir}/dist/'
70
71 clean_dir(build_dir)
72 os.makedirs(build_dir, exist_ok=True)
73 with open(f'{build_dir}/CMakeLists.txt', 'x', encoding='utf-8') as CMakeLists:
74 CMakeLists.write(f'''\
75 cmake_minimum_required(VERSION {cmake_version})
76 project(libcxx-modules)
77 add_subdirectory("{local_modules}" libcxx)
78 ''')
79
80 vars = [
81 ('LIBCXX_INSTALL_LIBRARY_DIR', lib),
82 ('LIBCXX_INSTALL_MODULES_DIR', share),
83 ('LIBCXX_LIBRARY_DIR', dist + lib),
84 ('LIBCXX_GENERATED_MODULE_DIR', dist + share),
85 ]
86
87 cmd = ['cmake', '-B', binary_dir, '-S', build_dir]
88 cmd += [f'-D{key}={val}' for key, val in vars]
89
90 subprocess.run(cmd, stdout=subprocess.DEVNULL)
91 subprocess.run(['cmake', '--build', binary_dir], stdout=subprocess.DEVNULL)
92 shutil.copytree(dist, dst, dirs_exist_ok=True)
93
94def main():
95 # Exit early if cmake is not found

Callers 1

mainFunction · 0.85

Calls 5

clean_dirFunction · 0.70
openFunction · 0.50
joinMethod · 0.45
writeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected