#import "util/get_source.script" get_source; str targetName #option; int processorCount #option; bool rebuild #option; void Start() { if processorCount == 0 processorCount = SystemGetProcessorCount(); bool install = false; if !PathExists("bin/musl") { get_source.Get("https://musl.libc.org/releases/musl-1.2.1.tar.gz", "musl-1.2.1", "68af6e18539f646f9c41a3a2bb25be4a5cfa5a8f65f0bb647fd2bbfdf877e84b"); assert PathMove("bin/source", "bin/musl"); assert FileCopy("ports/musl/changes/config.mak", "bin/musl/config.mak"); assert FileCopy("ports/musl/changes/dist_config.mak", "bin/musl/dist/config.mak"); assert FileCopy("ports/musl/changes/arch_x86_64_syscall_arch.h", "bin/musl/arch/x86_64/syscall_arch.h"); assert FileCopy("ports/musl/changes/src_env___init_tls.c", "bin/musl/src/env/__init_tls.c"); assert FileCopy("ports/musl/changes/src_process_x86_64_vfork.s", "bin/musl/src/process/x86_64/vfork.s"); assert FileCopy("ports/musl/changes/src_signal_x86_64_restore.s", "bin/musl/src/signal/x86_64/restore.s"); assert FileCopy("ports/musl/changes/src_thread_x86_64___unmapself.s", "bin/musl/src/thread/x86_64/__unmapself.s"); assert FileCopy("ports/musl/changes/src_thread_x86_64_clone.s", "bin/musl/src/thread/x86_64/clone.s"); assert FileCopy("ports/musl/changes/src_thread_x86_64_syscall_cp.s", "bin/musl/src/thread/x86_64/syscall_cp.s"); install = true; } if rebuild { assert SystemShellExecuteWithWorkingDirectory("bin/musl", "make clean"); assert SystemShellExecuteWithWorkingDirectory("bin/musl", "make -j %processorCount% lib/libc.a"); assert FileCopy("bin/musl/lib/libc.a", "ports/musl/libc.a"); install = true; } if !PathExists("root/Applications/POSIX/include/stdio.h") { install = true; } if install { assert PathCreateLeadingDirectories("root/Applications/POSIX/lib"); assert PathCreateLeadingDirectories("root/Applications/POSIX/include"); assert FileCopy("ports/musl/libc.a", "root/Applications/POSIX/lib/libc.a"); assert FileCopy("ports/musl/empty.a", "root/Applications/POSIX/lib/libm.a"); assert FileCopy("ports/musl/empty.a", "root/Applications/POSIX/lib/libpthread.a"); assert FileCopy("ports/musl/empty.a", "root/Applications/POSIX/lib/librt.a"); // TODO Replace calls to cp. assert SystemShellExecute("cp -p -r bin/musl/include/* root/Applications/POSIX/include/"); assert SystemShellExecute("cp -p -r bin/musl/arch/generic/* root/Applications/POSIX/include/"); assert SystemShellExecute("cp -p -r ports/musl/obj_bits_%targetName%/* root/Applications/POSIX/include/"); if targetName == "x86_64" { assert SystemShellExecute("cp -p -r bin/musl/arch/x86_64/* root/Applications/POSIX/include/"); } else if targetName == "x86_32" { assert SystemShellExecute("cp -p -r bin/musl/arch/i386/* root/Applications/POSIX/include/"); } else { assert false; } } }