blob: e1d2b0b3dfb3bf73d3bf40bd8b5bdcf6ac8779c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/bin/sh
# Copyright © Tavian Barnes <tavianator@tavianator.com>
# SPDX-License-Identifier: 0BSD
# Run the compiler and check if it succeeded. Usage:
#
# $ build/cc.sh [-q] path/to/file.c [-flags -Warnings ...]
set -eu
QUIET=
if [ "$1" = "-q" ]; then
QUIET=y
shift
fi
# Source files can specify their own flags with lines like
#
# /// _CFLAGS += -Wmissing-variable-declarations
#
# which will be added to the makefile on success, or lines like
#
# /// -Werror
#
# which are just used for the current file.
EXTRA_FLAGS=$(sed -n '\|^///|{s|^/// ||; s|[^=]*= ||; p;}' "$1")
# Without -q, print the executed command for config.log
if [ -z "$QUIET" ]; then
set -x
fi
$XCC $XCPPFLAGS $XCFLAGS $XLDFLAGS "$@" $EXTRA_FLAGS $XLDLIBS
|