Skip to content

Commit

Permalink
build: Save cc.sh build products to gen/
Browse files Browse the repository at this point in the history
  • Loading branch information
tavianator committed Jun 21, 2024
1 parent 4bc06bd commit 4bc7914
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
11 changes: 2 additions & 9 deletions build/cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,5 @@

# Run the compiler and check if it succeeded

set -eu

TMP=$(mktemp)
trap 'rm -f "$TMP"' EXIT

(
set -x
$XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS "$@" $XLDLIBS -o "$TMP"
)
set -eux
$XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS "$@" $XLDLIBS
2 changes: 1 addition & 1 deletion build/deps.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include build/exports.mk
gen/deps.mk::
${MSG} "[ GEN] $@"
@printf '# %s\n' "$@" >$@
@if build/cc.sh -MD -MP -MF /dev/null build/empty.c; then \
@if build/cc.sh -MD -MP build/empty.c -o gen/.deps.out; then \
printf '_CPPFLAGS += -MD -MP\n'; \
fi >>$@ 2>$@.log
${VCAT} $@
Expand Down
6 changes: 4 additions & 2 deletions build/header.mk
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,18 @@ gen/config.h: ${PKG_HEADERS} ${HEADERS}

# The short name of the config test
SLUG = ${@:gen/%.h=%}
# The hidden output file name
OUT = ${SLUG:has/%=gen/has/.%.out}

${HEADERS}: cc
@${MKDIR} ${@D}
@build/define-if.sh ${SLUG} build/cc.sh build/${SLUG}.c >$@ 2>$@.log; \
@build/define-if.sh ${SLUG} build/cc.sh build/${SLUG}.c -o ${OUT} >$@ 2>$@.log; \
build/msg-if.sh "[ CC ] ${SLUG}.c" test $$? -eq 0
.PHONY: ${HEADERS}

# Check that the C compiler works at all
cc::
@build/cc.sh build/empty.c 2>gen/cc.log; \
@build/cc.sh build/empty.c -o gen/.cc.out 2>gen/cc.log; \
ret=$$?; \
build/msg-if.sh "[ CC ] build/empty.c" test $$ret -eq 0; \
exit $$ret
2 changes: 1 addition & 1 deletion build/pkgconf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if [ -z "$MODE" ]; then
CFLAGS=$("$0" --cflags "$LIB") || exit 1
LDFLAGS=$("$0" --ldflags "$LIB") || exit 1
LDLIBS=$("$0" --ldlibs "$LIB") || exit 1
build/cc.sh $CFLAGS $LDFLAGS build/with/$LIB.c $LDLIBS || exit 1
build/cc.sh $CFLAGS $LDFLAGS "build/with/$LIB.c" $LDLIBS -o "gen/with/.$LIB.out" || exit 1
done
fi

Expand Down

0 comments on commit 4bc7914

Please sign in to comment.