Skip to content

Commit

Permalink
Allow passing environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
gasinvein committed Jul 11, 2022
1 parent da6fa89 commit 019611a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions editor-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function msg() {
}

function exec_editor() {
@EXPORT_ENVS_INNER@
if [ -n "@ZYPAK_BINDIR@" ]; then
export ZYPAK_BIN="@ZYPAK_BINDIR@"
export ZYPAK_LIB="@ZYPAK_LIBDIR@"
Expand Down
1 change: 1 addition & 0 deletions editor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FIRST_RUN="${XDG_CONFIG_HOME}/@FLAGFILE_PREFIX@-first-run"
SDK_UPDATE="${XDG_CONFIG_HOME}/@FLAGFILE_PREFIX@-sdk-update-@SDK_VERSION@"

function exec_editor() {
@EXPORT_ENVS@
exec "@WRAPPER_PATH@" @EDITOR_ARGS@ "$@"
}

Expand Down
14 changes: 14 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ foreach arg : get_option('editor_args')
editor_args += '"@0@"'.format(arg)
endforeach

export_envs = []
foreach env : get_option('envs')
var = env.split('=')
export_envs += 'export @0@="@1@"'.format(var[0], var[1])
endforeach

export_envs_inner = []
foreach env : get_option('envs_inner')
var = env.split('=')
export_envs_inner += 'export @0@="@1@"'.format(var[0], var[1])
endforeach

wrapper_name = '@0@-wrapper'.format(get_option('program_name'))
wrapper_dir = join_paths(get_option('prefix'), get_option('bindir'))
wrapper_path = join_paths(wrapper_dir, wrapper_name)
Expand All @@ -50,6 +62,8 @@ wrapper_data = configuration_data({
'WRAPPER_PATH': wrapper_path,
'EDITOR_BINARY': editor_path,
'EDITOR_ARGS': ' '.join(editor_args),
'EXPORT_ENVS': ' && '.join(export_envs),
'EXPORT_ENVS_INNER': ' && '.join(export_envs_inner),
'EDITOR_TITLE': get_option('editor_title'),
'FIRST_RUN_README': join_paths(datadir, first_run_filename),
'SDK_UPDATE_README': join_paths(datadir, sdk_update_filename),
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ 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('zypak', type: 'feature', value: 'disabled')
option('envs', type: 'array', value: [])
option('envs_inner', type: 'array', value: [])

0 comments on commit 019611a

Please sign in to comment.