From 17b528489bf19e876bceb7f2da93b0d85be6b7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulius=20Gerv=C4=97?= Date: Thu, 27 Feb 2025 20:14:55 +0200 Subject: [PATCH 1/6] Use shutil to move files (supports cross-env moves) --- multibuild.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multibuild.py b/multibuild.py index 2fbdc83..e424fae 100644 --- a/multibuild.py +++ b/multibuild.py @@ -22,6 +22,7 @@ import os import sys from dataclasses import dataclass from typing import List +import shutil # Constants AVAILABLE_TARGETS = ["linux", "windows", "macos"] @@ -86,7 +87,7 @@ def run_build(target, arch): # Move assets to dist print('Assets:', ', '.join(builder.assets)) for asset in builder.assets: - os.rename(asset, f'dist/{asset}') + shutil.move(asset, f'dist/{asset}') def main(): From f377a4e66db8d585582c65aff0e03463b39f66cd Mon Sep 17 00:00:00 2001 From: Paulius Gerve Date: Fri, 28 Feb 2025 10:02:15 +0200 Subject: [PATCH 2/6] Update GetJson --- additions/camoucfg/MaskConfig.hpp | 45 +++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/additions/camoucfg/MaskConfig.hpp b/additions/camoucfg/MaskConfig.hpp index 76fc407..caf80fc 100644 --- a/additions/camoucfg/MaskConfig.hpp +++ b/additions/camoucfg/MaskConfig.hpp @@ -44,10 +44,14 @@ inline std::optional get_env_utf8(const std::string& name) { } inline const nlohmann::json& GetJson() { - static const nlohmann::json jsonConfig = []() { - std::string jsonString; - int index = 1; + static std::once_flag initFlag; + static nlohmann::json jsonConfig; + std::call_once(initFlag, []() { + std::string jsonString; + + // First try the chunked environment variables + int index = 1; while (true) { std::string envName = "CAMOU_CONFIG_" + std::to_string(index); auto partialConfig = get_env_utf8(envName); @@ -57,23 +61,36 @@ inline const nlohmann::json& GetJson() { index++; } + // If no chunked variables found, try the original CAMOU_CONFIG if (jsonString.empty()) { - // Check for the original CAMOU_CONFIG as fallback auto originalConfig = get_env_utf8("CAMOU_CONFIG"); - if (originalConfig) jsonString = *originalConfig; + if (originalConfig) { + jsonString = *originalConfig; + } } - if (jsonString.empty()) return nlohmann::json{}; - - // Validate - if (!nlohmann::json::accept(jsonString)) { - printf_stderr("ERROR: Invalid JSON passed to CAMOU_CONFIG!\n"); - return nlohmann::json{}; + // If still empty, return an empty JSON object + if (jsonString.empty()) { + jsonConfig = nlohmann::json{}; + return; } - nlohmann::json result = nlohmann::json::parse(jsonString); - return result; - }(); + // Validate and parse the JSON + try { + if (!nlohmann::json::accept(jsonString)) { + printf_stderr("ERROR: Invalid JSON passed to CAMOU_CONFIG!\n"); + jsonConfig = nlohmann::json{}; + return; + } + + jsonConfig = nlohmann::json::parse(jsonString); + } catch (const nlohmann::json::exception& e) { + printf_stderr("ERROR: JSON parsing failed: %s\n", e.what()); + jsonConfig = nlohmann::json{}; + } + }); + + // Return the cached JSON object return jsonConfig; } From ef6a54509f863db9bd5f1bfc65a2a110c6e6b920 Mon Sep 17 00:00:00 2001 From: Paulius Gerve Date: Fri, 28 Feb 2025 10:03:02 +0200 Subject: [PATCH 3/6] Dockerfile fixes --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index dcf5310..c9b49a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y \ # Python python3 python3-dev python3-pip \ # Camoufox build system tools - git p7zip-full golang-go aria2 curl \ + git p7zip-full golang-go aria2 curl rsync \ # CA certificates ca-certificates \ && update-ca-certificates @@ -23,10 +23,10 @@ ENV PATH="/root/.cargo/bin:${PATH}" # Fetch Firefox & apply initial patches RUN make setup-minimal && \ make mozbootstrap && \ - mkdir /app/dist + mkdir -p /app/dist # Mount .mozbuild directory and dist folder VOLUME /root/.mozbuild VOLUME /app/dist -ENTRYPOINT ["python3", "./multibuild.py"] +ENTRYPOINT ["python3", "./multibuild.py"] \ No newline at end of file From f0b18df3240cf4b374c548bed5765fd61e72aa6d Mon Sep 17 00:00:00 2001 From: Paulius Gerve Date: Fri, 28 Feb 2025 10:30:21 +0200 Subject: [PATCH 4/6] Updated GetJson --- additions/camoucfg/MaskConfig.hpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/additions/camoucfg/MaskConfig.hpp b/additions/camoucfg/MaskConfig.hpp index caf80fc..28a95a7 100644 --- a/additions/camoucfg/MaskConfig.hpp +++ b/additions/camoucfg/MaskConfig.hpp @@ -49,9 +49,8 @@ inline const nlohmann::json& GetJson() { std::call_once(initFlag, []() { std::string jsonString; - - // First try the chunked environment variables int index = 1; + while (true) { std::string envName = "CAMOU_CONFIG_" + std::to_string(index); auto partialConfig = get_env_utf8(envName); @@ -61,36 +60,27 @@ inline const nlohmann::json& GetJson() { index++; } - // If no chunked variables found, try the original CAMOU_CONFIG if (jsonString.empty()) { + // Check for the original CAMOU_CONFIG as fallback auto originalConfig = get_env_utf8("CAMOU_CONFIG"); - if (originalConfig) { - jsonString = *originalConfig; - } + if (originalConfig) jsonString = *originalConfig; } - // If still empty, return an empty JSON object if (jsonString.empty()) { jsonConfig = nlohmann::json{}; return; } - // Validate and parse the JSON - try { - if (!nlohmann::json::accept(jsonString)) { - printf_stderr("ERROR: Invalid JSON passed to CAMOU_CONFIG!\n"); - jsonConfig = nlohmann::json{}; - return; - } - - jsonConfig = nlohmann::json::parse(jsonString); - } catch (const nlohmann::json::exception& e) { - printf_stderr("ERROR: JSON parsing failed: %s\n", e.what()); + // Validate + if (!nlohmann::json::accept(jsonString)) { + printf_stderr("ERROR: Invalid JSON passed to CAMOU_CONFIG!\n"); jsonConfig = nlohmann::json{}; + return; } + + jsonConfig = nlohmann::json::parse(jsonString); }); - // Return the cached JSON object return jsonConfig; } From 13d645cacfbabbf311a8c6d512436a2a13f384af Mon Sep 17 00:00:00 2001 From: Paulius Gerve Date: Fri, 28 Feb 2025 13:00:32 +0200 Subject: [PATCH 5/6] Experimental build improvements --- assets/base.mozconfig | 9 +++++++-- assets/macos.mozconfig | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/assets/base.mozconfig b/assets/base.mozconfig index 588160e..09ccec3 100644 --- a/assets/base.mozconfig +++ b/assets/base.mozconfig @@ -1,9 +1,14 @@ ac_add_options --enable-application=browser - + +# Memory-saving build configuration +mk_add_options MOZ_MAKE_FLAGS="-j4" # Reduce parallel jobs +ac_add_options --disable-debug-symbols # Reduce memory usage during linking +ac_add_options --disable-debug +ac_add_options --enable-optimize="-O2" # Less aggressive optimization than -O3 + ac_add_options --allow-addon-sideload ac_add_options --disable-crashreporter ac_add_options --disable-backgroundtasks -ac_add_options --disable-debug ac_add_options --disable-default-browser-agent ac_add_options --disable-tests ac_add_options --disable-updater diff --git a/assets/macos.mozconfig b/assets/macos.mozconfig index d9ba378..fef2c23 100644 --- a/assets/macos.mozconfig +++ b/assets/macos.mozconfig @@ -1,6 +1,10 @@ ac_add_options --disable-update-agent # ac_add_options --disable-alsa +# MacOS-specific memory-saving options +ac_add_options --disable-install-strip # Avoid extra memory usage during packaging +ac_add_options --disable-unified-build # Build files individually to reduce peak memory + # Packaging related # #export DSYMUTIL="$MOZBUILD/clang/bin/dsymutil" # export DMG_TOOL="$MOZBUILD/dmg/dmg" From d65e81caad0743f876092e58237a43b62ce3286a Mon Sep 17 00:00:00 2001 From: Paulius Gerve Date: Fri, 28 Feb 2025 14:21:48 +0200 Subject: [PATCH 6/6] Revert "Experimental build improvements" This reverts commit 13d645cacfbabbf311a8c6d512436a2a13f384af. --- assets/base.mozconfig | 9 ++------- assets/macos.mozconfig | 4 ---- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/assets/base.mozconfig b/assets/base.mozconfig index 09ccec3..588160e 100644 --- a/assets/base.mozconfig +++ b/assets/base.mozconfig @@ -1,14 +1,9 @@ ac_add_options --enable-application=browser - -# Memory-saving build configuration -mk_add_options MOZ_MAKE_FLAGS="-j4" # Reduce parallel jobs -ac_add_options --disable-debug-symbols # Reduce memory usage during linking -ac_add_options --disable-debug -ac_add_options --enable-optimize="-O2" # Less aggressive optimization than -O3 - + ac_add_options --allow-addon-sideload ac_add_options --disable-crashreporter ac_add_options --disable-backgroundtasks +ac_add_options --disable-debug ac_add_options --disable-default-browser-agent ac_add_options --disable-tests ac_add_options --disable-updater diff --git a/assets/macos.mozconfig b/assets/macos.mozconfig index fef2c23..d9ba378 100644 --- a/assets/macos.mozconfig +++ b/assets/macos.mozconfig @@ -1,10 +1,6 @@ ac_add_options --disable-update-agent # ac_add_options --disable-alsa -# MacOS-specific memory-saving options -ac_add_options --disable-install-strip # Avoid extra memory usage during packaging -ac_add_options --disable-unified-build # Build files individually to reduce peak memory - # Packaging related # #export DSYMUTIL="$MOZBUILD/clang/bin/dsymutil" # export DMG_TOOL="$MOZBUILD/dmg/dmg"