Skip to content

Commit

Permalink
fix: add all stb headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromil committed Dec 17, 2024
1 parent 9bcfe6f commit 5c2c0d1
Show file tree
Hide file tree
Showing 26 changed files with 45,589 additions and 15 deletions.
11 changes: 8 additions & 3 deletions build/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ SOURCES += \
src/kilo.o \
src/embed_libtcc1.a.o \
src/embed_include.o \
src/embed_contrib_headers.o
src/embed_contrib_headers.o \
src/embed_stb.o

all: embed cjit

Expand All @@ -20,8 +21,12 @@ embed: lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/include
bash build/embed-path.sh lib/contrib_headers
@echo "\nreturn(true);\n}\n" >> src/embedded.c
@echo "\n#endif\n" >> src/embedded.h
bash build/embed-path.sh lib/stb
@echo >> src/embedded.c
@echo "return(true);" >> src/embedded.c
@echo "}" >> src/embedded.c
@echo >> src/embedded.h
@echo "#endif" >> src/embedded.h

tinycc_config += --with-libgcc
ifeq ($(shell sestatus | awk -F': *' '/SELinux status:/ {print $2}'), enabled)
Expand Down
4 changes: 3 additions & 1 deletion build/musl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ SOURCES += \
src/embed_include.o \
src/embed_contrib_headers.o \
src/embed_libc.so.o \
src/musl-symbols.o
src/musl-symbols.o \
src/embed_stb.o

# SOURCES += src/embed-musl-libc.o src/musl-symbols.o src/kilo.o

Expand All @@ -32,6 +33,7 @@ embed: lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/include
bash build/embed-path.sh lib/contrib_headers
bash build/embed-path.sh /lib/x86_64-linux-musl/libc.so
bash build/embed-path.sh lib/stb
@echo >> src/embedded.c
@echo "return(true);" >> src/embedded.c
@echo "}" >> src/embedded.c
Expand Down
11 changes: 8 additions & 3 deletions build/osx.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ SOURCES += \
src/kilo.o \
src/embed_libtcc1.a.o \
src/embed_include.o \
src/embed_contrib_headers.o
src/embed_contrib_headers.o \
src/embed_stb.o

all: embed cjit.command

Expand All @@ -17,8 +18,12 @@ embed: lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/include
bash build/embed-path.sh lib/contrib_headers
@echo "\nreturn(true);\n}\n" >> src/embedded.c
@echo "\n#endif\n" >> src/embedded.h
bash build/embed-path.sh lib/stb
@echo >> src/embedded.c
@echo "return(true);" >> src/embedded.c
@echo "}" >> src/embedded.c
@echo >> src/embedded.h
@echo "#endif" >> src/embedded.h

cjit.command: ${SOURCES}
$(cc) $(cflags) -o $@ $(SOURCES) ${ldflags} ${ldadd}
Expand Down
51 changes: 51 additions & 0 deletions build/update-libs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

odir=lib/contrib_headers

function fetch() {
[ -z $odir ] && {
>&2 echo "Script error: \$odir not set"
exit 1
}
out="$1"
url="$2"
mkdir -p ${odir}
mkdir -p .${odir}
if [ -r ${odir}/${out} ];then
mv ${odir}/${out} .${odir}/${out}
>&2 echo "Update: ${odir}/${out}"
else
>&2 echo "Download: ${odir}/${out}"
fi
curl -sL --output ${odir}/${out} ${url}
[ -r .${odir}/${out} ] || return
diff ${odir}/${out} .${odir}/${out} > /dev/null || {
>&2 echo "DIFF ${out}"
>&2 diff ${odir}/${out} .${odir}/${out}
>&2 echo "END DIFF"
}
rm -rf .${odir}
}

fetch dmon.h https://raw.githubusercontent.com/septag/dmon/master/dmon.h
fetch nuklear.h https://raw.githubusercontent.com/Immediate-Mode-UI/Nuklear/master/nuklear.h
fetch miniaudio.h https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h

# win32ports
odir="lib/win32ports"
fetch unistd.h https://raw.githubusercontent.com/win32ports/unistd_h/refs/heads/master/unistd.h
fetch strings.h https://raw.githubusercontent.com/win32ports/strings_h/refs/heads/master/strings.h
fetch dirent.h https://raw.githubusercontent.com/win32ports/dirent_h/refs/heads/master/dirent.h
odir="lib/win32ports/sys"
fetch time.h https://raw.githubusercontent.com/win32ports/sys_time_h/refs/heads/master/sys/time.h
fetch wait.h https://raw.githubusercontent.com/win32ports/sys_wait_h/refs/heads/master/sys/wait.h


[ "$1" = "stb" ] && {
# std headers
if [ -d stb ]; then cd stb && git pull --rebase; cd -
else git clone https://github.com/nothings/stb.git
fi
mkdir -p lib/stb
cp stb/*.h lib/stb/
}
8 changes: 5 additions & 3 deletions build/win-native.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ ldadd := lib/tinycc/libtcc.a -lshlwapi
SOURCES += src/win-compat.o \
src/embed_libtcc1.a.o \
src/embed_include.o \
src/embed_contrib_headers.o \
src/embed_tinycc_win32.o \
src/embed_win32ports.o
src/embed_win32ports.o \
src/embed_contrib_headers.o \
src/embed_stb.o

all: embed cjit.exe

Expand All @@ -35,8 +36,9 @@ embed: lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/include
bash build/embed-path.sh lib/tinycc/win32/include tinycc_win32
bash build/embed-path.sh lib/contrib_headers
bash build/embed-path.sh lib/win32ports
bash build/embed-path.sh lib/contrib_headers
bash build/embed-path.sh lib/stb
@echo >> src/embedded.c
@echo "return(true);" >> src/embedded.c
@echo "}" >> src/embedded.c
Expand Down
15 changes: 10 additions & 5 deletions build/win-wsl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ tinycc_config += --ar=${ar}
SOURCES += src/win-compat.o \
src/embed_libtcc1.a.o \
src/embed_include.o \
src/embed_contrib_headers.o \
src/embed_tinycc_win32.o \
src/embed_win32ports.o
src/embed_win32ports.o \
src/embed_contrib_headers.o \
src/embed_stb.o

all: deps embed cjit.exe

Expand All @@ -33,10 +34,14 @@ embed: lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/libtcc1.a
bash build/embed-path.sh lib/tinycc/include
bash build/embed-path.sh lib/tinycc/win32/include tinycc_win32
bash build/embed-path.sh lib/contrib_headers
bash build/embed-path.sh lib/win32ports
@echo "\nreturn(true);\n}\n" >> src/embedded.c
@echo "\n#endif\n" >> src/embedded.h
bash build/embed-path.sh lib/contrib_headers
bash build/embed-path.sh lib/stb
@echo >> src/embedded.c
@echo "return(true);" >> src/embedded.c
@echo "}" >> src/embedded.c
@echo >> src/embedded.h
@echo "#endif" >> src/embedded.h

cjit.exe: ${SOURCES}
./build/stamp-exe.sh
Expand Down
Loading

0 comments on commit 5c2c0d1

Please sign in to comment.