📦 build(scripts/release): implement support for socket-based communication if there's an active instance
it's FASTERgit add scripts/release.shgit add scripts/release.sh
This commit is contained in:
+31
-4
@@ -1,8 +1,8 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
outdir="./build/release"
|
socket_support=true
|
||||||
|
|
||||||
while getopts o:r:h args; do
|
while getopts o:r:hn args; do
|
||||||
case "$args" in
|
case "$args" in
|
||||||
o)
|
o)
|
||||||
outdir=${OPTARG}
|
outdir=${OPTARG}
|
||||||
@@ -10,12 +10,16 @@ while getopts o:r:h args; do
|
|||||||
r)
|
r)
|
||||||
gresource_file=${OPTARG}
|
gresource_file=${OPTARG}
|
||||||
;;
|
;;
|
||||||
h)
|
n)
|
||||||
|
unset socket_support
|
||||||
|
;;
|
||||||
|
? | h)
|
||||||
echo "\
|
echo "\
|
||||||
colorshell's automated release-build script.
|
colorshell's automated release-build script.
|
||||||
|
|
||||||
options:
|
options:
|
||||||
-r \$file: gresource's target path (shell-only, file is kept in \$output. default: \$XDG_DATA_HOME/colorshell/resources.gresource)
|
-r \$file: gresource's target path (shell-only, file is kept in \$output. default: \$XDG_DATA_HOME/colorshell/resources.gresource)
|
||||||
|
-n: disable socket communication support(use the slower remote instance communication)
|
||||||
-o \$path: build output path (default: \`./build/release\`)
|
-o \$path: build output path (default: \`./build/release\`)
|
||||||
-h: show this help message"
|
-h: show this help message"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -24,4 +28,27 @@ options:
|
|||||||
done
|
done
|
||||||
|
|
||||||
# send literal variable name, so it's interpreted in the shell rather than in the build
|
# send literal variable name, so it's interpreted in the shell rather than in the build
|
||||||
pnpm build -o "${outdir:-./build/release}" -b -r "${gresource_file:-\$XDG_DATA_HOME/colorshell/resources.gresource}"
|
sh ./scripts/build.sh -o "${outdir:-./build/release}" -b -r "${gresource_file:-\$XDG_DATA_HOME/colorshell/resources.gresource}"
|
||||||
|
|
||||||
|
# add socket-communication support on executable
|
||||||
|
if [[ $socket_support ]]; then
|
||||||
|
echo "[info] adding socket communication support"
|
||||||
|
script="\
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if gdbus introspect --session \\
|
||||||
|
--dest io.github.retrozinndev.colorshell \\
|
||||||
|
--object-path /io/github/retrozinndev/colorshell > /dev/null 2>&1; then
|
||||||
|
|
||||||
|
echo \"\$@\" | socat - \"\${XDG_RUNTIME_DIR:-/run/user/\$(id -u)}/colorshell.sock\"
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
`cat "${outdir:-./build/release}/colorshell" | sed -e 's/^#.*//'`" # remove shebang
|
||||||
|
|
||||||
|
echo -en "$script" > "${outdir:-./build/release}/colorshell"
|
||||||
|
chmod +x "${outdir:-./build/release}/colorshell"
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user