util: add ofc (one file compile) script
This commit is contained in:
parent
e726ca606b
commit
1751749274
2 changed files with 13 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
||||||
FROM alpine:3.16 as partial
|
FROM alpine:3.16 as partial
|
||||||
# need this for acquire (.tar.xz files):
|
# need this for acquire (.tar.xz files):
|
||||||
RUN apk add --no-cache xz
|
RUN apk add --no-cache xz
|
||||||
COPY --chmod=0755 acquire cosmocc dedupe quickconf shed \
|
COPY --chmod=0755 acquire cosmocc dedupe ofc quickconf shed \
|
||||||
/usr/local/bin/
|
/usr/local/bin/
|
||||||
RUN ln -s /usr/local/bin /nu
|
RUN ln -s /usr/local/bin /nu
|
||||||
WORKDIR /media/common
|
WORKDIR /media/common
|
||||||
|
|
12
notwa-util/ofc
Executable file
12
notwa-util/ofc
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
: "${CC:=cc}" "${LDFLAGS=-Wl,--gc-sections}" "${CFLAGS=-Os -g -Wall -Wextra \
|
||||||
|
-Wwrite-strings -Wformat=2 -Wno-unused -ffunction-sections -fdata-sections}" \
|
||||||
|
&& compile() { "$CC" $CFLAGS $CPPFLAGS -c -o "$n$obj" "$c" ;} \
|
||||||
|
&& link() { "$CC" $LDFLAGS -o "$n$dbg" "$n$obj" $LIBS ;} \
|
||||||
|
&& finish() { "${STRIP:-strip}" "$n$dbg" -o "$n$exe" ;} \
|
||||||
|
&& obj=.o dbg=.dbg exe= \
|
||||||
|
&& if [ cosmocc = "${CC##*/}" ]; then dbg=.com.dbg exe=.com \
|
||||||
|
&& finish() { "${OBJCOPY:-objcopy}" -S -O binary "$n$dbg" "$n$exe" ;} \
|
||||||
|
;fi \
|
||||||
|
&& for c in "$@"; do n="${c%.*}" && compile && link && finish || exit; done \
|
||||||
|
;
|
Loading…
Add table
Reference in a new issue