Browse code

Make setup-toolchain-zig.sh compile the sources of SDL3 instead of downloading a binary release

Dario Rodriguez authored on 03/11/2024 18:26:04
Showing 1 changed files
... ...
@@ -29,7 +29,7 @@ if [ "m\$2" = "m--help" ] ; then
29 29
         exit 1
30 30
 fi
31 31
 . "$parentdir/toolchain-zig/env.sh" >/dev/null
32
-exec zig cc "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/w32api/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL2" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL" "\$@" -target x86_64-windows-gnu
32
+exec zig cc "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/w32api/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL2" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL" "-I$parentdir/toolchain-zig/sdl3-windows/SDL3/include" "-I$parentdir/toolchain-zig/sdl3-windows/SDL_ttf/include" "\$@" -target x86_64-windows-gnu
33 33
 EOF
34 34
 chmod 755 compile.sh
35 35
 cat > compile-cpp.sh  <<EOF
... ...
@@ -39,7 +39,7 @@ if [ "m$2" = "m--help" ] ; then
39 39
         exit 1
40 40
 fi
41 41
 . "$parentdir/toolchain-zig/env.sh" >/dev/null
42
-exec zig c++ "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/w32api/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL2" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL" "\$@" -target x86_64-windows-gnu
42
+exec zig c++ "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/w32api/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL2" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL" "-I$parentdir/toolchain-zig/sdl3-windows/SDL3/include" "-I$parentdir/toolchain-zig/sdl3-windows/SDL_ttf/include" "\$@" -target x86_64-windows-gnu
43 43
 EOF
44 44
 chmod 755 compile-cpp.sh
45 45
 
... ...
@@ -66,7 +66,7 @@ shift
66 66
 convert "\$icon" "\${icon/.png/-buildiconobject.ico}" && \
67 67
  echo "1 ICON \"\${icon/.png/-buildiconobject.ico}\"" > "\${icon/.png/-buildiconobject.rc}" && \
68 68
  x86_64-w64-mingw32-windres --preprocessor /usr/bin/cpp "\${icon/.png/-buildiconobject.rc}" "\${icon/.png/-buildiconobject.o}" && \
69
- zig build-exe --subsystem windows "\$@" \${icon/.png/-buildiconobject.o} -L$parentdir/toolchain-zig/windows-msys2-mingw/lib/ -L$parentdir/toolchain-zig/windows-msys2-mingw/lib/w32api -lSDL2 -lSDL2main -lSDL2_ttf -lfreetype -lgdi32 -lwinmm -lsetupapi -lmincore -lwindowsapp -limm32 -lversion -lgraphite2 -lpng -lbrotlidec -lbrotlicommon -lharfbuzz -lstdc++ -lbz2 -lz --name \$name -target x86_64-windows-gnu && rm \${name}.lib \${name}.pdb
69
+ zig build-exe --subsystem windows "\$@" \${icon/.png/-buildiconobject.o} -L$parentdir/toolchain-zig/windows-msys2-mingw/lib/ -L$parentdir/toolchain-zig/windows-msys2-mingw/lib/w32api $parentdir/toolchain-zig/sdl3-windows/libSDL3.dll.a $parentdir/toolchain-zig/sdl3-windows/libSDL3_ttf.dll.a $parentdir/toolchain-zig/sdl3-windows/libfreetype.a -lgdi32 -lwinmm -lsetupapi -lmincore -lwindowsapp -limm32 -lversion -lgraphite2 -lpng -lbrotlidec -lbrotlicommon -lharfbuzz -lstdc++ -lbz2 -lz --name \$name -target x86_64-windows-gnu && rm \${name}.lib \${name}.pdb
70 70
 res=\$?
71 71
 rm "\${icon/.png/-buildiconobject.ico}" "\${icon/.png/-buildiconobject.rc}" "\${icon/.png/-buildiconobject.o}"
72 72
 if [ \$tmpicon -eq 1 ] ; then rm "\$icon" ; fi
... ...
@@ -186,34 +186,46 @@ chmod a+x add-xz.sh add-zst.sh
186 186
 cd ..
187 187
 # Check for windres
188 188
 if ! which x86_64-w64-mingw32-windres >/dev/null 2>/dev/null; then
