diff --git a/build/bootstrap/rollup b/build/bootstrap/rollup deleted file mode 100755 index 47d2d505c54..00000000000 Binary files a/build/bootstrap/rollup and /dev/null differ diff --git a/third_party/make/job.c b/third_party/make/job.c index 9b0399d9818..66c2f27fffa 100644 --- a/third_party/make/job.c +++ b/third_party/make/job.c @@ -427,6 +427,7 @@ is_bourne_compatible_shell (const char *path) "sh", "bash", "dash", + "cocmd", "ksh", "rksh", "zsh", diff --git a/tool/build/rollup.c b/tool/build/rollup.c deleted file mode 100644 index 2dcc61596b4..00000000000 --- a/tool/build/rollup.c +++ /dev/null @@ -1,177 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/calls.h" -#include "libc/calls/struct/stat.h" -#include "libc/mem/mem.h" -#include "libc/runtime/runtime.h" -#include "libc/stdio/append.h" -#include "libc/stdio/stdio.h" -#include "libc/str/str.h" -#include "libc/sysv/consts/map.h" -#include "libc/sysv/consts/o.h" -#include "libc/sysv/consts/prot.h" -#include "tool/build/lib/getargs.h" -#include "tool/build/lib/interner.h" - -#define LOOKINGAT(p, pe, s) LookingAt(p, pe, s, strlen(s)) - -struct Visited { - size_t i, n; - const char **p; -}; - -char *output; -const char *prog; -struct Interner *visited; - -void Visit(const char *); - -static wontreturn void Die(const char *reason) { - tinyprint(2, prog, ": ", reason, "\n", NULL); - exit(1); -} - -static wontreturn void DieSys(const char *thing) { - perror(thing); - exit(1); -} - -static wontreturn void DieOom(void) { - Die("out of memory"); -} - -static void Appends(char **b, const char *s) { - if (appends(b, s) == -1) - DieOom(); -} - -static void Appendd(char **b, const void *p, size_t n) { - if (appendd(b, p, n) == -1) - DieOom(); -} - -size_t GetFdSize(int fd) { - struct stat st; - if (fstat(fd, &st)) { - DieSys("fstat"); - } - return st.st_size; -} - -bool LookingAt(const char *p, const char *pe, const char *s, size_t n) { - return pe - p >= n && memcmp(p, s, n) == 0; -} - -void Process(const char *p, const char *pe, const char *path, bool isheader) { - int level; - bool noformat; - const char *p2, *dq, *name; - for (noformat = false, level = 0; p < pe; p = p2) { - p2 = memchr(p, '\n', pe - p); - p2 = p2 ? p2 + 1 : pe; - if (LOOKINGAT(p, pe, "#if")) { - if (isheader && !level++) - continue; - } - if (LOOKINGAT(p, pe, "#endif")) { - if (isheader && !--level) - continue; - } - if (LOOKINGAT(p, pe, "/* clang-format off */")) { - noformat = true; - } else if (LOOKINGAT(p, pe, "/* clang-format on */")) { - noformat = false; - } - if (LOOKINGAT(p, pe, "#include \"")) { - name = p + strlen("#include \""); - dq = memchr(name, '"', pe - name); - if (dq) { - Visit(strndup(name, dq - name)); - continue; - } - } - Appendd(&output, p, p2 - p); - } - if (noformat) { - Appends(&output, "/* clang-format on */\n"); - } -} - -void Visit(const char *path) { - int fd; - char *map; - size_t size; - bool isheader; - if (!endswith(path, ".h") && !endswith(path, ".inc")) - return; - if (endswith(path, ".internal.h")) - return; - if (endswith(path, "/internal.h")) - return; - if (endswith(path, ".internal.inc")) - return; - if (endswith(path, "/internal.inc")) - return; - if (startswith(path, "libc/isystem/")) - return; - isheader = endswith(path, ".h"); - if (isheader && isinterned(visited, path)) - return; - Appends(&output, "\n\f\n/*!BEGIN "); - Appends(&output, path); - Appends(&output, " */\n\n"); - intern(visited, path); - if ((fd = open(path, O_RDONLY)) == -1) - DieSys(path); - if ((size = GetFdSize(fd))) { - map = mmap(0, size, PROT_READ, MAP_PRIVATE, fd, 0); - if (map == MAP_FAILED) - DieSys(path); - Process(map, map + size, path, isheader); - if (munmap(map, size)) - DieSys(path); - } - if (close(fd)) - DieSys(path); -} - -int main(int argc, char *argv[]) { - size_t bytes; - const char *src; - struct GetArgs ga; - prog = argv[0]; - if (!prog) - prog = "rollup"; - visited = newinterner(); - Appends(&output, "#ifndef COSMOPOLITAN_H_\n"); - Appends(&output, "#define COSMOPOLITAN_H_\n"); - getargs_init(&ga, argv + 1); - while ((src = getargs_next(&ga))) { - Visit(src); - } - getargs_destroy(&ga); - Appends(&output, "\n"); - Appends(&output, "#endif /* COSMOPOLITAN_H_ */\n"); - bytes = appendz(output).i; - if (write(1, output, bytes) != bytes) { - DieSys(prog); - } - freeinterner(visited); - return 0; -} diff --git a/tool/cosmocc/package.sh b/tool/cosmocc/package.sh index 70e76328cc8..0ad1fc091e9 100755 --- a/tool/cosmocc/package.sh +++ b/tool/cosmocc/package.sh @@ -44,6 +44,19 @@ make -j64 m=$AMD64 \ o/$AMD64/tool/build/zipobj.dbg \ o/$AMD64/tool/build/apelink.dbg \ o/$AMD64/tool/build/pecheck.dbg \ + o/$AMD64/tool/build/ar.dbg \ + o/$AMD64/tool/build/chmod.dbg \ + o/$AMD64/tool/build/cocmd.dbg \ + o/$AMD64/tool/build/compile.dbg \ + o/$AMD64/tool/build/cp.dbg \ + o/$AMD64/tool/build/echo.dbg \ + o/$AMD64/tool/build/gzip.dbg \ + o/$AMD64/tool/build/objbincopy.dbg \ + o/$AMD64/tool/build/package.dbg \ + o/$AMD64/tool/build/rm.dbg \ + o/$AMD64/tool/build/touch.dbg \ + o/$AMD64/tool/build/sha256sum.dbg \ + o/$AMD64/tool/build/resymbol.dbg \ o/$AMD64/third_party/make/make.dbg \ o/$AMD64/third_party/ctags/ctags.dbg @@ -64,6 +77,19 @@ make -j64 m=$ARM64 \ o/$ARM64/tool/build/zipobj.dbg \ o/$ARM64/tool/build/apelink.dbg \ o/$ARM64/tool/build/pecheck.dbg \ + o/$ARM64/tool/build/ar.dbg \ + o/$ARM64/tool/build/chmod.dbg \ + o/$ARM64/tool/build/cocmd.dbg \ + o/$ARM64/tool/build/compile.dbg \ + o/$ARM64/tool/build/cp.dbg \ + o/$ARM64/tool/build/echo.dbg \ + o/$ARM64/tool/build/gzip.dbg \ + o/$ARM64/tool/build/objbincopy.dbg \ + o/$ARM64/tool/build/package.dbg \ + o/$ARM64/tool/build/rm.dbg \ + o/$ARM64/tool/build/touch.dbg \ + o/$ARM64/tool/build/sha256sum.dbg \ + o/$ARM64/tool/build/resymbol.dbg \ o/$ARM64/third_party/make/make.dbg \ o/$ARM64/third_party/ctags/ctags.dbg @@ -146,7 +172,9 @@ cp -af tool/cosmocc/bin/* "$OUTDIR/bin/" cp -f o/$AMD64/ape/ape.elf "$OUTDIR/bin/ape-x86_64.elf" cp -f o/$AMD64/ape/ape.macho "$OUTDIR/bin/ape-x86_64.macho" cp -f o/$ARM64/ape/ape.elf "$OUTDIR/bin/ape-aarch64.elf" -for x in assimilate march-native mktemper fixupobj zipcopy apelink pecheck mkdeps zipobj; do + +for x in assimilate march-native mktemper fixupobj zipcopy apelink pecheck mkdeps zipobj \ + ar chmod cocmd cp echo gzip objbincopy package rm touch sha256sum resymbol; do ape $APELINK \ -l o/$AMD64/ape/ape.elf \ -l o/$ARM64/ape/ape.elf \ @@ -155,6 +183,11 @@ for x in assimilate march-native mktemper fixupobj zipcopy apelink pecheck mkdep o/$AMD64/tool/build/$x.dbg \ o/$ARM64/tool/build/$x.dbg done + +for x in ar chmod cp echo gzip package rm touch sha256sum; do + mv "$OUTDIR/bin/$x" "$OUTDIR/bin/$x.ape" +done + for x in make ctags; do ape $APELINK \ -l o/$AMD64/ape/ape.elf \