Skip to content

Commit

Permalink
Enable/Disable ivi-homescreen/flutter-auto plugins when creating a Fl…
Browse files Browse the repository at this point in the history
…utter workspace

Example usage: `./flutter_workspace.py --enable-plugin=video_player_linux,flatpak --disable-plugin=rive_text`

-resolves #75

Signed-off-by: Joel Winarske <[email protected]>
  • Loading branch information
jwinarske committed Feb 10, 2025
1 parent d082725 commit 404ca23
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion configs/desktop-homescreen.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"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",
"PLUGIN_WEBRTC": "-DBUILD_PLUGIN_WEBRTC=${FLUTTER_WORKSPACE_LIBWEBRTC_LOAD} -DLIBWEBRTC_INC_DIR=${LIBWEBRTC_INC_DIR} -DLIBWEBRTC_LIB=${LIBWEBRTC_LIB}",
"PLUGIN_ARGS": "-DBUILD_PLUGIN_FILAMENT_VIEW=ON ${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=ON -DBUILD_PLUGIN_DESKTOP_WINDOW_LINUX=ON ${PLUGIN_FIREBASE} ${PLUGIN_RIVE} ${PLUGIN_PDF} ${FLUGIN_FILAMENT_VIEW} ${PLUGIN_WEBRTC} ${PLUGIN_CAMERA} ${PLUGIN_FLATPAK}",
"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} ${PLUGIN_ARGS}",
"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} ${PLUGIN_ARGS}${CMD_LINE_CMAKE_PLUGIN_ARGS}",
"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}",
"PING_CMD": "[ -n \"$WAYLAND_DISPLAY\" ] && echo \"Type=wayland\"",
"CREATE_BUNDLE_FOLDER": "mkdir -p ${PLATFORM_ID_DIR_RELATIVE}/data",
Expand Down
44 changes: 36 additions & 8 deletions flutter_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def main():
parser.add_argument('--plex', default='', type=str, help='Platform Load Excludes')
parser.add_argument('--enable', default='', type=str, help='Platform Load Enable Override')
parser.add_argument('--disable', default='', type=str, help='Platform Load Disable Override')
parser.add_argument('--enable-plugin', default='', type=str, help='Plugin Enable')
parser.add_argument('--disable-plugin', default='', type=str, help='Plugin Disable')
parser.add_argument('--fastboot', default='', type=str, help='Update the selected platform using fastboot')
parser.add_argument('--mask-rom', default='', type=str, help='Update the selected platform using Mask ROM')
parser.add_argument('--device-id', default='', type=str, help='device id for flashing')
Expand Down Expand Up @@ -340,7 +342,7 @@ def main():
if args.cookie_file:
cookie_file = args.cookie_file

setup_platforms(platforms, github_token, cookie_file, args.plex, args.enable, args.disable, app_folder)
setup_platforms(platforms, github_token, cookie_file, args.plex, args.enable, args.disable, args.enable_plugin, args.disable_plugin, app_folder)

#
# Display the custom devices list
Expand Down Expand Up @@ -1782,7 +1784,26 @@ def is_host_type_supported(host_types):
return True


def setup_platform(platform_, git_token, cookie_file, plex, enable, disable, app_folder):
def handle_plugin_variables(enable_plugin, disable_plugin):
""" Set plugin environmental variables """
plugins = []

if enable_plugin:
for it in enable_plugin:
plugins.append(f' -DBUILD_PLUGIN_{it.upper()}=ON')

if disable_plugin:
for it in disable_plugin:
plugins.append(f' -DBUILD_PLUGIN_{it.upper()}=OFF')

plugins = "".join(plugins)

os.environ['CMD_LINE_CMAKE_PLUGIN_ARGS'] = plugins

print_banner('CMD_LINE_CMAKE_PLUGIN_ARGS=' + os.environ.get('CMD_LINE_CMAKE_PLUGIN_ARGS','Not Set'))


def setup_platform(platform_, git_token, cookie_file, plex, enable, disable, enable_plugin, disable_plugin, app_folder):
""" Sets up platform """

if 'type' in platform_:
Expand Down Expand Up @@ -1843,6 +1864,7 @@ def setup_platform(platform_, git_token, cookie_file, plex, enable, disable, app
handle_artifacts_obj(runtime.get('artifacts'),
host_machine_arch, cwd, git_token, cookie_file)
validate_sudo_user()
handle_plugin_variables(enable_plugin, disable_plugin)
handle_pre_requisites(runtime.get('pre-requisites'), cwd)
validate_sudo_user()
handle_docker_obj(runtime.get('docker'), host_machine_arch, cwd)
Expand Down Expand Up @@ -1928,15 +1950,15 @@ def get_hardware_threads():
return multiprocessing.cpu_count()


def setup_toolchain(platform_, git_token, cookie_file, plex, enable, disable, app_folder):
def setup_toolchain(platform_, git_token, cookie_file, plex, enable, disable, enable_plugin, disable_plugin, app_folder):
hw_threads = get_hardware_threads()
if not os.getenv('GITHUB_ACTIONS'):
if hw_threads > 1:
hw_threads = hw_threads - 1
os.environ['HARDWARE_THREADS'] = str(hw_threads)

platform_['type'] = 'dependency'
setup_platform(platform_, git_token, cookie_file, plex, enable, disable, app_folder)
setup_platform(platform_, git_token, cookie_file, plex, enable, disable, enable_plugin, disable_plugin, app_folder)
platform_['type'] = 'toolchain'

if not 'toolchain' in platform_:
Expand Down Expand Up @@ -2017,7 +2039,7 @@ def get_not_dependencies(platforms):
return not_dependencies


def setup_platforms(platforms, git_token, cookie_file, plex, enable, disable, app_folder):
def setup_platforms(platforms, git_token, cookie_file, plex, enable, disable, enable_plugin, disable_plugin, app_folder):
""" Sets up each occurring platform defined """

if plex:
Expand All @@ -2029,19 +2051,25 @@ def setup_platforms(platforms, git_token, cookie_file, plex, enable, disable, ap
if disable:
disable = disable.split(',')

if enable_plugin:
enable_plugin = enable_plugin.split(',')

if disable_plugin:
disable_plugin = disable_plugin.split(',')

for toolchain in get_toolchains(platforms):
setup_toolchain(toolchain, git_token, cookie_file, plex, enable, disable, app_folder)
setup_toolchain(toolchain, git_token, cookie_file, plex, enable, disable, enable_plugin, disable_plugin, app_folder)

# iterate over dependencies first
for dependency in get_dependencies(platforms):
setup_platform(dependency, git_token, cookie_file, plex, enable, disable, app_folder)
setup_platform(dependency, git_token, cookie_file, plex, enable, disable, enable_plugin, disable_plugin, app_folder)

# reset sudo timeout
validate_sudo_user()

# iterate over non-dependencies
for platform_ in get_not_dependencies(platforms):
setup_platform(platform_, git_token, cookie_file, plex, enable, disable, app_folder)
setup_platform(platform_, git_token, cookie_file, plex, enable, disable, enable_plugin, disable_plugin, app_folder)

# reset sudo timeout
validate_sudo_user()
Expand Down

0 comments on commit 404ca23

Please sign in to comment.