189
-        echo "Please, install windres manually using your distribution, i.e.:"                
190
-        echo "sudo apt-get install binutils-mingw-w64-x86-64"
189
+        echo "Please, install windres manually using your distribution, i.e.:" >> tooldchain-zig/error.log
190
+        echo "sudo apt-get install binutils-mingw-w64-x86-64" >> tooldchain-zig/error.log
191 191
 fi
192 192
 if ! which convert >/dev/null 2>/dev/null; then
193
-        echo "Please, install imagemagick manually using your distribution, i.e.:"                
194
-        echo "sudo apt-get install imagemagick"
193
+        echo "Please, install imagemagick manually using your distribution, i.e.:" >> tooldchain-zig/error.log
194
+        echo "sudo apt-get install imagemagick" >> tooldchain-zig/error.log
195 195
 fi
196 196
 # SDL3 for mingw
197
-mkdir -p sdl3-windows
198
-cat > sdl3-windows/setup.sh <<'SeTuPeOf'
197
+mkdir -p "$parentdir/toolchain-zig/sdl3-windows"
198
+cd "$parentdir/toolchain-zig/sdl3-windows"
199
+cat > setup.sh <<'SeTuPeOf'
199 200
 #!/bin/bash
200 201
 #SDL3
201
-if [ ! -e SDL3-devel-3.1.3-mingw.tar.xz ] ; then
202
-	wget https://github.com/libsdl-org/SDL/releases/download/preview-3.1.3/SDL3-devel-3.1.3-mingw.tar.xz
202
+if [ ! -e ../../toolchain-zig-dl/SDL3-preview-3.1.6.tgz ] ; then
203
+	wget https://github.com/libsdl-org/SDL/archive/refs/tags/preview-3.1.6.tar.gz -O ../../toolchain-zig-dl/SDL3-preview-3.1.6.tgz
203 204
 fi
204
-xz -d < SDL3-devel-3.1.3-mingw.tar.xz | tar -xvf -
205
-cp ./SDL3-3.1.3/x86_64-w64-mingw32/bin/SDL3.dll .
205
+tar -xvzf ../../toolchain-zig-dl/SDL3-preview-3.1.6.tgz
206
+mv SDL3-3.1.6 SDL3
207
+cd SDL3
208
+ln -s PARENTDIR/toolchain-zig/compile.sh x86_64-w64-mingw32-gcc
209
+ln -s PARENTDIR/toolchain-zig/compile-cpp.sh x86_64-w64-mingw32-g++
210
+cat >> src/winresrc.h <<'EOF'
211
+#define LANG_ENGLISH    0x09
212
+#define SUBLANG_ENGLISH_US      0x01
213
+EOF
214
+PATH=$(pwd):$PATH cmake -S . -B build -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=build-scripts/cmake-toolchain-mingw64-x86_64.cmake -DCMAKE_MAKE_PROGRAM=make -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ && cmake --build build
215
+cd ..
216
+cp ./SDL3/build/SDL3.dll .
217
+cp ./SDL3/build/libSDL3.dll.a .
206 218
 #SDL3_ttf
207
-rm -rf SDL_ttf
208
-if [ ! -e SDL_ttf.tgz ] ; then
209
-	git clone --recurse-submodules -j4 https://github.com/libsdl-org/SDL_ttf.git
210
-	tar -cf SDL_ttf.tgz SDL_ttf
219
+if [ -e ../../toolchain-zig-dl/SDL_ttf.tgz ] ; then
220
+	tar -xf ../../toolchain-zig-dl/SDL_ttf.tgz
211 221
 else
212
-	tar -xf SDL_ttf.tgz
222
+	git clone --recurse-submodules -j4 https://github.com/libsdl-org/SDL_ttf.git
223
+	tar -cf ../../toolchain-zig-dl/SDL_ttf.tgz SDL_ttf
213 224
 fi
214 225
 cd SDL_ttf
215
-ln -s ~/Programacion/sources/boxui/toolchain-zig/compile.sh x86_64-w64-mingw32-gcc
216
-ln -s ~/Programacion/sources/boxui/toolchain-zig/compile-cpp.sh x86_64-w64-mingw32-g++
226
+sed -i "s/SDL_REQUIRED_VERSION 3\.1\.5/SDL_REQUIRED_VERSION 3.1.6/g" CMakeLists.txt
227
+ln -s PARENTDIR/toolchain-zig/compile.sh x86_64-w64-mingw32-gcc
228
+ln -s PARENTDIR/toolchain-zig/compile-cpp.sh x86_64-w64-mingw32-g++
217 229
 mkdir -p build/external/freetype/include
