Skip to content

Commit 1e41cd2

Browse files
committed
ci skip: update create-app to allow custom environment file
1 parent 786fd81 commit 1e41cd2

File tree

7 files changed

+291
-162
lines changed

7 files changed

+291
-162
lines changed

tools/create-app-linux.sh

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ fi
9595

9696
# Create custom AppRun script
9797
echo "Creating custom launcher..."
98-
if [[ -n "$SCORE_BASENAME" ]]; then
99-
# With score
98+
10099
cat > AppRun << APPRUN_EOF
101100
#!/bin/sh
102101
@@ -108,6 +107,15 @@ export SCORE_CUSTOM_APP_APPLICATION_VERSION="$APP_VERSION"
108107
export QML2_IMPORT_PATH="\${APPDIR}/usr/bin/qml/"
109108
export LD_LIBRARY_PATH="\${APPIMAGE_LIBRARY_PATH}:\${APPDIR}/usr/lib:\${LD_LIBRARY_PATH}"
110109
"\${APPDIR}/usr/bin/linuxcheck" "\${APPDIR}/usr/bin/app-bin"
110+
APPRUN_EOF
111+
112+
if [[ -n "$APP_ENVIRONMENT" ]]; then
113+
cat "$APP_ENVIRONMENT" >> AppRun
114+
fi
115+
116+
if [[ -n "$SCORE_BASENAME" ]]; then
117+
# With score
118+
cat >> AppRun << APPRUN_EOF
111119
112120
# Launch with custom UI and score
113121
exec "\${APPDIR}/usr/bin/app-bin" \
@@ -118,17 +126,7 @@ exec "\${APPDIR}/usr/bin/app-bin" \
118126
APPRUN_EOF
119127
else
120128
# Without custom score
121-
cat > AppRun << APPRUN_EOF
122-
#!/bin/sh
123-
124-
export SCORE_CUSTOM_APP_ORGANIZATION_NAME="$APP_ORGANIZATION"
125-
export SCORE_CUSTOM_APP_ORGANIZATION_DOMAIN="$APP_DOMAIN"
126-
export SCORE_CUSTOM_APP_APPLICATION_NAME="$APP_NAME"
127-
export SCORE_CUSTOM_APP_APPLICATION_VERSION="$APP_VERSION"
128-
129-
export QML2_IMPORT_PATH="\${APPDIR}/usr/bin/qml/"
130-
export LD_LIBRARY_PATH="\${APPIMAGE_LIBRARY_PATH}:\${APPDIR}/usr/lib:\${LD_LIBRARY_PATH}"
131-
"\${APPDIR}/usr/bin/linuxcheck" "\${APPDIR}/usr/bin/app-bin"
129+
cat >> AppRun << APPRUN_EOF
132130
133131
# Launch with custom UI
134132
exec "\${APPDIR}/usr/bin/app-bin" \

tools/create-app-macos.sh

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,8 @@ fi
187187

