comparison Makefile @ 476:6862ca8c1324

add: windows builds
author Sam <sam@basx.dev>
date Wed, 28 Dec 2022 20:33:15 +0700
parents d4750f2e0760
children 617c6dcddbe2
comparison
equal deleted inserted replaced
475:dc9c038cb31a 476:6862ca8c1324
1 SOURCES := $(shell find src -name '*.nim') 1 SOURCES := $(shell find src -name '*.nim')
2 COMPILE_OPTIONS := --path:src --mm:orc --experimental:strictEffects --threads:on --app:gui 2 COMPILE_OPTIONS := --path:src --mm:orc --experimental:strictEffects --threads:on --app:gui
3 DEBUG_OPTIONS := --debugger:native --checks:on --assertions:on 3 DEBUG_OPTIONS := --debugger:native --checks:on --assertions:on
4 RELEASE_OPTIONS := -d:release --checks:off --assertions:off 4 RELEASE_OPTIONS := -d:release --checks:off --assertions:off
5 WINDOWS_DEBUG_OPTIONS := --cc:vcc --passC:'/MDd' --passL:'ucrtd.lib' 5 WINDOWS_DEBUG_OPTIONS := --cc:vcc --passC:'/MDd' --passL:'ucrtd.lib'
6 WINDOWS_RELEASE_OPTIONS := --cc:vcc --passC:'/MD' --passL:'ucrt.lib' 6 WINDOWS_RELEASE_OPTIONS := --cc:vcc --passC:'/MD' --passL:'ucrt.lib'
7
8 # HACK to get cross-compilation working --------------------------------
9
10 # anywhere with a windows filesystem that has the visual basic compiler tools installed
11 WINDOWS_BASE := /mnt
12
13 # path variables, need to have correct versions
14 WINDOWS_PROGAMS := ${WINDOWS_BASE}/Program Files (x86)
15 MSVC_BUILDTOOLS_PATH := ${WINDOWS_PROGAMS}/Microsoft Visual Studio/2022/BuildTools/VC
16 WINDOWS_KIT_INCLUDE_BASE := ${WINDOWS_PROGAMS}/Windows Kits/10/Include/10.0.22000.0
17 WINDOWS_KIT_LIBS_BASE := ${WINDOWS_PROGAMS}/Windows Kits/10/Lib/10.0.22000.0
18 MSVC_PATH := ${MSVC_BUILDTOOLS_PATH}/Tools/MSVC/14.34.31933
19
20 MSVC_ADDITIONAL_PATH := ${MSVC_BUILDTOOLS_PATH}/Auxiliary/Build/
21 CL_DIR := ${MSVC_PATH}/bin/Hostx64/x64/
22 CL_INCL_DIR := ${MSVC_PATH}/include
23 WINE_NIM_VERSION := 1.6.10
24
25 # nim command:
26 WINE_NIM := WINEPATH="${CL_DIR}" wine ./build/nim_windows/nim-${WINE_NIM_VERSION}/bin/nim.exe --path:"${MSVC_ADDITIONAL_PATH}" --path:"${CL_INCL_DIR}" --passC:'/I "${CL_INCL_DIR}"' --passC:'/I "${WINDOWS_KIT_INCLUDE_BASE}/ucrt"' --passC:'/I "${WINDOWS_KIT_INCLUDE_BASE}/um"' --passC:'/I "${WINDOWS_KIT_INCLUDE_BASE}/shared"' --passL:'/LIBPATH:"${WINDOWS_KIT_LIBS_BASE}/ucrt/x64"' --passL:'/LIBPATH:"${WINDOWS_KIT_LIBS_BASE}/um/x64"' --passL:'/LIBPATH:"${MSVC_PATH}/lib/x64"'
27
28 # end of HACK-----------------------------------------------------------
29
7 30
8 make_dirs: 31 make_dirs:
9 mkdir -p build/debug/linux 32 mkdir -p build/debug/linux
10 mkdir -p build/release/linux 33 mkdir -p build/release/linux
11 mkdir -p build/debug/windows 34 mkdir -p build/debug/windows
14 # build hello_triangle 37 # build hello_triangle
15 build/debug/linux/hello_triangle: ${SOURCES} make_dirs 38 build/debug/linux/hello_triangle: ${SOURCES} make_dirs
16 nim c ${COMPILE_OPTIONS} ${DEBUG_OPTIONS} -o:$@ examples/hello_triangle.nim 39 nim c ${COMPILE_OPTIONS} ${DEBUG_OPTIONS} -o:$@ examples/hello_triangle.nim
17 build/release/linux/hello_triangle: ${SOURCES} make_dirs 40 build/release/linux/hello_triangle: ${SOURCES} make_dirs
18 nim c ${COMPILE_OPTIONS} ${RELEASE_OPTIONS} -o:$@ examples/hello_triangle.nim 41 nim c ${COMPILE_OPTIONS} ${RELEASE_OPTIONS} -o:$@ examples/hello_triangle.nim
19 build/debug/windows/hello_triangle.exe: ${SOURCES} make_dirs 42 build/debug/windows/hello_triangle.exe: ${SOURCES} make_dirs build/nim_windows
20 nim c ${COMPILE_OPTIONS} ${DEBUG_OPTIONS} ${WINDOWS_DEBUG_OPTIONS} -o:$@ examples/hello_triangle.nim 43 ${WINE_NIM} c ${COMPILE_OPTIONS} ${DEBUG_OPTIONS} ${WINDOWS_DEBUG_OPTIONS} -o:$@ examples/hello_triangle.nim
21 build/release/windows/hello_triangle.exe: ${SOURCES} make_dirs 44 build/release/windows/hello_triangle.exe: ${SOURCES} make_dirs build/nim_windows
22 nim c ${COMPILE_OPTIONS} ${RELEASE_OPTIONS} ${WINDOWS_RELEASE_OPTIONS} -o:$@ examples/hello_triangle.nim 45 ${WINE_NIM} c ${COMPILE_OPTIONS} ${RELEASE_OPTIONS} ${WINDOWS_RELEASE_OPTIONS} -o:$@ examples/hello_triangle.nim
23 46
24 build_all_linux: build/debug/linux/hello_triangle build/release/linux/hello_triangle 47 build_all_linux: build/debug/linux/hello_triangle build/release/linux/hello_triangle
25 build_all_windows: build/debug/windows/hello_triangle.exe build/release/windows/hello_triangle.exe 48 build_all_windows: build/debug/windows/hello_triangle.exe build/release/windows/hello_triangle.exe
26 build_all: build_all_linux build_all_windows 49 build_all: build_all_linux build_all_windows
27 50
28 # build maths (for testing) 51 # clean
29 build/debug/linux/maths: ${SOURCES} make_dirs
30 nim c ${COMPILE_OPTIONS} ${DEBUG_OPTIONS} -o:$@ examples/maths.nim
31 build/release/linux/maths: ${SOURCES} make_dirs
32 nim c ${COMPILE_OPTIONS} ${RELEASE_OPTIONS} -o:$@ examples/maths.nim
33 build/debug/windows/maths.exe: ${SOURCES} make_dirs
34 nim c ${COMPILE_OPTIONS} ${DEBUG_OPTIONS} ${WINDOWS_DEBUG_OPTIONS} -o:$@ examples/maths.nim
35 build/release/windows/maths.exe: ${SOURCES} make_dirs
36 nim c ${COMPILE_OPTIONS} ${RELEASE_OPTIONS} ${WINDOWS_RELEASE_OPTIONS} -o:$@ examples/maths.nim
37
38 clean: 52 clean:
39 rm -rf build 53 rm -rf build
54 # clean thirdparty too?
40 55
56 # tests
41 tests: 57 tests:
42 testament p tests/ 58 testament p tests/
43 59
44 # publish 60 # publish
45 publish_linux_debug: build/debug/linux/hello_triangle 61 publish_linux_debug: build/debug/linux/hello_triangle
49 publish_windows_debug: build/debug/linux/hello_triangle 65 publish_windows_debug: build/debug/linux/hello_triangle
50 scp $< basx.dev:/var/www/public.basx.dev/joni/windows/debug/ 66 scp $< basx.dev:/var/www/public.basx.dev/joni/windows/debug/
51 publish_windows_release: build/release/linux/hello_triangle 67 publish_windows_release: build/release/linux/hello_triangle
52 scp $< basx.dev:/var/www/public.basx.dev/joni/windows/release/ 68 scp $< basx.dev:/var/www/public.basx.dev/joni/windows/release/
53 69
54 publish_all: publish_linux_debug publish_linux_release publish_windows_debug publish_windows_release 70 publish_all_linux: publish_linux_debug publish_linux_release
71 publish_all_windows: publish_windows_debug publish_windows_release
72 publish_all: publish_all_linux publish_all_windows
55 73
56 74
57 # download thirdparty-libraries 75 # download thirdparty-libraries
58 76
59 thirdparty/lib/glslang/linux_debug: 77 thirdparty/lib/glslang/linux_debug:
60 mkdir -p $@ 78 mkdir -p $@
61 wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Debug.zip 79 wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Debug.zip
62 unzip glslang-master-linux-Debug.zip 80 unzip glslang-master-linux-Debug.zip -d $@
63 thirdparty/lib/glslang/linux_release: 81 thirdparty/lib/glslang/linux_release:
64 mkdir -p $@ 82 mkdir -p $@
65 wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip 83 wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip
66 unzip glslang-master-linux-Release.zip 84 unzip glslang-master-linux-Release.zip -d $@
67 thirdparty/lib/glslang/windows_debug: 85 thirdparty/lib/glslang/windows_debug:
68 mkdir -p $@ 86 mkdir -p $@
69 wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Debug.zip 87 wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Debug.zip
70 unzip glslang-master-windows-x64-Debug.zip 88 unzip glslang-master-windows-x64-Debug.zip -d $@
71 thirdparty/lib/glslang/windows_release: 89 thirdparty/lib/glslang/windows_release:
72 mkdir -p $@ 90 mkdir -p $@
73 wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Release.zip 91 wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Release.zip
74 unzip glslang-master-windows-x64-Release.zip 92 unzip glslang-master-windows-x64-Release.zip -d $@
75 93
76 thirdparty/lib/spirv-tools/linux_debug: 94 thirdparty/lib/spirv-tools/linux_debug:
77 mkdir -p $@ 95 mkdir -p $@
78 wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-gcc-debug/continuous/1899/20221216-081758/install.tgz 96 wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-gcc-debug/continuous/1899/20221216-081758/install.tgz
79 tar -xf $@/install.tgz 97 tar --directory $@ -xf $@/install.tgz
80 thirdparty/lib/spirv-tools/linux_release: 98 thirdparty/lib/spirv-tools/linux_release:
81 mkdir -p $@ 99 mkdir -p $@
82 wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-gcc-release/continuous/1889/20221216-081754/install.tgz 100 wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-gcc-release/continuous/1889/20221216-081754/install.tgz
83 tar -xf $@/install.tgz 101 tar --directory $@ -xf $@/install.tgz
84 thirdparty/lib/spirv-tools/windows_debug: 102 thirdparty/lib/spirv-tools/windows_debug:
85 mkdir -p $@ 103 mkdir -p $@
86 wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/windows-msvc-2017-debug/continuous/1599/20221216-081803/install.zip 104 wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/windows-msvc-2017-debug/continuous/1599/20221216-081803/install.zip
87 unzip $@/install.zip 105 unzip $@/install.zip -d $@
88 thirdparty/lib/spirv-tools/windows_release: 106 thirdparty/lib/spirv-tools/windows_release:
89 mkdir -p $@ 107 mkdir -p $@
90 wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/windows-msvc-2017-release/continuous/1885/20221216-081805/install.zip 108 wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/windows-msvc-2017-release/continuous/1885/20221216-081805/install.zip
91 unzip $@/install.zip 109 unzip $@/install.zip -d $@
110
111 # set up cross compilation to compile for windows on linux
112 build/nim_windows/:
113 mkdir -p build/nim_windows
114 wget --directory-prefix=$@ https://nim-lang.org/download/nim-${WINE_NIM_VERSION}_x64.zip
115 unzip $@/nim-${WINE_NIM_VERSION}_x64.zip -d $@