218 230
 cat >> build/external/freetype/include/windows.h <<'EOF'
219 231
 #define	VS_FF_DEBUG	0x01L
... ...
@@ -259,18 +271,22 @@ index f96d5087..b2028178 100644
259 271
  }
260 272
 EOF
261 273
 # revert patch https://discourse.libsdl.org/t/sdl-ttf-use-sdl-stepbackutf8/54854
262
-( patch -R -p1 < ./freetype_Use_SDL_StepBackUTF8.patch )
274
+#( patch -R -p1 < ./freetype_Use_SDL_StepBackUTF8.patch )
263 275
 sed -i "s/vendored_default FALSE/vendored_default TRUE/g" CMakeLists.txt
264
-PATH=$(pwd):$PATH cmake -S . -B build -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=build-scripts/cmake-toolchain-mingw64-x86_64.cmake -DCMAKE_MAKE_PROGRAM=make -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DSDL3_DIR=/home/bit/Programacion/sources/boxui/sdl3-windows/SDL3-3.1.3/x86_64-w64-mingw32/lib/cmake/SDL3/ && cmake --build build
276
+PATH=$(pwd):$PATH cmake -S . -B build -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=build-scripts/cmake-toolchain-mingw64-x86_64.cmake -DCMAKE_MAKE_PROGRAM=make -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DSDL3_DIR=PARENTDIR/toolchain-zig/sdl3-windows/SDL3/build && cmake --build build
265 277
 cd ..
266 278
 cp SDL_ttf/build/SDL3_ttf.dll .
267 279
 cp SDL_ttf/build/libSDL3_ttf.dll.a .
268 280
 cp SDL_ttf/build/external/freetype/libfreetype.a .
269 281
 SeTuPeOf
270
-cd sdl3-windows
282
+sed -i "s#PARENTDIR#$parentdir#g" setup.sh
271 283
 chmod a+x setup.sh
272 284
 ./setup.sh
273 285
 cd ..
286
+# Show errors if tehre is an error.log file
287
+if [ -e toolchain-zig/error.log ] ; then
288
+	cat toolchain-zig/error.log
289
+fi
274 290
 # Success message
275 291
 echo ""
276 292
 echo "Installation complete."
Browse code

Update the zig toolchain to crosscompile to windows for SDL3 and SDL3_ttf

Dario Rodriguez authored on 25/10/2024 15:56:57
Showing 1 changed files
... ...
@@ -24,14 +24,25 @@ chmod 755 env.sh
24 24
 # Convenience scripts
25 25
 cat > compile.sh  <<EOF
26 26
 #!/bin/bash
27
-if [ ! -e "\$1" ] || [ "m\$2" = "m" ] ; then
27
+if [ "m\$2" = "m--help" ] ; then
28 28
         echo "Syntax: \$0 source.c -c -o result.o [flags]"
29 29
         exit 1
30 30
 fi
31 31
 . "$parentdir/toolchain-zig/env.sh" >/dev/null
32
-exec zig cc "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL2" "\$@" -target x86_64-windows-gnu
32
+exec zig cc "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/w32api/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL2" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL" "\$@" -target x86_64-windows-gnu
33 33
 EOF
34 34
 chmod 755 compile.sh
35
+cat > compile-cpp.sh  <<EOF
36
+#!/bin/bash
37
+if [ "m$2" = "m--help" ] ; then
38
+        echo "Syntax: $0 source.cpp -c -o result.o [flags]"
39
+        exit 1
40
+fi
41
+. "$parentdir/toolchain-zig/env.sh" >/dev/null
42
+exec zig c++ "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/w32api/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL2" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL" "\$@" -target x86_64-windows-gnu
43
+EOF
44
+chmod 755 compile-cpp.sh
45
+
35 46
 cat > link.sh  <<EOF
36 47
 #!/bin/bash
37 48
 tmpicon=0
