(stamp)
| 2515 | |
| 2516 | |
| 2517 | def install_system_headers(stamp): |
| 2518 | install_dirs = { |
| 2519 | 'system/include': '', |
| 2520 | 'system/lib/compiler-rt/include': '', |
| 2521 | 'system/lib/libunwind/include': '', |
| 2522 | # Copy the generic arch files first then |
| 2523 | 'system/lib/libc/musl/arch/generic/bits': 'bits', |
| 2524 | # Then overlay the emscripten directory on top. |
| 2525 | # This mimics how musl itself installs its headers. |
| 2526 | 'system/lib/libc/musl/arch/emscripten/bits': 'bits', |
| 2527 | 'system/lib/libc/musl/include': '', |
| 2528 | 'system/lib/libcxx/include': 'c++/v1', |
| 2529 | 'system/lib/libcxxabi/include': 'c++/v1', |
| 2530 | 'system/lib/mimalloc/include': '', |
| 2531 | 'system/lib/libcxx/modules/prebuilt/lib/emscripten': cache.get_lib_dir(absolute=True), |
| 2532 | 'system/lib/libcxx/modules/prebuilt/share': cache.get_sysroot_dir('share'), |
| 2533 | 'system/lib/libcxx/modules/std': cache.get_sysroot_dir('share/libc++/v1/std'), |
| 2534 | 'system/lib/libcxx/modules/std.compat': cache.get_sysroot_dir('share/libc++/v1/std.compat'), |
| 2535 | } |
| 2536 | |
| 2537 | target_include_dir = cache.get_include_dir() |
| 2538 | for src, dest in install_dirs.items(): |
| 2539 | src = utils.path_from_root(src) |
| 2540 | dest = os.path.join(target_include_dir, dest) |
| 2541 | safe_copytree(src, dest, excludes={'alltypes.h.in'}) |
| 2542 | |
| 2543 | pkgconfig_src = utils.path_from_root('system/lib/pkgconfig') |
| 2544 | pkgconfig_dest = cache.get_sysroot_dir('lib/pkgconfig') |
| 2545 | safe_copytree(pkgconfig_src, pkgconfig_dest) |
| 2546 | |
| 2547 | bin_src = utils.path_from_root('system/bin') |
| 2548 | bin_dest = cache.get_sysroot_dir('bin') |
| 2549 | safe_copytree(bin_src, bin_dest) |
| 2550 | |
| 2551 | # Create a version header based on the emscripten-version.txt |
| 2552 | version_file = cache.get_include_dir('emscripten/version.h') |
| 2553 | utils.write_file(version_file, textwrap.dedent(f'''\ |
| 2554 | /* Automatically generated by tools/system_libs.py */ |
| 2555 | #define __EMSCRIPTEN_MAJOR__ {utils.EMSCRIPTEN_VERSION_MAJOR} |
| 2556 | #define __EMSCRIPTEN_MINOR__ {utils.EMSCRIPTEN_VERSION_MINOR} |
| 2557 | #define __EMSCRIPTEN_TINY__ {utils.EMSCRIPTEN_VERSION_TINY} |
| 2558 | |
| 2559 | // Legacy mixed-case macros: |
| 2560 | #define __EMSCRIPTEN_major__ __EMSCRIPTEN_MAJOR__ |
| 2561 | #define __EMSCRIPTEN_minor__ __EMSCRIPTEN_MINOR__ |
| 2562 | #define __EMSCRIPTEN_tiny__ __EMSCRIPTEN_TINY__ |
| 2563 | #pragma clang deprecated(__EMSCRIPTEN_major__, "Use __EMSCRIPTEN_MAJOR__ instead") |
| 2564 | #pragma clang deprecated(__EMSCRIPTEN_minor__, "Use __EMSCRIPTEN_MINOR__ instead") |
| 2565 | #pragma clang deprecated(__EMSCRIPTEN_tiny__, "Use __EMSCRIPTEN_TINY__ instead") |
| 2566 | ''')) |
| 2567 | |
| 2568 | # Create a stamp file that signal that the headers have been installed |
| 2569 | # Removing this file, or running `emcc --clear-cache` or running |
| 2570 | # `./embuilder build sysroot --force` will cause the re-installation of |
| 2571 | # the system headers. |
| 2572 | utils.write_file(stamp, 'x') |
| 2573 | return stamp |
| 2574 |
nothing calls this directly
no test coverage detected