Skip to content

Commit

Permalink
new simplified build for windows targets
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromil committed Sep 23, 2024
1 parent 1e30e95 commit 055322b
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 9 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ jobs:
run : sudo apt install -y zsh jq gcc-mingw-w64 g++-mingw-w64
- name: Build x86_64 windows .exe
run: |
make win
make win-dll
make -f build/win-exe.mk CCACHE=1
make clean -C src
make -f build/win-dll.mk CCACHE=1
macosx-build:
name: 🍎 Macosx build
Expand Down Expand Up @@ -416,17 +417,18 @@ jobs:
run: make clean
- name: Build x86_64 windows .exe
run: |
make win
make win-dll
make -f build/win-exe.mk CCACHE=1 RELEASE=1
make clean -C src
make -f build/win-dll.mk CCACHE=1 RELEASE=1
- name: Upload artifact win x86_64
uses: actions/upload-artifact@v4
with:
name: release-exe-win-w64
path: |
src/zenroom.exe
src/zencode-exec.exe
src/libzenroom_dll.lib
src/zenroom.dll
zenroom.exe
zencode-exec.exe
libzenroom_dll.lib
zenroom.dll
file-changes:
name: "🗃️ Check file changes"
Expand Down
2 changes: 1 addition & 1 deletion build/deps.mk
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ ed25519-donna:
tinycc-ccache: tinycc
tinycc:
$(info -- Building tinycc embedded C compiler)
cd ${pwd}/lib/tinycc && CC="${cc}" AR=${ar} CFLAGS="${cflags}" \
cd ${pwd}/lib/tinycc && CC="${libcc_cc}" AR=${ar} CFLAGS="${cflags}" \
LDFLAGS="${ldflags}" ./configure --config-musl && make libtcc.a \
libtcc1.a
36 changes: 36 additions & 0 deletions build/stamp-exe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

# this script is needed to inscribe metadata in the .exe files
# targeting windows. it creates a .rs to be used when linking

cat << EOF > zenroom.rc
1 VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Dyne.org Foundation"
VALUE "FileDescription", "Zenroom, cryptolang VM"
VALUE "FileVersion", "`date +'%Y%m%d'`"
VALUE "InternalName", "zenroom"
VALUE "LegalCopyright", "Written and designed by Denis Roio <[email protected]>"
VALUE "OriginalFilename", "zenroom.exe"
VALUE "ProductName", "Zenroom"
VALUE "ProductVersion", "3"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
EOF

if [ "$(which windres)" = "" ]; then
x86_64-w64-mingw32-windres zenroom.rc -O coff -o zenroom.res
else
windres zenroom.rc -O coff -o zenroom.res
fi
48 changes: 48 additions & 0 deletions build/win-dll.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
## Initialize build defaults
include build/init.mk

BUILD_DEPS += mimalloc

cc := $(shell which x86_64-w64-mingw32-gcc)
ar := $(shell which x86_64-w64-mingw32-ar)
ranlib := $(shell which x86_64-w64-mingw32-ranlib)
ld := $(shell which x86_64-w64-mingw32-ld)
system := Windows
cflags += -mthreads ${defines} -D'ARCH="WIN"' -DARCH_WIN -DLUA_USE_WINDOWS -DLIBRARY
ldflags += -L/usr/x86_64-w64-mingw32/lib -shared
ldadd += -l:libm.a -l:libpthread.a -lssp -Wl,--out-implib,libzenroom_dll.lib

## Specific compiler settings for all built dependencies
ifdef RELEASE
cflags += -O3 ${cflags_protection} -fPIC
else
cflags += ${cflags_debug} -fPIC
endif
ifdef CCACHE
milagro_cmake_flags += -DCMAKE_C_COMPILER_LAUNCHER=ccache
mimalloc_cmake_flags += -DCMAKE_C_COMPILER_LAUNCHER=ccache
mimalloc_cmake_flags += -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
zenroom_cc := ccache ${cc}
quantum_proof_cc := ccache ${cc}
ed25519_cc := ccache ${cc}
libcc_cc := ccache ${cc}
lua_cc := ccache ${cc}
endif


all: ${BUILD_DEPS} stamp-exe-windres zenroom.dll

stamp-exe-windres:
sh build/stamp-exe.sh

zenroom.dll: ${ZEN_SOURCES}
$(info === Linking Windows zenroom.dll)
${cc} ${cflags} ${ZEN_SOURCES} \
-o $@ zenroom.res ${ldflags} ${ldadd}

include build/deps.mk


# win-dll: ${BUILDS}
# CC=${gcc} CFLAGS="${cflags}" LDFLAGS="${ldflags}" LDADD="${ldadd}" \
# make -C src win-dll
53 changes: 53 additions & 0 deletions build/win-exe.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## Initialize build defaults
include build/init.mk

BUILD_DEPS += mimalloc

cc := $(shell which x86_64-w64-mingw32-gcc)
ar := $(shell which x86_64-w64-mingw32-ar)
ranlib := $(shell which x86_64-w64-mingw32-ranlib)
ld := $(shell which x86_64-w64-mingw32-ld)
system := Windows
cflags += -mthreads ${defines} -D'ARCH="WIN"' -DARCH_WIN -DLUA_USE_WINDOWS
ldflags += -L/usr/x86_64-w64-mingw32/lib
ldadd += -l:libm.a -l:libpthread.a -lssp

## Specific compiler settings for all built dependencies
ifdef RELEASE
cflags += -O3 ${cflags_protection} -fPIC
else
cflags += ${cflags_debug} -fPIC
endif
ifdef CCACHE
milagro_cmake_flags += -DCMAKE_C_COMPILER_LAUNCHER=ccache
mimalloc_cmake_flags += -DCMAKE_C_COMPILER_LAUNCHER=ccache
mimalloc_cmake_flags += -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
zenroom_cc := ccache ${cc}
quantum_proof_cc := ccache ${cc}
ed25519_cc := ccache ${cc}
libcc_cc := ccache ${cc}
lua_cc := ccache ${cc}
endif


all: ${BUILD_DEPS} stamp-exe-windres zenroom.exe zencode-exec.exe

stamp-exe-windres:
sh build/stamp-exe.sh

zenroom.exe: ${ZEN_SOURCES} src/cli-zenroom.o
$(info === Linking Windows zenroom.exe)
${cc} ${cflags} ${ZEN_SOURCES} src/cli-zenroom.o \
-o $@ zenroom.res ${ldflags} ${ldadd}

zencode-exec.exe: ${ZEN_SOURCES} src/zencode-exec.o
$(info === Linking Windows zencode-exec.exe)
${cc} ${cflags} ${ZEN_SOURCES} src/zencode-exec.o \
-o $@ zenroom.res ${ldflags} ${ldadd}

include build/deps.mk


# win-dll: ${BUILDS}
# CC=${gcc} CFLAGS="${cflags}" LDFLAGS="${ldflags}" LDADD="${ldadd}" \
# make -C src win-dll

0 comments on commit 055322b

Please sign in to comment.