mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 07:29:23 +00:00
Support <isystem> includes in monorepo
This commit is contained in:
parent
5330442d85
commit
ea28f93a26
8 changed files with 298 additions and 51 deletions
Binary file not shown.
|
@ -222,7 +222,8 @@ DEFAULT_CPPFLAGS += \
|
|||
-D_COSMO_SOURCE \
|
||||
-DMODE='"$(MODE)"' \
|
||||
-nostdinc \
|
||||
-iquote .
|
||||
-iquote. \
|
||||
-isystem libc/isystem
|
||||
|
||||
DEFAULT_CFLAGS = \
|
||||
-std=gnu2x
|
||||
|
|
|
@ -100,8 +100,6 @@ EXAMPLES_DIRECTDEPS = \
|
|||
EXAMPLES_DEPS := \
|
||||
$(call uniq,$(foreach x,$(EXAMPLES_DIRECTDEPS),$($(x))))
|
||||
|
||||
$(EXAMPLES_OBJS): override CFLAGS += -isystem libc/isystem
|
||||
|
||||
o/$(MODE)/examples/examples.pkg: \
|
||||
$(EXAMPLES_OBJS) \
|
||||
$(foreach x,$(EXAMPLES_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#ifdef __COSMOCC__
|
||||
#ifndef _COSMO_SOURCE
|
||||
#define _COSMO_SOURCE
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <cosmo.h>
|
||||
#include <errno.h>
|
||||
|
@ -22,42 +23,6 @@
|
|||
#include <sys/auxv.h>
|
||||
#include <sys/socket.h>
|
||||
#include <time.h>
|
||||
#else
|
||||
#include "libc/assert.h"
|
||||
#include "libc/atomic.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/pledge.h"
|
||||
#include "libc/calls/struct/sigaction.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/sysv/consts/limits.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/consts/so.h"
|
||||
#include "libc/sysv/consts/sock.h"
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
#include "libc/sysv/consts/tcp.h"
|
||||
#include "libc/sysv/consts/timer.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/thread2.h"
|
||||
#include "net/http/http.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @fileoverview greenbean lightweight threaded web server
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef _SYS_PROCFS_H
|
||||
#define _SYS_PROCFS_H
|
||||
#include <sys/user.h>
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
261
libc/libc.mk
261
libc/libc.mk
|
@ -3,12 +3,269 @@
|
|||
|
||||
PKGS += LIBC
|
||||
|
||||
LIBC_HDRS = $(filter %.h,$(LIBC_FILES))
|
||||
LIBC_ISYSTEM = \
|
||||
libc/isystem/algorithm \
|
||||
libc/isystem/alloca.h \
|
||||
libc/isystem/ammintrin.h \
|
||||
libc/isystem/any \
|
||||
libc/isystem/ar.h \
|
||||
libc/isystem/arm_acle.h \
|
||||
libc/isystem/arm_bf16.h \
|
||||
libc/isystem/arm_fp16.h \
|
||||
libc/isystem/arm_neon.h \
|
||||
libc/isystem/arpa/inet.h \
|
||||
libc/isystem/array \
|
||||
libc/isystem/assert.h \
|
||||
libc/isystem/atomic \
|
||||
libc/isystem/bit \
|
||||
libc/isystem/bitset \
|
||||
libc/isystem/byteswap.h \
|
||||
libc/isystem/cassert \
|
||||
libc/isystem/ccomplex \
|
||||
libc/isystem/cctype \
|
||||
libc/isystem/cerrno \
|
||||
libc/isystem/cfenv \
|
||||
libc/isystem/cfloat \
|
||||
libc/isystem/charconv \
|
||||
libc/isystem/chrono \
|
||||
libc/isystem/cinttypes \
|
||||
libc/isystem/ciso646 \
|
||||
libc/isystem/climits \
|
||||
libc/isystem/clocale \
|
||||
libc/isystem/clzerointrin.h \
|
||||
libc/isystem/cmath \
|
||||
libc/isystem/codecvt \
|
||||
libc/isystem/compare \
|
||||
libc/isystem/complex \
|
||||
libc/isystem/complex.h \
|
||||
libc/isystem/condition_variable \
|
||||
libc/isystem/cosmo.h \
|
||||
libc/isystem/cpio.h \
|
||||
libc/isystem/cpuid.h \
|
||||
libc/isystem/crypt.h \
|
||||
libc/isystem/csetjmp \
|
||||
libc/isystem/csignal \
|
||||
libc/isystem/cstdarg \
|
||||
libc/isystem/cstdbool \
|
||||
libc/isystem/cstddef \
|
||||
libc/isystem/cstdint \
|
||||
libc/isystem/cstdio \
|
||||
libc/isystem/cstdlib \
|
||||
libc/isystem/cstring \
|
||||
libc/isystem/ctgmath \
|
||||
libc/isystem/ctime \
|
||||
libc/isystem/ctype.h \
|
||||
libc/isystem/cwchar \
|
||||
libc/isystem/cwctype \
|
||||
libc/isystem/deque \
|
||||
libc/isystem/dirent.h \
|
||||
libc/isystem/dlfcn.h \
|
||||
libc/isystem/elf.h \
|
||||
libc/isystem/emmintrin.h \
|
||||
libc/isystem/endian.h \
|
||||
libc/isystem/err.h \
|
||||
libc/isystem/errno.h \
|
||||
libc/isystem/exception \
|
||||
libc/isystem/execution \
|
||||
libc/isystem/fcntl.h \
|
||||
libc/isystem/features.h \
|
||||
libc/isystem/fenv.h \
|
||||
libc/isystem/filesystem \
|
||||
libc/isystem/float.h \
|
||||
libc/isystem/fnmatch.h \
|
||||
libc/isystem/forward_list \
|
||||
libc/isystem/fstream \
|
||||
libc/isystem/ftw.h \
|
||||
libc/isystem/functional \
|
||||
libc/isystem/getopt.h \
|
||||
libc/isystem/glob.h \
|
||||
libc/isystem/grp.h \
|
||||
libc/isystem/iconv.h \
|
||||
libc/isystem/ifaddrs.h \
|
||||
libc/isystem/immintrin.h \
|
||||
libc/isystem/initializer_list \
|
||||
libc/isystem/inttypes.h \
|
||||
libc/isystem/iomanip \
|
||||
libc/isystem/ios \
|
||||
libc/isystem/iosfwd \
|
||||
libc/isystem/iostream \
|
||||
libc/isystem/iso646.h \
|
||||
libc/isystem/istream \
|
||||
libc/isystem/iterator \
|
||||
libc/isystem/langinfo.h \
|
||||
libc/isystem/libgen.h \
|
||||
libc/isystem/limits \
|
||||
libc/isystem/limits.h \
|
||||
libc/isystem/linux/futex.h \
|
||||
libc/isystem/linux/limits.h \
|
||||
libc/isystem/linux/param.h \
|
||||
libc/isystem/linux/types.h \
|
||||
libc/isystem/list \
|
||||
libc/isystem/locale \
|
||||
libc/isystem/locale.h \
|
||||
libc/isystem/malloc.h \
|
||||
libc/isystem/map \
|
||||
libc/isystem/math.h \
|
||||
libc/isystem/memory \
|
||||
libc/isystem/memory.h \
|
||||
libc/isystem/mm3dnow.h \
|
||||
libc/isystem/mm_malloc.h \
|
||||
libc/isystem/mmintrin.h \
|
||||
libc/isystem/mntent.h \
|
||||
libc/isystem/monetary.h \
|
||||
libc/isystem/mutex \
|
||||
libc/isystem/mwaitxintrin.h \
|
||||
libc/isystem/net/ethernet.h \
|
||||
libc/isystem/net/if.h \
|
||||
libc/isystem/net/if_arp.h \
|
||||
libc/isystem/netdb.h \
|
||||
libc/isystem/netinet/in.h \
|
||||
libc/isystem/netinet/ip.h \
|
||||
libc/isystem/netinet/tcp.h \
|
||||
libc/isystem/netinet/udp.h \
|
||||
libc/isystem/new \
|
||||
libc/isystem/nl_types.h \
|
||||
libc/isystem/nmmintrin.h \
|
||||
libc/isystem/nsync.h \
|
||||
libc/isystem/nsync_atomic.h \
|
||||
libc/isystem/nsync_counter.h \
|
||||
libc/isystem/nsync_cv.h \
|
||||
libc/isystem/nsync_debug.h \
|
||||
libc/isystem/nsync_mu.h \
|
||||
libc/isystem/nsync_mu_wait.h \
|
||||
libc/isystem/nsync_note.h \
|
||||
libc/isystem/nsync_once.h \
|
||||
libc/isystem/nsync_time.h \
|
||||
libc/isystem/nsync_waiter.h \
|
||||
libc/isystem/numeric \
|
||||
libc/isystem/optional \
|
||||
libc/isystem/ostream \
|
||||
libc/isystem/paths.h \
|
||||
libc/isystem/pmmintrin.h \
|
||||
libc/isystem/poll.h \
|
||||
libc/isystem/popcntintrin.h \
|
||||
libc/isystem/pthread.h \
|
||||
libc/isystem/pwd.h \
|
||||
libc/isystem/queue \
|
||||
libc/isystem/random \
|
||||
libc/isystem/ratio \
|
||||
libc/isystem/regex \
|
||||
libc/isystem/regex.h \
|
||||
libc/isystem/sched.h \
|
||||
libc/isystem/scoped_allocator \
|
||||
libc/isystem/search.h \
|
||||
libc/isystem/semaphore.h \
|
||||
libc/isystem/set \
|
||||
libc/isystem/setjmp.h \
|
||||
libc/isystem/sgxintrin.h \
|
||||
libc/isystem/shared_mutex \
|
||||
libc/isystem/signal.h \
|
||||
libc/isystem/smmintrin.h \
|
||||
libc/isystem/span \
|
||||
libc/isystem/spawn.h \
|
||||
libc/isystem/sstream \
|
||||
libc/isystem/stack \
|
||||
libc/isystem/stdalign.h \
|
||||
libc/isystem/stdarg.h \
|
||||
libc/isystem/stdatomic.h \
|
||||
libc/isystem/stdbool.h \
|
||||
libc/isystem/stdc-predef.h \
|
||||
libc/isystem/stdckdint.h \
|
||||
libc/isystem/stddef.h \
|
||||
libc/isystem/stdexcept \
|
||||
libc/isystem/stdint.h \
|
||||
libc/isystem/stdio.h \
|
||||
libc/isystem/stdio_ext.h \
|
||||
libc/isystem/stdlib.h \
|
||||
libc/isystem/stdnoreturn.h \
|
||||
libc/isystem/streambuf \
|
||||
libc/isystem/string \
|
||||
libc/isystem/string.h \
|
||||
libc/isystem/string_view \
|
||||
libc/isystem/strings.h \
|
||||
libc/isystem/strstream \
|
||||
libc/isystem/sys/auxv.h \
|
||||
libc/isystem/sys/cdefs.h \
|
||||
libc/isystem/sys/dir.h \
|
||||
libc/isystem/sys/errno.h \
|
||||
libc/isystem/sys/event.h \
|
||||
libc/isystem/sys/fcntl.h \
|
||||
libc/isystem/sys/file.h \
|
||||
libc/isystem/sys/ioctl.h \
|
||||
libc/isystem/sys/ipc.h \
|
||||
libc/isystem/sys/mman.h \
|
||||
libc/isystem/sys/mount.h \
|
||||
libc/isystem/sys/msg.h \
|
||||
libc/isystem/sys/param.h \
|
||||
libc/isystem/sys/poll.h \
|
||||
libc/isystem/sys/prctl.h \
|
||||
libc/isystem/sys/procfs.h \
|
||||
libc/isystem/sys/ptrace.h \
|
||||
libc/isystem/sys/random.h \
|
||||
libc/isystem/sys/reboot.h \
|
||||
libc/isystem/sys/resource.h \
|
||||
libc/isystem/sys/select.h \
|
||||
libc/isystem/sys/sendfile.h \
|
||||
libc/isystem/sys/signal.h \
|
||||
libc/isystem/sys/socket.h \
|
||||
libc/isystem/sys/stat.h \
|
||||
libc/isystem/sys/statfs.h \
|
||||
libc/isystem/sys/statvfs.h \
|
||||
libc/isystem/sys/syscall.h \
|
||||
libc/isystem/sys/sysinfo.h \
|
||||
libc/isystem/sys/sysmacros.h \
|
||||
libc/isystem/sys/termios.h \
|
||||
libc/isystem/sys/time.h \
|
||||
libc/isystem/sys/times.h \
|
||||
libc/isystem/sys/ttydefaults.h \
|
||||
libc/isystem/sys/types.h \
|
||||
libc/isystem/sys/ucontext.h \
|
||||
libc/isystem/sys/uio.h \
|
||||
libc/isystem/sys/un.h \
|
||||
libc/isystem/sys/user.h \
|
||||
libc/isystem/sys/utsname.h \
|
||||
libc/isystem/sys/vfs.h \
|
||||
libc/isystem/sys/wait.h \
|
||||
libc/isystem/sysexits.h \
|
||||
libc/isystem/syslog.h \
|
||||
libc/isystem/system_error \
|
||||
libc/isystem/termios.h \
|
||||
libc/isystem/tgmath.h \
|
||||
libc/isystem/thread \
|
||||
libc/isystem/time.h \
|
||||
libc/isystem/tmmintrin.h \
|
||||
libc/isystem/tuple \
|
||||
libc/isystem/type_traits \
|
||||
libc/isystem/typeindex \
|
||||
libc/isystem/typeinfo \
|
||||
libc/isystem/uchar.h \
|
||||
libc/isystem/ucontext.h \
|
||||
libc/isystem/uio.h \
|
||||
libc/isystem/unistd.h \
|
||||
libc/isystem/unordered_map \
|
||||
libc/isystem/unordered_set \
|
||||
libc/isystem/utility \
|
||||
libc/isystem/utime.h \
|
||||
libc/isystem/utmp.h \
|
||||
libc/isystem/utmpx.h \
|
||||
libc/isystem/valarray \
|
||||
libc/isystem/variant \
|
||||
libc/isystem/vector \
|
||||
libc/isystem/version \
|
||||
libc/isystem/wait.h \
|
||||
libc/isystem/wchar.h \
|
||||
libc/isystem/wctype.h \
|
||||
libc/isystem/winternl.h \
|
||||
libc/isystem/wmmintrin.h \
|
||||
libc/isystem/x86intrin.h \
|
||||
libc/isystem/xmmintrin.h
|
||||
|
||||
LIBC_HDRS = $(filter %.h,$(LIBC_FILES)) $(LIBC_ISYSTEM)
|
||||
LIBC_INCS = $(filter %.inc,$(LIBC_FILES))
|
||||
LIBC_CHECKS = $(LIBC_HDRS:%=o/$(MODE)/%.ok)
|
||||
|
||||
ifneq ($(MODE), llvm)
|
||||
LIBC_FILES := $(wildcard libc/*) $(wildcard libc/isystem/*)
|
||||
LIBC_FILES := $(wildcard libc/*)
|
||||
else
|
||||
LIBC_FILES := $(wildcard libc/*)
|
||||
endif
|
||||
|
|
|
@ -6,7 +6,7 @@ PKGS += LIBC_STDIO
|
|||
LIBC_STDIO_ARTIFACTS += LIBC_STDIO_A
|
||||
LIBC_STDIO = $(LIBC_STDIO_A_DEPS) $(LIBC_STDIO_A)
|
||||
LIBC_STDIO_A = o/$(MODE)/libc/stdio/stdio.a
|
||||
LIBC_STDIO_A_FILES := $(wildcard libc/stdio/*) $(wildcard libc/stdio/unlocked/*)
|
||||
LIBC_STDIO_A_FILES := $(wildcard libc/stdio/*)
|
||||
LIBC_STDIO_A_HDRS = $(filter %.h,$(LIBC_STDIO_A_FILES))
|
||||
LIBC_STDIO_A_SRCS_S = $(filter %.S,$(LIBC_STDIO_A_FILES))
|
||||
LIBC_STDIO_A_SRCS_C = $(filter %.c,$(LIBC_STDIO_A_FILES))
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/libgen.h"
|
||||
#include "libc/fmt/magnumstrs.internal.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/limits.h"
|
||||
|
@ -81,7 +82,8 @@
|
|||
" INPUT should be source or @args.txt\n" \
|
||||
"\n"
|
||||
|
||||
#define kIncludePrefix "include \""
|
||||
#define kIncludePrefix "include "
|
||||
#define kSystemIncludes "libc/isystem/"
|
||||
|
||||
struct Source {
|
||||
unsigned hash;
|
||||
|
@ -267,14 +269,17 @@ static void LoadRelationships(int argc, char *argv[]) {
|
|||
char *map;
|
||||
ssize_t rc;
|
||||
struct GetArgs ga;
|
||||
char srcdirbuf[256];
|
||||
size_t n, size, inclen;
|
||||
unsigned srcid, dependency;
|
||||
const char *p, *pe, *src, *path, *pathend;
|
||||
const char *p, *pe, *src, *path, *pathend, *srcdir;
|
||||
getargs_init(&ga, argv + optind);
|
||||
inclen = strlen(kIncludePrefix);
|
||||
while ((src = getargs_next(&ga))) {
|
||||
n = strlen(src);
|
||||
srcid = GetSourceId(src, n);
|
||||
strlcpy(srcdirbuf, src, sizeof(srcdirbuf));
|
||||
srcdir = dirname(srcdirbuf);
|
||||
if ((fd = open(src, O_RDONLY)) == -1) {
|
||||
if (errno == ENOENT && ga.path) {
|
||||
// This code helps GNU Make automatically fix itself when we
|
||||
|
@ -296,13 +301,33 @@ static void LoadRelationships(int argc, char *argv[]) {
|
|||
DieSys(src);
|
||||
}
|
||||
for (p = map + 1, pe = map + size; p < pe; ++p) {
|
||||
int right;
|
||||
char juf[256], *jb;
|
||||
char buf[256], *bp = buf;
|
||||
if (!(p = memmem(p, pe - p, kIncludePrefix, inclen))) break;
|
||||
path = p + inclen;
|
||||
pathend = memchr(path, '"', pe - path);
|
||||
if (pathend && //
|
||||
path = p + inclen + 1;
|
||||
if (path[-1] == '"') {
|
||||
right = '"';
|
||||
} else if (path[-1] == '<') {
|
||||
bp = mempcpy(bp, kSystemIncludes, strlen(kSystemIncludes));
|
||||
right = '>';
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
pathend = memchr(path, right, pe - path);
|
||||
if (pathend && pathend - path > 0 && //
|
||||
(p[-1] == '#' || p[-1] == '.') && //
|
||||
(p - map == 1 || p[-2] == '\n')) { //
|
||||
dependency = GetSourceId(path, pathend - path);
|
||||
(p - map == 1 || p[-2] == '\n') && //
|
||||
(bp - buf) + (pathend - path) < sizeof(buf)) { //
|
||||
*(bp = mempcpy(bp, path, pathend - path)) = 0;
|
||||
if (right == '>' && !isregularfile(buf)) continue;
|
||||
if (!strchr(buf, '/') && !isregularfile(buf)) {
|
||||
if (!(jb = __join_paths(juf, sizeof(juf), srcdir, buf))) continue;
|
||||
if (!isregularfile(jb)) continue;
|
||||
dependency = GetSourceId(jb, strlen(jb));
|
||||
} else {
|
||||
dependency = GetSourceId(buf, bp - buf);
|
||||
}
|
||||
AppendEdge(&edges, dependency, srcid);
|
||||
p = pathend;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue