Skip to content

Commit a614bd4

Browse files
committed
Added configs env append with separator
1 parent 7bb3c5b commit a614bd4

File tree

2 files changed

+50
-21
lines changed

2 files changed

+50
-21
lines changed

configs/desktop-homescreen.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"HOMESCREEN_SRC_DIR": "${FLUTTER_WORKSPACE}/app/ivi-homescreen",
2020
"HOMESCREEN_BUILD_DIR": "${FLUTTER_WORKSPACE}/app/ivi-homescreen/build",
2121
"PLUGINS_DIR": "${FLUTTER_WORKSPACE}/app/ivi-homescreen-plugins/plugins",
22+
"+(;)EXT_PLUGINS_DIRS": "",
2223
"FIREBASE_SRC_DIR": "${FLUTTER_WORKSPACE}/app/firebase-cpp-sdk",
2324
"FIREBASE_BUILD_DIR": "${FLUTTER_WORKSPACE}/app/firebase-cpp-sdk/build",
2425
"PLUGIN_FIREBASE": "-DBUILD_PLUGIN_CLOUD_FIRESTORE=${FLUTTER_WORKSPACE_FIREBASE_CPP_SDK_LOAD} -DBUILD_PLUGIN_FIREBASE_AUTH=${FLUTTER_WORKSPACE_FIREBASE_CPP_SDK_LOAD} -DBUILD_PLUGIN_FIREBASE_STORAGE=${FLUTTER_WORKSPACE_FIREBASE_CPP_SDK_LOAD} -DFIREBASE_CPP_SDK_DIR=${FIREBASE_SRC_DIR} -DFIREBASE_SDK_LIBDIR=${FIREBASE_BUILD_DIR}",
@@ -34,8 +35,8 @@
3435
"LIBWEBRTC_LIB": "${LIBWEBRTC_LIB_DIR}/libwebrtc.so",
3536
"PLUGIN_WEBVIEW": "-DBUILD_PLUGIN_WEBVIEW_FLUTTER_VIEW=${FLUTTER_WORKSPACE_CEF_PREBUILT_LOAD} -DCEF_ROOT=${FLUTTER_WORKSPACE}/app/ivi-homescreen-plugins/plugins/webview_flutter_view/third_party/cef_binary_128.4.9+g9840ad9+chromium-128.0.6613.120_linux64_minimal",
3637
"PLUGIN_WEBRTC": "-DBUILD_PLUGIN_WEBRTC=${FLUTTER_WORKSPACE_LIBWEBRTC_LOAD} -DLIBWEBRTC_INC_DIR=${LIBWEBRTC_INC_DIR} -DLIBWEBRTC_LIB=${LIBWEBRTC_LIB}",
37-
"PLUGIN_ARGS": "${PLUGIN_WEBVIEW} -DBUILD_PLUGIN_NAV_RENDER_VIEW=${FLUTTER_WORKSPACE_MAPLIBRE_VULKAN_LOAD} -DBUILD_PLUGIN_LAYER_PLAYGROUND_VIEW=OFF -DBUILD_PLUGIN_AUDIOPLAYERS_LINUX=OFF -DBUILD_PLUGIN_URL_LAUNCHER=ON -DBUILD_PLUGIN_FILE_SELECTOR=ON -DBUILD_PLUGIN_GO_ROUTER=ON -DBUILD_PLUGIN_SECURE_STORAGE=OFF -DBUILD_PLUGIN_DESKTOP_WINDOW_LINUX=ON ${PLUGIN_FIREBASE} ${PLUGIN_RIVE} ${PLUGIN_PDF} ${PLUGIN_WEBRTC} ${PLUGIN_CAMERA} ${PLUGIN_CAMERA_PIPEWIRE} ${PLUGIN_FLATPAK}",
38-
"HOMESCREEN_CMAKE_ARGS": "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DLLVM_CONFIG=${LLVM_CONFIG} -DSANITIZE_ADDRESS=OFF -DENABLE_DLT=OFF -DBUILD_UNIT_TESTS=OFF -DBUILD_DOCS=OFF -DBUILD_CRASH_HANDLER=OFF -DENABLE_IVI_SHELL_CLIENT=OFF -DENABLE_XDG_CLIENT=ON -DENABLE_AGL_SHELL_CLIENT=${FLUTTER_WORKSPACE_AGL_COMPOSITOR_LOAD} -DENABLE_LTO=ON -DENABLE_STATIC_LINK=ON -DDEBUG_PLATFORM_MESSAGES=OFF -DBUILD_BACKEND_WAYLAND_EGL=ON -DBUILD_BACKEND_WAYLAND_VULKAN=OFF -DBUILD_EGL_TRANSPARENCY=ON -DBUILD_EGL_ENABLE_3D=ON -DBUILD_EGL_ENABLE_MULTISAMPLE=ON -DPLUGINS_DIR=${PLUGINS_DIR} -DEXT_PLUGINS_DIRS=${EXT_PLUGINS_DIRS} ${PLUGIN_ARGS}${CMD_LINE_CMAKE_PLUGIN_ARGS}",
38+
"+PLUGIN_ARGS": "${PLUGIN_WEBVIEW} -DBUILD_PLUGIN_NAV_RENDER_VIEW=${FLUTTER_WORKSPACE_MAPLIBRE_VULKAN_LOAD} -DBUILD_PLUGIN_LAYER_PLAYGROUND_VIEW=OFF -DBUILD_PLUGIN_AUDIOPLAYERS_LINUX=OFF -DBUILD_PLUGIN_URL_LAUNCHER=ON -DBUILD_PLUGIN_FILE_SELECTOR=ON -DBUILD_PLUGIN_GO_ROUTER=ON -DBUILD_PLUGIN_SECURE_STORAGE=OFF -DBUILD_PLUGIN_DESKTOP_WINDOW_LINUX=ON ${PLUGIN_FIREBASE} ${PLUGIN_RIVE} ${PLUGIN_PDF} ${PLUGIN_WEBRTC} ${PLUGIN_CAMERA} ${PLUGIN_CAMERA_PIPEWIRE} ${PLUGIN_FLATPAK}",
39+
"HOMESCREEN_CMAKE_ARGS": "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DLLVM_CONFIG=${LLVM_CONFIG} -DSANITIZE_ADDRESS=OFF -DENABLE_DLT=OFF -DBUILD_UNIT_TESTS=OFF -DBUILD_DOCS=OFF -DBUILD_CRASH_HANDLER=OFF -DENABLE_IVI_SHELL_CLIENT=OFF -DENABLE_XDG_CLIENT=ON -DENABLE_AGL_SHELL_CLIENT=${FLUTTER_WORKSPACE_AGL_COMPOSITOR_LOAD} -DENABLE_LTO=ON -DENABLE_STATIC_LINK=ON -DDEBUG_PLATFORM_MESSAGES=OFF -DBUILD_BACKEND_WAYLAND_EGL=ON -DBUILD_BACKEND_WAYLAND_VULKAN=OFF -DBUILD_EGL_TRANSPARENCY=ON -DBUILD_EGL_ENABLE_3D=ON -DBUILD_EGL_ENABLE_MULTISAMPLE=ON -DPLUGINS_DIR=${PLUGINS_DIR} -DEXT_PLUGINS_DIRS=${EXT_PLUGINS_DIRS} ${PLUGIN_ARGS} ${CMD_LINE_CMAKE_PLUGIN_ARGS}",
3940
"HOMESCREEN_EXE": "LD_LIBRARY_PATH=${LIBWEBRTC_LIB_DIR}:${RIVE_TEXT_LIB_DIR} SPDLOG_LEVEL=debug ${HOMESCREEN_BUILD_DIR}/shell/homescreen -b ${PLATFORM_ID_DIR_RELATIVE}",
4041
"PING_CMD": "[ -n \"$WAYLAND_DISPLAY\" ] && echo \"Type=wayland\"",
4142
"CREATE_BUNDLE_FOLDER": "mkdir -p ${PLATFORM_ID_DIR_RELATIVE}/data ${PLATFORM_ID_DIR_RELATIVE}/lib",

flutter_workspace.py

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import json
3434
import os
3535
import platform
36+
import re
3637
import shlex
3738
import shutil
3839
import signal
@@ -2028,34 +2029,61 @@ def handle_dotenv(dotenv_files):
20282029
print(f'Loaded: {dotenv_path}')
20292030

20302031

2031-
def handle_env(env_variables, local_env, build_type=None):
2032+
def handle_env(env_variables, env=None, build_type=None):
20322033
if not env_variables:
20332034
return
2035+
2036+
if env is None:
2037+
env = os.environ
20342038

2039+
# If k starts with +, append to existing variable
20352040
for k, v in env_variables.items():
2036-
if local_env:
2037-
if 'PATH_PREPEND' in k:
2038-
local_env['PATH'] = os.path.normpath(os.path.expandvars(v)) + os.pathsep + local_env['PATH']
2039-
continue
2040-
if 'PATH_APPEND' in k:
2041-
local_env['PATH'] = local_env['PATH'] + os.pathsep + os.path.normpath(os.path.expandvars(v))
2042-
continue
2041+
print(f'Processing env var: {k} = {v}')
2042+
2043+
# Append to existing variable if the key starts with +
2044+
# (then remove the + from the key)
2045+
append = False
2046+
if k.startswith('+'):
2047+
append = True
2048+
k = k[1:]
2049+
2050+
# TODO: obsolete? remove in the future
2051+
if 'PATH_PREPEND' in k:
2052+
env['PATH'] = os.path.normpath(os.path.expandvars(v)) + os.pathsep + env['PATH']
2053+
continue
2054+
if 'PATH_APPEND' in k:
2055+
env['PATH'] = env['PATH'] + os.pathsep + os.path.normpath(os.path.expandvars(v))
2056+
continue
20432057

2044-
handle_build_type(local_env, build_type)
2058+
handle_build_type(env, build_type)
20452059

2046-
local_env[k] = os.path.normpath(os.path.expandvars(v))
2047-
else:
2048-
if 'PATH_PREPEND' in k:
2049-
os.environ['PATH'] = os.path.normpath(os.path.expandvars(v)) + os.pathsep + os.environ['PATH']
2050-
continue
2051-
if 'PATH_APPEND' in k:
2052-
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + os.path.normpath(os.path.expandvars(v))
2060+
v = os.path.expandvars(v)
2061+
if append:
2062+
# If append empty string, skip
2063+
if k == '':
20532064
continue
20542065

2055-
handle_build_type(os.environ, build_type)
2066+
# if a separator is specified in the key like `(;)SOMETHING_SOMETHING`, extract it
2067+
2068+
# Separator extraction logic:
2069+
# sep = between '(' and ')'
2070+
# default separator is " "
2071+
sep = " "
2072+
if '(' in k and ')' in k:
2073+
sep = k.split('(')[1].split(')')[0]
2074+
k = k.split(')')[1]
2075+
2076+
# Append to existing value
2077+
old_value = env.get(k, '')
2078+
if old_value != '':
2079+
v = old_value + sep + v
2080+
# skip append if there's no old value
2081+
2082+
env[k] = v
2083+
if not env is os.environ:
2084+
os.environ[k] = v
20562085

2057-
os.environ[k] = os.path.normpath(os.path.expandvars(v))
2058-
# print(f'global: {k} = {os.environ[k]}')
2086+
print(f'Final env var: {k} = {os.environ[k]}')
20592087

20602088

20612089
def handle_build_type(env, build_type=None):

0 commit comments

Comments
 (0)