Skip to content

Commit

Permalink
Add environmental variable QZ_OPTS (qzind#710)
Browse files Browse the repository at this point in the history
Allows overriding java launch behavior such as -Xms -Xmx, etc
  • Loading branch information
tresf authored Sep 23, 2020
1 parent 6d7f1f3 commit d2e18ce
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ant/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ project.filename=qz-tray
project.datadir=qz

launch.opts=-Xms512m -Djna.nosys=true
launch.overrides=QZ_OPTS

src.dir=${basedir}/src
out.dir=${basedir}/out
Expand All @@ -25,3 +26,6 @@ javac.target=1.8
javafx.version=15.ea+3_monocle
javafx.mirror=https://download2.gluonhq.com/openjfx/15
java.download=https://adoptopenjdk.net/?variant=openjdk11

# Workaround to delay expansion of $${foo} (e.g. shell scripts)
dollar=$
18 changes: 15 additions & 3 deletions ant/unix/unix-launcher.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ RED="\\x1B[1;31m";GREEN="\\x1B[1;32m";YELLOW="\\x1B[1;33m";PLAIN="\\x1B[0m"
SUCCESS=" [${GREEN}success${PLAIN}]"
FAILURE=" [${RED}failure${PLAIN}]"
WARNING=" [${YELLOW}warning${PLAIN}]"
MESSAGE=" [${YELLOW}message${PLAIN}]"

echo "Looking for Java..."

Expand All @@ -38,10 +39,21 @@ if [ -d ./jre ]; then
export PATH
fi

# Check for user overridable launch options
if [ -n "${dollar}${launch.overrides}" ]; then
echo -e "$MESSAGE Picked up additional launch options: ${dollar}${launch.overrides}"
LAUNCH_OPTS="$LAUNCH_OPTS ${dollar}${launch.overrides}"
fi

if [[ "$OSTYPE" == "darwin"* ]]; then
DEFAULTS_READ=$(defaults read ${apple.bundleid} ${launch.overrides} 2>/dev/null) || true
if [ -n "$DEFAULTS_READ" ]; then
echo -e "$MESSAGE Picked up additional launch options: $DEFAULTS_READ"
LAUNCH_OPTS="$LAUNCH_OPTS $DEFAULTS_READ"
fi
ICON_PATH="$DIR/Contents/Resources/apple-icon.icns"
MAC_PRIMARY="/usr/libexec/java_home"
MAC_FALLACK="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin"
MAC_FALLBACK="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin"
echo "Trying $MAC_PRIMARY..."
if "$MAC_PRIMARY" -v $JAVA_MIN+ &>/dev/null; then
echo -e "$SUCCESS Using \"$MAC_PRIMARY -v $JAVA_MIN+ --exec\" to launch $ABOUT_TITLE"
Expand All @@ -50,9 +62,9 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
}
elif [ -d "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin" ]; then
echo -e "$WARNING No luck using $MAC_PRIMARY"
echo "Trying $MAC_FALLACK..."
echo "Trying $MAC_FALLBACK..."
java() {
"$MAC_FALLACK/java" "$@"
"$MAC_FALLBACK/java" "$@"
}
fi
else
Expand Down
11 changes: 10 additions & 1 deletion ant/windows/windows-launcher.nsi.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ Section
; Sets the $java variable
Call FindJava

Exec '"$javaw" ${launch.opts} -jar "${JAR}" $params'
Var /GLOBAL opts
StrCpy $opts "${launch.opts}"

; Check for user overridable launch options
ClearErrors
ReadEnvStr $R0 ${launch.overrides}
IfErrors +2 0
StrCpy $opts "$opts $R0"

Exec '"$javaw" $opts -jar "${JAR}" $params'
${If} ${RunningX64}
${EnableX64FSRedirection}
${EndIf}
Expand Down

0 comments on commit d2e18ce

Please sign in to comment.