... ...
@@ -132,8 +143,13 @@ https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-wineditline-2.205-3-any.
132 143
 https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-xz-5.2.9-1-any.pkg.tar.zst
133 144
 https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-zlib-1.2.13-2-any.pkg.tar.zst
134 145
 https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-zstd-1.5.2-2-any.pkg.tar.zst
146
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-winpthreads-git-12.0.0.r351.gcdf6b16b8-1-any.pkg.tar.zst
147
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-cmake-3.30.5-1-any.pkg.tar.zst
148
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-ninja-1.12.1-1-any.pkg.tar.zst
149
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-pkg-config-0.29.2-6-any.pkg.tar.zst
135 150
 https://mirror.msys2.org/msys/x86_64/msys2-w32api-headers-10.0.0.r16.g49a56d453-1-x86_64.pkg.tar.zst
136 151
 https://mirror.msys2.org/msys/x86_64/msys2-w32api-runtime-10.0.0.r16.g49a56d453-1-x86_64.pkg.tar.zst
152
+https://mirror.msys2.org/msys/x86_64/perl-5.38.2-2-x86_64.pkg.tar.zst
137 153
 EOF
138 154
 for i in  $(cat deps.txt) ; do
139 155
         if [ ! -e ../toolchain-zig-dl/$(basename $i) ] ; then
... ...
@@ -167,6 +183,7 @@ i="$1"
167 183
 EOF
168 184
 echo " (cd $l && tar -cf - . | (cd $parentdir/toolchain-zig/windows-msys2-mingw && tar -xvf - ) ) ; done ) ; rm -rf t " >> add-xz.sh
169 185
 chmod a+x add-xz.sh add-zst.sh
186
+cd ..
170 187
 # Check for windres
171 188
 if ! which x86_64-w64-mingw32-windres >/dev/null 2>/dev/null; then
172 189
         echo "Please, install windres manually using your distribution, i.e.:"                
... ...
@@ -176,7 +193,85 @@ if ! which convert >/dev/null 2>/dev/null; then
176 193
         echo "Please, install imagemagick manually using your distribution, i.e.:"                
177 194
         echo "sudo apt-get install imagemagick"
178 195
 fi
