Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gate appending electron by meson feature #24

Merged
merged 3 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ jobs:

- name: Run shellcheck
run: |
shellcheck --severity=style ide-wrapper-build/bin/dummy-editor
shellcheck --severity=style ide-wrapper-build/bin/dummy-editor{,-wrapper}

1 change: 1 addition & 0 deletions editor-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function msg() {

function exec_editor() {
@EXPORT_ENVS_INNER@
# shellcheck disable=SC2157
if [ -n "@ZYPAK_BINDIR@" ]; then
export ZYPAK_BIN="@ZYPAK_BINDIR@"
export ZYPAK_LIB="@ZYPAK_LIBDIR@"
Expand Down
28 changes: 20 additions & 8 deletions editor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ shopt -s nullglob
FIRST_RUN="${XDG_CONFIG_HOME}/@FLAGFILE_PREFIX@-first-run"
SDK_UPDATE="${XDG_CONFIG_HOME}/@FLAGFILE_PREFIX@-sdk-update-@SDK_VERSION@"

function display_server_args (){
declare -a DISPLAY_SERVER_ARGS=()

function update_display_server_args () {
# See https://github.com/flathub/im.riot.Riot/blob/3fdd41c84f40fa1e8e186bade5d832d79045600c/element.sh
# See also https://gaultier.github.io/blog/wayland_from_scratch.html
# and https://github.com/flathub/com.vscodium.codium/issues/321
Expand All @@ -19,20 +21,30 @@ function display_server_args (){
fi
fi

# shellcheck disable=SC2050
if [ "@ELECTRON_ENABLED@" -eq 0 ]; then
return 0
fi

if [ -e "$wayland_socket" ]; then
DISPLAY_SERVER_ARGS="--ozone-platform=wayland --enable-wayland-ime --enable-features=WaylandWindowDecorations"
[ -c /dev/nvidia0 ] && DISPLAY_SERVER_ARGS="${DISPLAY_SERVER_ARGS} --disable-gpu-sandbox"
DISPLAY_SERVER_ARGS=(
"--ozone-platform=wayland"
"--enable-wayland-ime"
"--enable-features=WaylandWindowDecorations"
)
if [ -c /dev/nvidia0 ]; then
DISPLAY_SERVER_ARGS+=("--disable-gpu-sandbox")
fi
else
DISPLAY_SERVER_ARGS="--ozone-platform=x11"
DISPLAY_SERVER_ARGS=("--ozone-platform=x11")
fi

echo "${DISPLAY_SERVER_ARGS}"
}

function exec_editor() {
@EXPORT_ENVS@
# shellcheck disable=SC2046,SC2086
exec "@WRAPPER_PATH@" @EDITOR_ARGS@ $(display_server_args) ${EDITOR_RUNTIME_ARGS} "$@"
update_display_server_args
# shellcheck disable=SC2086
exec "@WRAPPER_PATH@" @EDITOR_ARGS@ "${DISPLAY_SERVER_ARGS[@]}" ${EDITOR_RUNTIME_ARGS} "$@"
}

if [ ! -f "${FIRST_RUN}" ]; then
Expand Down
12 changes: 12 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ else
sdk_version = get_option('sdk_version')
endif

if get_option('electron').enabled()
electron_enabled = true
elif get_option('electron').auto()
electron_enabled = get_option('zypak').enabled()
else
if get_option('zypak').enabled()
error('`electron` feature is required if `zypak` is enabled')
endif
electron_enabled = false
endif

editor_args = []
foreach arg : get_option('editor_args')
editor_args += '"@0@"'.format(arg)
Expand Down Expand Up @@ -67,6 +78,7 @@ wrapper_data = configuration_data({
'WRAPPER_PATH': wrapper_path,
'EDITOR_BINARY': editor_path,
'EDITOR_ARGS': ' '.join(editor_args),
'ELECTRON_ENABLED': electron_enabled.to_int(),
'ZYPAK_ARGS': ' '.join(zypak_args),
'EXPORT_ENVS': ' && '.join(export_envs),
'EXPORT_ENVS_INNER': ' && '.join(export_envs_inner),
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ option('first_run_template', type: 'string', value: 'first_run.txt')
option('sdk_update_template', type: 'string', value: 'sdk_update.txt')
option('flagfile_prefix', type: 'string', value: 'flatpak-vscode')
option('default_loglevel', type: 'string', value: '1')
option('electron', type: 'feature', value: 'auto')
option('zypak', type: 'feature', value: 'disabled')
option('zypak_args', type: 'array', value: ['host'])
option('envs', type: 'array', value: [])
Expand Down
Loading