188188
# Create launcher script
189189
echo "Creating custom launcher..."
190-
if [[ -n "$SCORE_BASENAME" ]]; then
191-
# With score
192-
cat > "$BUNDLE_MACOS/$APP_NAME" << LAUNCHER_EOF
190+
191+
cat > "$BUNDLE_MACOS/$APP_NAME" << LAUNCHER_EOF
193192
#!/bin/bash
194193
195194
export SCORE_CUSTOM_APP_ORGANIZATION_NAME="$APP_ORGANIZATION"
@@ -200,6 +199,16 @@ export SCORE_CUSTOM_APP_APPLICATION_VERSION="$APP_VERSION"
200199
SCRIPT_DIR="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
201200
RESOURCES_DIR="\$(cd "\$SCRIPT_DIR/../Resources" && pwd)"
202201
export QML2_IMPORT_PATH="\${RESOURCES_DIR}/qml/"
202+
203+
LAUNCHER_EOF
204+
205+
if [[ -n "$APP_ENVIRONMENT" ]]; then
206+
cat "$APP_ENVIRONMENT" >> "$BUNDLE_MACOS/$APP_NAME"
207+
fi
208+
209+
if [[ -n "$SCORE_BASENAME" ]]; then
210+
# With score
211+
cat >> "$BUNDLE_MACOS/$APP_NAME" << LAUNCHER_EOF
203212
exec "\$SCRIPT_DIR/app-bin" \
204213
${AUTOPLAY} \
205214
--ui "\${RESOURCES_DIR}/qml/${MAIN_QML}" \
@@ -208,18 +217,7 @@ exec "\$SCRIPT_DIR/app-bin" \
208217
LAUNCHER_EOF
209218
else
210219
# Without autoplay
211-
cat > "$BUNDLE_MACOS/$APP_NAME" << LAUNCHER_EOF
212-
#!/bin/bash
213-
214-
export SCORE_CUSTOM_APP_ORGANIZATION_NAME="$APP_ORGANIZATION"
215-
export SCORE_CUSTOM_APP_ORGANIZATION_DOMAIN="$APP_DOMAIN"
216-
export SCORE_CUSTOM_APP_APPLICATION_NAME="$APP_NAME"
217-
export SCORE_CUSTOM_APP_APPLICATION_VERSION="$APP_VERSION"
218-
219-
SCRIPT_DIR="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
220-
RESOURCES_DIR="\$(cd "\$SCRIPT_DIR/../Resources" && pwd)"
221-
export QML2_IMPORT_PATH="\${RESOURCES_DIR}/qml/"
222-
220+
cat >> "$BUNDLE_MACOS/$APP_NAME" << LAUNCHER_EOF
223221
exec "\$SCRIPT_DIR/app-bin" \
224222
${AUTOPLAY} \
225223
--ui "\${RESOURCES_DIR}/qml/${MAIN_QML}" \

tools/create-app-windows.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ echo "Creating native launcher executable..."
129129

130130
# Generate C source code
131131
echo " =========== "
132-
cp "$SCORE_SOURCE_DIR/tools/launcher/launcher.c" launcher.c
132+
cp "$SCORE_SOURCE_DIR/tools/launcher/launcher.cpp" launcher.cpp
133133
cat > launcher-defines.h << EOF
134134
#pragma once
135135
@@ -145,26 +145,38 @@ cat > launcher-defines.h << EOF
145145
146146
EOF
147147

148+
if [[ -n "$APP_ENVIRONMENT" ]]; then
149+
echo "#undef SCORE_ENVIRONMENT" >> launcher-defines.h
150+
echo '#define SCORE_ENVIRONMENT R"___(' >> launcher-defines.h
151+
cat "$APP_ENVIRONMENT" >> launcher-defines.h
152+
echo ')___"' >> launcher-defines.h
153+
else
154+
echo '#define SCORE_ENVIRONMENT ""' >> launcher-defines.h
155+
fi
156+
148157
# Compile the launcher
149158
# Try clang first, then fall back to CC (usually gcc or msvc cl)
150159
COMPILER=""
151-
if command -v clang &> /dev/null; then
152-
COMPILER="clang"
153-
echo "Using clang to compile launcher"
154-
elif [[ -n "${CC:-}" ]] && command -v "$CC" &> /dev/null; then
155-
COMPILER="$CC"
156-
echo "Using $CC to compile launcher"
157-
elif command -v gcc &> /dev/null; then
158-
COMPILER="gcc"
159-
echo "Using gcc to compile launcher"
160+
if command -v 'clang++' &> /dev/null; then
161+
COMPILER="clang++"
162+
CXXFLAGS="-O3 -std=c++20 -Xlinker -SUBSYSTEM:WINDOWS"
163+
echo "Using clang++ to compile launcher"
164+
elif [[ -n "${CXX:-}" ]] && command -v "$CXX" &> /dev/null; then
165+
COMPILER="$CXX"
166+
CXXFLAGS="-O3 -std=c++20 -mwindows"
167+
echo "Using $CXX to compile launcher"
168+
elif command -v 'g++' &> /dev/null; then
169+
COMPILER="g++"
170+
CXXFLAGS="-O3 -mwindows"
171+
echo "Using g++ to compile launcher"
160172
else
161173
echo "Warning: No C compiler found (tried clang, \$CC, gcc)"
162174
echo "Falling back to batch script launcher"
163175
exit 1
164176
fi
165177