179
-
196
+# SDL3 for mingw
197
+mkdir -p sdl3-windows
198
+cat > sdl3-windows/setup.sh <<'SeTuPeOf'
199
+#!/bin/bash
200
+#SDL3
201
+if [ ! -e SDL3-devel-3.1.3-mingw.tar.xz ] ; then
202
+	wget https://github.com/libsdl-org/SDL/releases/download/preview-3.1.3/SDL3-devel-3.1.3-mingw.tar.xz
203
+fi
204
+xz -d < SDL3-devel-3.1.3-mingw.tar.xz | tar -xvf -
205
+cp ./SDL3-3.1.3/x86_64-w64-mingw32/bin/SDL3.dll .
206
+#SDL3_ttf
207
+rm -rf SDL_ttf
208
+if [ ! -e SDL_ttf.tgz ] ; then
209
+	git clone --recurse-submodules -j4 https://github.com/libsdl-org/SDL_ttf.git
210
+	tar -cf SDL_ttf.tgz SDL_ttf
211
+else
212
+	tar -xf SDL_ttf.tgz
213
+fi
214
+cd SDL_ttf
215
+ln -s ~/Programacion/sources/boxui/toolchain-zig/compile.sh x86_64-w64-mingw32-gcc
216
+ln -s ~/Programacion/sources/boxui/toolchain-zig/compile-cpp.sh x86_64-w64-mingw32-g++
217
+mkdir -p build/external/freetype/include
218
+cat >> build/external/freetype/include/windows.h <<'EOF'
219
+#define	VS_FF_DEBUG	0x01L
220
+#define	VFT_DLL	0x00000002L
221
+#define	VFT_STATIC_LIB	0x00000007L
222
+#define	VS_FF_DEBUG	0x01L
223
+#define	VS_FFI_FILEFLAGSMASK	0x0000003fL
224
+EOF
225
+cat >> build/external/freetype/include/winresrc.h <<'EOF'
226
+#define LANG_ENGLISH    0x09
227
+#define SUBLANG_ENGLISH_US      0x01
228
+EOF
229
+cat >> freetype_Use_SDL_StepBackUTF8.patch <<'EOF'
230
+diff --git a/examples/editbox.c b/examples/editbox.c
231
+index f96d5087..b2028178 100644
232
+--- a/examples/editbox.c
233
+@@ -633,19 +633,14 @@ void EditBox_Backspace(EditBox *edit)
234
+         return;
235
+     }
236
+ 
237
+-    const char *start = &edit->text->text[edit->cursor];
238
+-    const char *current = start;
239
+-    /* Step back over the previous UTF-8 character */
240
+-    do {
241
+-        if (current == edit->text->text) {
242
+-            break;
243
+-        }
244
+-        --current;
245
+-    } while ((*current & 0xC0) == 0x80);
246
+-
247
+-    int length = (int)(start - current);
248
+-    TTF_DeleteTextString(edit->text, edit->cursor - length, length);
249
+-    edit->cursor -= length;
250
++    if (edit->cursor > 0) {
251
++        const char *start = &edit->text->text[edit->cursor];
252
++        const char *next = start;
253
++        SDL_StepBackUTF8(edit->text->text, &next);
254
++        int length = (int)(uintptr_t)(start - next);
255
++        TTF_DeleteTextString(edit->text, edit->cursor - length, length);
256
++        edit->cursor -= length;
257
++    }
258
+ }
259
+EOF
260
+# revert patch https://discourse.libsdl.org/t/sdl-ttf-use-sdl-stepbackutf8/54854
261
+( patch -R -p1 < ./freetype_Use_SDL_StepBackUTF8.patch )
262
+sed -i "s/vendored_default FALSE/vendored_default TRUE/g" CMakeLists.txt
263
+PATH=$(pwd):$PATH cmake -S . -B build -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=build-scripts/cmake-toolchain-mingw64-x86_64.cmake -DCMAKE_MAKE_PROGRAM=make -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DSDL3_DIR=/home/bit/Programacion/sources/boxui/sdl3-windows/SDL3-3.1.3/x86_64-w64-mingw32/lib/cmake/SDL3/ && cmake --build build
264
+cd ..
265
+cp SDL_ttf/build/SDL3_ttf.dll .
266
+cp SDL_ttf/build/libSDL3_ttf.dll.a .
267
+cp SDL_ttf/build/external/freetype/libfreetype.a .
268
+SeTuPeOf
269
+cd sdl3-windows
270
+chmod a+x setup.sh
271
+./setup.sh
272
+cd ..
273
+# Success message
180 274
 echo ""
181 275
 echo "Installation complete."
182 276
 echo "To use the zig toolchain, first include env.sh with \". toolchain-zig/env.sh\""
Browse code

Simplify compiling for windows in the Makefile example (using toolchain-zig/compile.sh and toolchain-zig/link.sh ).

Dario Rodriguez authored on 02/07/2023 14:41:21
Showing 1 changed files
... ...
@@ -21,6 +21,47 @@ echo "Reminder: this script has to be used with source (.) instead of exec"
21 21
 EOF
22 22
 echo "export PATH=\$PATH:$parentdir/toolchain-zig/zig-$zigversion" >> env.sh
23 23
 chmod 755 env.sh
