git » sdk » commit 501769e

Build batteries included and not and static

author Stephen Paul Weber
2026-03-10 16:11:01 UTC
committer Stephen Paul Weber
2026-03-10 16:11:01 UTC
parent 57204d7bc24e40d630261eae1aca173dff12b8f0

Build batteries included and not and static

.gitignore +2 -0
Makefile +19 -4
build-misc/Containerfile.image +3 -4
cpp/configure.simple +8 -1

diff --git a/.gitignore b/.gitignore
index 2cae8da..788f7c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,8 @@ npm/*.d.ts
 npm/*.js
 npm/*.mjs
 npm/*.map
+*.so
+*.a
 npm/borogove-enums.ts
 npm/borogove-browser-enums.ts
 node_modules
diff --git a/Makefile b/Makefile
index e0c3e80..472b66d 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ HAXE_PATH=$$HOME/Software/haxe-4.3.1/hxnodejs/12,1,0/src
 
 .PHONY: all test doc hx-build-dep cpp/libborogove.dso npm/borogove-browser.js npm/borogove.js cpp
 
-all: npm libborogove.so
+all: npm libborogove.batteriesincluded.so libborogove.so libborogove.a
 
 test:
 	haxe test.hxml
@@ -51,14 +51,16 @@ cpp/libborogove.dso:
 	$(RM) cpp/libborogove.dso.hash
 
 cpp:
+	haxe -D no-compilation cpp.hxml
 	$(RM) -r cpp/obj
+	$(RM) cpp/*.dso
 	$(RM) cpp/src/__main__.cpp
 	$(RM) cpp/src/__files__.cpp
-	cp cpp/alt/SSL-mbedtls3.cpp cpp/src/hx/libs/ssl/SSL.cpp
 	cp "$(shell haxelib libpath hxcpp)"/include/*.h cpp/include/
 	cp -r "$(shell haxelib libpath hxcpp)"/include/hx cpp/include/
 	cp -r "$(shell haxelib libpath hxcpp)"/include/cpp cpp/include/
 	mkdir -p cpp/src/hx/libs/ssl
+	cp cpp/alt/SSL-mbedtls3.cpp cpp/src/hx/libs/ssl/SSL.cpp
 	cp -r "$(shell haxelib libpath hxcpp)"/src/hx/libs/std cpp/src/hx/libs/
 	cp -r "$(shell haxelib libpath hxcpp)"/src/hx/libs/regexp cpp/src/hx/libs/
 	cp -r "$(shell haxelib libpath hxcpp)"/src/hx/libs/sqlite cpp/src/hx/libs/
@@ -82,9 +84,22 @@ cpp:
 	cp "$(shell haxelib libpath hxcpp)"/src/Array.cpp cpp/src/
 	cp "$(shell haxelib libpath hxcpp)"/src/Dynamic.cpp cpp/src/
 	cp "$(shell haxelib libpath hxcpp)"/src/Math.cpp cpp/src/
+	cd cpp && ./configure.simple
+
+libborogove.batteriesincluded.so: cpp/libborogove.dso
+	mv cpp/libborogove.dso libborogove.batteriesincluded.so
+
+cpp/libborogove.so: cpp
+	cd cpp && $(MAKE) -j libborogove.so
+
+cpp/libborogove.a: cpp
+	cd cpp && $(MAKE) -j libborogove.a
+
+libborogove.so: cpp/libborogove.so
+	mv cpp/libborogove.so libborogove.so
 
-libborogove.so: cpp/libborogove.dso
-	mv cpp/libborogove.dso libborogove.so
+libborogove.a: cpp/libborogove.a
+	mv cpp/libborogove.a libborogove.a
 
 doc:
 	npx @microsoft/api-extractor run -c npm/api-extractor.json || true
diff --git a/build-misc/Containerfile.image b/build-misc/Containerfile.image
index a53c2fb..98f2bcc 100644
--- a/build-misc/Containerfile.image
+++ b/build-misc/Containerfile.image
@@ -59,18 +59,15 @@ RUN printf '#!/bin/bash\nexec /usr/bin/node --tls-max-v1.2 "$@"' > /usr/local/bi
  && npm install typescript
 
 RUN haxelib setup /opt/haxe
-
 ENV HAXE_STD_PATH=/opt/haxe/std
-
 COPY Makefile *.hxml /usr/src/sdk/
-
 COPY . /usr/src/sdk/
 
 RUN make hx-build-dep
-
 RUN cd /opt/haxe/hxcpp/git/tools/hxcpp && haxe compile.hxml
 
 RUN make
+RUN cd cpp && make clean
 
 RUN make test
 
@@ -80,6 +77,8 @@ WORKDIR /opt/sdk
 
 COPY --from=build /usr/src/sdk/cpp ./cpp
 COPY --from=build /usr/src/sdk/libborogove.so ./libborogove.so
+COPY --from=build /usr/src/sdk/libborogove.a ./libborogove.a
+COPY --from=build /usr/src/sdk/libborogove.batteriesincluded.so ./libborogove.batteriesincluded.so
 COPY --from=build /usr/src/sdk/npm ./npm
 
 CMD ["cp", "-R", "/opt/sdk", "/output"]
diff --git a/cpp/configure.simple b/cpp/configure.simple
index bc684e8..53f9d5a 100755
--- a/cpp/configure.simple
+++ b/cpp/configure.simple
@@ -3,7 +3,10 @@
 # Create a Makefile just from the sources
 
 echo 'CXXFLAGS=-Wno-invalid-offsetof -fPIC -O2 -DHX_LINUX -DHX_SMART_STRINGS=1 -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=430 -Iinclude' > Makefile
-echo 'LDFLAGS=-shared -lmbedtls -ldatachannel $$(pkg-config --libs sqlite3 opus libstrophe) $$(pcre2-config --libs16 --libs8)' >> Makefile
+echo 'LDFLAGS=-shared -flto -lmbedtls -ldatachannel $$(pkg-config --libs sqlite3 opus libstrophe) $$(pcre2-config --libs16 --libs8)' >> Makefile
+echo >> Makefile
+
+echo ".PHONY: clean" >> Makefile
 echo >> Makefile
 
 printf "libborogove.so: " >> Makefile
@@ -15,3 +18,7 @@ echo >> Makefile
 printf "libborogove.a: " >> Makefile
 find src -name '*.cpp' -print0 | xargs -0 | sed -e's/\.cpp/\.o/g' >> Makefile
 echo '	$(AR) rcs $@ $^' >> Makefile
+
+echo "clean:" >> Makefile
+echo '	find -name *.o -delete' >> Makefile
+echo '	$(RM) *.so *.a' >> Makefile