|
1 | 1 | #!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Build the DART Wails app and stamp it with the correct tag/release number. |
| 4 | +# |
| 5 | +# ---------------------------------------------------------------------------- |
2 | 6 |
|
3 | | -# Note: CGO_ENABLED is set to zero in this script because we are |
4 | | -# not using any CGO dependencies. If CGO happens to be enabled in |
5 | | -# the greater environment, we want to override it here to prevent |
6 | | -# cross compilation failures. For details on why we do this, see |
7 | | -# https://stackoverflow.com/questions/77293369/dynamic-linked-go-program-when-cross-compile |
8 | | - |
9 | | -# While DART does use SQLite, we're using the pure Go driver from |
10 | | -# https://pkg.go.dev/modernc.org/sqlite. So, no C interop required. |
11 | | - |
| 7 | +# Make sure script is called from the top-level directory |
12 | 8 | if [ -z $(ls scripts/build_dart.sh 2> /dev/null) ]; then |
13 | 9 | echo "Run this script from the project root directory" |
14 | 10 | exit |
15 | 11 | fi |
16 | 12 |
|
| 13 | +# Gather variables from Git and the local OS so we can tag |
| 14 | +# this release. These vars show up in the Release number |
| 15 | +# displayed on DART's About screen. They also appear if the |
| 16 | +# user runs `DART -version`. |
17 | 17 | COMMIT=$(git rev-parse --short HEAD) |
18 | | -#TAG=$(git describe --tags 2> /dev/null) |
| 18 | +TAG=$(git describe --tags 2> /dev/null) |
| 19 | +if [ -z "$TAG" ]; then |
| 20 | + TAG="undefined" |
| 21 | +fi |
19 | 22 | DATE=$(date +%Y-%m-%d) |
20 | 23 | OS=$(uname -s) |
21 | 24 | ARCH=$(uname -m) |
22 | | - |
23 | 25 | BUILD_TAGS='-tags release' |
24 | 26 |
|
| 27 | + |
| 28 | +# Special handling for the special child of the OS world. |
25 | 29 | # uname returns MINGW64_NT-10.0 on Windows 10 Cygwin |
26 | 30 | # and MSYS_NT-10.0 on Windows 10 cmd. |
27 | 31 | if [[ "$OS" == *"_NT-"* ]]; then |
28 | 32 | OS="Windows $(uname -m)" |
29 | 33 | BUILD_TAGS='-tags="release windows"' |
30 | 34 | fi |
31 | 35 |
|
32 | | -#TAG="${TAG:=Alpha-01}" |
33 | | - |
34 | | -VERSION="DART Alpha-01 for Darwin amd64 (Build $COMMIT $DATE)" |
35 | | -echo "Building MacOS amd64 version in ./dist/mac-amd64/dart3" |
36 | | -mkdir -p dist/mac-amd64 |
37 | | -#mkdir -p dist/mac-amd64/dart3.app/Contents/MacOS |
38 | | -#mkdir -p dist/mac-amd64/dart3.app/Contents/Resources |
39 | | -#cp server/build_support/macos/Info.plist dist/mac-amd64/dart3.app/Contents/Info.plist |
40 | | -#cp server/build_support/macos/icons/icon.icns dist/mac-amd64/dart3.app/Contents/Resources/icon.icns |
41 | | -GOOS=darwin \ |
42 | | - GOARCH=amd64 \ |
43 | | - CGO_ENABLED=0 \ |
44 | | - go build -o dist/mac-amd64/dart3 \ |
45 | | - -ldflags "-X 'main.Version=$VERSION'" \ |
46 | | - $BUILD_TAGS dart/main.go |
47 | | - |
48 | | -VERSION="DART Alpha-01 for Darwin arm64 (Build $COMMIT $DATE)" |
49 | | -echo "Building MacOS arm-64 (M-chip) version in ./dist/mac-arm64/dart3" |
50 | | -mkdir -p dist/mac-arm64 |
51 | | -#mkdir -p dist/mac-arm64/dart3.app/Contents/MacOS |
52 | | -#mkdir -p dist/mac-arm64/dart3.app/Contents/Resources |
53 | | -#cp server/build_support/macos/Info.plist dist/mac-arm64/dart3.app/Contents/Info.plist |
54 | | -#cp server/build_support/macos/icons/* dist/mac-arm64/dart3.app/Contents/Resources/ |
55 | | -GOOS=darwin \ |
56 | | - GOARCH=arm64 \ |
57 | | - CGO_ENABLED=0 \ |
58 | | - go build -o dist/mac-arm64/dart3 \ |
59 | | - -ldflags "-X 'main.Version=$VERSION'" \ |
60 | | - $BUILD_TAGS dart/main.go |
61 | | - |
| 36 | +# Create the full version string. |
| 37 | +VERSION="DART $TAG for $OS $ARCH (Build $COMMIT $DATE)" |
62 | 38 |
|
63 | | -# Note: When running `./scripts/run tests`, post_build_test.go uses its own special build command for Windows. |
64 | | -VERSION="DART Alpha-01 for Windows amd64 (Build $COMMIT $DATE)" |
65 | | -echo "Building Windows amd64 version in ./dist/windows-amd64/dart3" |
66 | | -mkdir -p dist/windows-amd64 |
67 | | -GOOS=windows \ |
68 | | - GOARCH=amd64 \ |
69 | | - CGO_ENABLED=0 \ |
70 | | - go build -o dist/windows-amd64/dart3.exe \ |
71 | | - -ldflags "-X 'main.Version=$VERSION' -H=windowsgui" \ |
72 | | - $BUILD_TAGS dart/main.go |
73 | | - |
74 | | -VERSION="DART Alpha-01 for Windows arm64 (Build $COMMIT $DATE)" |
75 | | -echo "Building Windows arm64 version in ./dist/windows-arm64/dart3" |
76 | | -mkdir -p dist/windows-arm64 |
77 | | -GOOS=windows \ |
78 | | - GOARCH=arm64 \ |
79 | | - CGO_ENABLED=0 \ |
80 | | - go build -o dist/windows-arm64/dart3.exe \ |
81 | | - -ldflags "-X 'main.Version=$VERSION' -H=windowsgui" \ |
82 | | - $BUILD_TAGS dart/main.go |
83 | | - |
84 | | - |
85 | | -VERSION="DART Alpha-01 for Linux amd64 (Build $COMMIT $DATE)" |
86 | | -echo "Building Linux amd64 version in ./dist/linux-amd64/dart3" |
87 | | -mkdir -p dist/linux-amd64 |
88 | | -GOOS=linux \ |
89 | | - GOARCH=amd64 \ |
90 | | - CGO_ENABLED=0 \ |
91 | | - go build -o dist/linux-amd64/dart3 \ |
92 | | - -ldflags "-X 'main.Version=$VERSION'" \ |
93 | | - $BUILD_TAGS dart/main.go |
94 | | - |
95 | | - |
96 | | -VERSION="DART Alpha-01 for Linux arm64 (Build $COMMIT $DATE)" |
97 | | -echo "Building Linux arm64 version in ./dist/linux-arm64/dart3" |
98 | | -mkdir -p dist/linux-arm64 |
99 | | -GOOS=linux \ |
100 | | - GOARCH=arm64 \ |
101 | | - CGO_ENABLED=0 \ |
102 | | - go build -o dist/linux-arm64/dart3 \ |
103 | | - -ldflags "-X 'main.Version=$VERSION'" \ |
104 | | - $BUILD_TAGS dart/main.go |
105 | | - |
106 | | - |
107 | | -echo "Version info from latest build:" |
108 | | -if [[ "$OS" == "Darwin" ]]; then |
109 | | - if [[ "$ARCH" == "x86_64" ]]; then |
110 | | - dist/mac-amd64/dart3 --version |
111 | | - else |
112 | | - dist/mac-arm64/dart3 --version |
113 | | - fi |
114 | | -elif [[ "$OS" == "Linux" ]]; then |
115 | | - if [[ "$ARCH" == "x86_64" ]]; then |
116 | | - dist/linux-amd64/dart3 --version |
117 | | - else |
118 | | - dist/linux-arm64/dart3 --version |
119 | | - fi |
120 | | -else |
121 | | - if [[ "$ARCH" == "x86_64" ]]; then |
122 | | - dist/windows-amd64/dart3.exe --version |
123 | | - else |
124 | | - dist/windows-arm64/dart3.exe --version |
125 | | - fi |
126 | | -fi |
| 39 | +# Now run wails build with the proper tags and version |
| 40 | +# number. |
| 41 | +wails build $BUILD_TAGS -ldflags "-X 'main.Version=$VERSION'" |
0 commit comments