24
+# Convenience scripts
25
+cat > compile.sh  <<EOF
26
+#!/bin/bash
27
+if [ ! -e "\$1" ] || [ "m\$2" = "m" ] ; then
28
+        echo "Syntax: \$0 source.c -c -o result.o [flags]"
29
+        exit 1
30
+fi
31
+. "$parentdir/toolchain-zig/env.sh" >/dev/null
32
+exec zig cc "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/" "-I$parentdir/toolchain-zig/windows-msys2-mingw/include/SDL2" "\$@" -target x86_64-windows-gnu
33
+EOF
34
+chmod 755 compile.sh
35
+cat > link.sh  <<EOF
36
+#!/bin/bash
37
+tmpicon=0
38
+if [ "m\$1" = "m-icon" ] ; then
39
+        shift
40
+        icon="\$1"
41
+        shift
42
+else
43
+        tmpicon=1
44
+        icon=\$(mktemp -p . --suffix=.png)
45
+        convert -size 256x256 xc:white \$icon
46
+fi
47
+if [ "\${icon/.png/}" = "\$icon" ] || [ "\${1/.exe/}" = "\$1" ] || [ ! -e "\$2" ] ; then
48
+        echo "Syntax: \$0 [-icon myicon.png] result.exe source1.o [source2.o [...]"
49
+        if [ \$tmpicon -eq 1 ] ; then rm "\$icon" ; fi
50
+        exit 1
51
+fi
52
+. "$parentdir/toolchain-zig/env.sh" >/dev/null
53
+name="\${1/.exe/}"
54
+shift
55
+convert "\$icon" "\${icon/.png/-buildiconobject.ico}" && \
56
+ echo "1 ICON \"\${icon/.png/-buildiconobject.ico}\"" > "\${icon/.png/-buildiconobject.rc}" && \
57
+ x86_64-w64-mingw32-windres --preprocessor /usr/bin/cpp "\${icon/.png/-buildiconobject.rc}" "\${icon/.png/-buildiconobject.o}" && \
58
+ zig build-exe --subsystem windows "\$@" \${icon/.png/-buildiconobject.o} -L$parentdir/toolchain-zig/windows-msys2-mingw/lib/ -L$parentdir/toolchain-zig/windows-msys2-mingw/lib/w32api -lSDL2 -lSDL2main -lSDL2_ttf -lfreetype -lgdi32 -lwinmm -lsetupapi -lmincore -lwindowsapp -limm32 -lversion -lgraphite2 -lpng -lbrotlidec -lbrotlicommon -lharfbuzz -lstdc++ -lbz2 -lz --name \$name -target x86_64-windows-gnu && rm \${name}.lib \${name}.pdb
59
+res=\$?
60
+rm "\${icon/.png/-buildiconobject.ico}" "\${icon/.png/-buildiconobject.rc}" "\${icon/.png/-buildiconobject.o}"
61
+if [ \$tmpicon -eq 1 ] ; then rm "\$icon" ; fi
62
+exit \$res
63
+EOF
64
+chmod 755 link.sh
24 65
 # msys2 install
25 66
 mkdir -p windows-msys2-mingw
26 67
 cat > deps.txt <<'EOF'
... ...
@@ -139,3 +180,4 @@ fi
139 180
 echo ""
140 181
 echo "Installation complete."
141 182
 echo "To use the zig toolchain, first include env.sh with \". toolchain-zig/env.sh\""
183
+echo "( alternative: use toolchain-zig/compile.sh and toolchain-zig/link.sh )"
Browse code

Change toolchain directories and setup-scripts names.