166-
$COMPILER -O3 -o "${APP_NAME}.exe" launcher.c -luser32
167-
rm -f launcher.c launcher-defines.h
178+
$COMPILER $CXXFLAGS -o "${APP_NAME}.exe" launcher.cpp -luser32 -lshell32
179+
rm -f launcher.cpp launcher-defines.h
168180

169181
# Set icon and properties
170182
if [[ -f "${APP_ICON_ICO}" ]]; then

tools/create-app.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ APP_NAME_SAFE=""
1818
APP_APPDATA_XML=""
1919
APP_COPYRIGHT=""
2020
APP_DESCRIPTION=""
21+
APP_ENVIRONMENT=""
2122
APP_ORGANIZATION=""
2223
APP_DOMAIN=""
2324
APP_IDENTIFIER=""
@@ -57,17 +58,18 @@ Optional:
5758
macos-intel, macos-arm, windows
5859
Can be specified multiple times. If not specified,
5960
builds for current platform.
60-
--app-organization Set the app organization (e.g. ossia)
61-
--app-domain Set the app domain (e.g. ossia.io)
62-
--app-identifier Set the app identifier (e.g. io.ossia.score)
63-
--app-description Set the app description (one line max)
64-
--app-copyright Set the app copyright (e.g. ossia.io)
65-
--app-version Set the app version (e.g. 1.0-rc3)
6661
--app-appdata-xml Set the app appdata.xml file (Linux)
67-
--app-ico Set the app icon (ico format, Windows)
62+
--app-copyright Set the app copyright (e.g. ossia.io)
63+
--app-description Set the app description (one line max)
64+
--app-domain Set the app domain (e.g. ossia.io)
65+
--app-environment Set a file containing environment variables to set
6866
--app-icns Set the app icon (icns format, macOS)
67+
--app-ico Set the app icon (ico format, Windows)
68+
--app-identifier Set the app identifier (e.g. io.ossia.score)
69+
--app-organization Set the app organization (e.g. ossia)
6970
--app-png Set the app icon (png format, Linux)
7071
--app-qrc Optional qrc resource file
72+
--app-version Set the app version (e.g. 1.0-rc3)
7173
--help Show this help message
7274
7375
Example:
@@ -124,6 +126,10 @@ while [[ $# -gt 0 ]]; do
124126
APP_NAME="$2"
125127
shift 2
126128
;;
129+
--app-environment)
130+
APP_ENVIRONMENT="$2"
131+
shift 2
132+
;;
127133
--app-organization)
128134
APP_ORGANIZATION="$2"
129135
shift 2
@@ -314,6 +320,7 @@ export APP_COPYRIGHT
314320
export APP_DESCRIPTION
315321
export APP_ORGANIZATION
316322
export APP_DOMAIN
323+
export APP_ENVIRONMENT
317324
export APP_IDENTIFIER
318325
export APP_ICON_ICO
319326
export APP_ICON_ICNS

tools/launcher/launcher-defines.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
#define SCORE_CUSTOM_APP_ORGANIZATION_DOMAIN "$SCORE_CUSTOM_APP_ORGANIZATION_DOMAIN"
1111
#define SCORE_CUSTOM_APP_APPLICATION_NAME "$SCORE_CUSTOM_APP_APPLICATION_NAME"
1212
#define SCORE_CUSTOM_APP_APPLICATION_VERSION "$SCORE_CUSTOM_APP_APPLICATION_VERSION"
13+
14+
#define SCORE_ENVIRONMENT ""

tools/launcher/launcher.c

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)