Dario Rodriguez authored on 01/07/2023 15:15:29
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,141 @@
1
+#!/bin/bash
2
+zigbuild=zig-linux-x86_64-0.11.0-dev.514+4be1bb4aa.tar.xz
3
+zigversion=$(echo $zigbuild | cut -d '-' -f 4)
4
+if [ -e toolchain-zig ] ; then
5
+        echo "ERROR: A toolchain-zig directory already exists, aborting install"
6
+        exit 1
7
+fi
8
+parentdir=$(pwd)
9
+mkdir -p toolchain-zig toolchain-zig-dl
10
+cd toolchain-zig
11
+
12
+# Zig install
13
+if [ ! -e ../toolchain-zig-dl/$zigbuild ] ; then
14
+        (cd ../toolchain-zig-dl && wget https://ziglang.org/builds/$zigbuild)
15
+fi
16
+xz -dc <../toolchain-zig-dl/$zigbuild | tar -xvf -
17
+ln -s ${zigbuild/.tar.xz/} zig-$zigversion
18
+cat > env.sh  <<'EOF'
19
+#!/bin/bash
20
+echo "Reminder: this script has to be used with source (.) instead of exec"
21
+EOF
22
+echo "export PATH=\$PATH:$parentdir/toolchain-zig/zig-$zigversion" >> env.sh
23
+chmod 755 env.sh
24
+# msys2 install
25
+mkdir -p windows-msys2-mingw
26
+cat > deps.txt <<'EOF'
27
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-aom-3.5.0-1-any.pkg.tar.zst
28
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-brotli-1.0.9-5-any.pkg.tar.zst
29
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-bzip2-1.0.8-2-any.pkg.tar.zst
30
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-ca-certificates-20211016-3-any.pkg.tar.zst
31
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-dav1d-1.0.0-1-any.pkg.tar.zst
32
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-expat-2.5.0-1-any.pkg.tar.zst
33
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-flac-1.4.2-1-any.pkg.tar.zst
34
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-fluidsynth-2.3.0-1-any.pkg.tar.zst
35
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-freetype-2.12.1-1-any.pkg.tar.zst
36
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-gcc-libs-12.2.0-6-any.pkg.tar.zst
37
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-gettext-0.21-3-any.pkg.tar.zst
38
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-giflib-5.2.1-3-any.pkg.tar.zst
39
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-glib2-2.74.3-1-any.pkg.tar.zst
40
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-gmp-6.2.1-3-any.pkg.tar.zst
41
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-graphite2-1.3.14-2-any.pkg.tar.zst
42
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-harfbuzz-5.3.1-2-any.pkg.tar.zst
43
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-highway-1.0.2-1-any.pkg.tar.zst
44
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-imath-3.1.6-1-any.pkg.tar.zst
45
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-jbigkit-2.1-4-any.pkg.tar.xz
46
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-lcms2-2.14-1-any.pkg.tar.zst
47
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-lerc-4.0.0-1-any.pkg.tar.zst
48
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libavif-0.11.1-3-any.pkg.tar.zst
49
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libdeflate-1.15-1-any.pkg.tar.zst
50
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libffi-3.4.4-1-any.pkg.tar.zst
51
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libiconv-1.17-1-any.pkg.tar.zst
52
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libjpeg-turbo-2.1.4-1-any.pkg.tar.zst
53
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libjxl-0.7.0-2-any.pkg.tar.zst
54
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libmodplug-0.8.9.0-4-any.pkg.tar.zst
55
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libogg-1.3.5-1-any.pkg.tar.zst
56
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libpng-1.6.39-1-any.pkg.tar.zst
57
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libsndfile-1.1.0-3-any.pkg.tar.zst
58
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libsystre-1.0.1-4-any.pkg.tar.xz
59
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libtasn1-4.19.0-1-any.pkg.tar.zst
60
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libtiff-4.4.0-6-any.pkg.tar.zst
61
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libtre-git-r128.6fb7206-2-any.pkg.tar.xz
62
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libvorbis-1.3.7-1-any.pkg.tar.zst
63
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libwebp-1.2.4-2-any.pkg.tar.zst
64
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libwinpthread-git-10.0.0.r157.gd295924f0-1-any.pkg.tar.zst
65
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-libyuv-1844.r2374.f9fda6e7-1-any.pkg.tar.zst
66
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpc-1.2.1-1-any.pkg.tar.zst
67
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpdecimal-2.5.1-1-any.pkg.tar.zst
68
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpfr-4.1.0.p13-1-any.pkg.tar.zst
69
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpg123-1.31.1-1-any.pkg.tar.zst
70
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-ncurses-6.3-6-any.pkg.tar.zst
71
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-openexr-3.1.5-2-any.pkg.tar.zst
72
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-openssl-1.1.1.s-1-any.pkg.tar.zst
73
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-opus-1.3.1-5-any.pkg.tar.zst
74
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-opusfile-0.12-2-any.pkg.tar.zst
75
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-p11-kit-0.24.1-3-any.pkg.tar.zst
76
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-pcre2-10.40-1-any.pkg.tar.zst
77
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-portaudio-1~19.7.0-4-any.pkg.tar.zst
78
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-python-3.10.8-2-any.pkg.tar.zst
79
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-rav1e-0.6.1-1-any.pkg.tar.zst
80
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-SDL2-2.26.0-1-any.pkg.tar.zst
81
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-SDL2_image-2.6.2-3-any.pkg.tar.zst
82
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-SDL2_mixer-2.6.2-1-any.pkg.tar.zst
83
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-SDL2_ttf-2.20.1-1-any.pkg.tar.zst
84
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-sqlite3-3.40.0-1-any.pkg.tar.zst
85
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-svt-av1-1.3.0-1-any.pkg.tar.zst
86
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-tcl-8.6.12-1-any.pkg.tar.zst
87
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-tzdata-2022g-1-any.pkg.tar.zst
88
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-vulkan-headers-1.3.236-1-any.pkg.tar.zst
89
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-vulkan-loader-1.3.236-1-any.pkg.tar.zst
90
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-wineditline-2.205-3-any.pkg.tar.xz
91
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-xz-5.2.9-1-any.pkg.tar.zst
92
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-zlib-1.2.13-2-any.pkg.tar.zst
93
+https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-zstd-1.5.2-2-any.pkg.tar.zst
94
+https://mirror.msys2.org/msys/x86_64/msys2-w32api-headers-10.0.0.r16.g49a56d453-1-x86_64.pkg.tar.zst
95
+https://mirror.msys2.org/msys/x86_64/msys2-w32api-runtime-10.0.0.r16.g49a56d453-1-x86_64.pkg.tar.zst
96
+EOF
97
+for i in  $(cat deps.txt) ; do
98
+        if [ ! -e ../toolchain-zig-dl/$(basename $i) ] ; then
99
+                (cd ../toolchain-zig-dl && wget $i )
100
+        fi
101
+done
102
+for i in $(cd ../toolchain-zig-dl && find . -maxdepth 1 -name "*.zst") ; do 
103
+         ( mkdir -p t ; cd t ; cat ../../toolchain-zig-dl/$i | zstd -dc | tar -xvf - ; find . -maxdepth 1 -type d  -print | grep -v "^\.\$" | while read l ; do
104
+          (cd $l && tar -cf - . | (cd $parentdir/toolchain-zig/windows-msys2-mingw && tar -xvf - ) ) ; done ) ; rm -rf t ; done
105
+for i in $(cd ../toolchain-zig-dl && find . -maxdepth 1 -name "*.xz") ; do 
106
+         ( mkdir -p t ; cd t ; cat ../../toolchain-zig-dl/$i | xz -dc | tar -xvf - ; find . -maxdepth 1 -type d  -print | grep -v "^\.\$" | while read l ; do
107
+         (cd $l && tar -cf - . | (cd $parentdir/toolchain-zig/windows-msys2-mingw && tar -xvf - ) ) ; done ) ; rm -rf t ; done
108
+cat > add-zst.sh <<'EOF'
109
+#!/bin/bash
110
+if [ "m$1" == "m" ] || [ "m$1" == "m--help" ] || [ ! -f "$1" ] ; then
111
+        echo "Syntax: $0 filename.pkg.tar.zst"
112
+        exit 0
113
+fi
114
+i="$1"
115
+( mkdir -p t ; cd t ; cat ../$i | zstd -dc | tar -xvf - ; find . -maxdepth 1 -type d  -print | grep -v "^\.\$" | while read l ; do
116
+EOF
117
+echo " (cd \$l && tar -cf - . | (cd $parentdir/toolchain-zig/windows-msys2-mingw && tar -xvf - ) ) ; done ) ; rm -rf t " >> add-zst.sh
118
+cat > add-xz.sh <<'EOF'
119
+#!/bin/bash
120
+if [ "m$1" == "m" ] || [ "m$1" == "m--help" ] || [ ! -f "$1" ] ; then
121
+        echo "Syntax: $0 filename.pkg.tar.xz"
122
+        exit 0
123
+fi
124
+i="$1"
125
+( mkdir -p t ; cd t ; cat ../$i | xz -dc | tar -xvf - ; find . -maxdepth 1 -type d  -print | grep -v "^\.\$" | while read l ; do
126
+EOF
127
+echo " (cd $l && tar -cf - . | (cd $parentdir/toolchain-zig/windows-msys2-mingw && tar -xvf - ) ) ; done ) ; rm -rf t " >> add-xz.sh
128
+chmod a+x add-xz.sh add-zst.sh
129
+# Check for windres
130
+if ! which x86_64-w64-mingw32-windres >/dev/null 2>/dev/null; then
131
+        echo "Please, install windres manually using your distribution, i.e.:"                
132
+        echo "sudo apt-get install binutils-mingw-w64-x86-64"
133
+fi
134
+if ! which convert >/dev/null 2>/dev/null; then
135
+        echo "Please, install imagemagick manually using your distribution, i.e.:"                
136
+        echo "sudo apt-get install imagemagick"
137
+fi
138
+
139
+echo ""
140
+echo "Installation complete."
141
+echo "To use the zig toolchain, first include env.sh with \". toolchain-zig/env.sh\""