From abfb9d5ba7d069d18e522f3852b218408bff004c Mon Sep 17 00:00:00 2001 From: trickypr Date: Sun, 10 Nov 2024 15:29:54 +1100 Subject: [PATCH 1/8] allow CI to run on non-main branch --- .github/workflows/artifact.yml | 3 ++- .gitignore | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/artifact.yml b/.github/workflows/artifact.yml index 6d34130..4369084 100644 --- a/.github/workflows/artifact.yml +++ b/.github/workflows/artifact.yml @@ -6,7 +6,7 @@ name: Create Artifact on: # Triggers the workflow on push or pull request events but only for the "main" branch push: - branches: ["main"] + branches: ["*"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -128,6 +128,7 @@ jobs: - name: Make artifact available uses: "marvinpinto/action-automatic-releases@latest" + if: github.ref == 'refs/heads/main' with: repo_token: "${{ secrets.GITHUB_TOKEN }}" automatic_release_tag: "latest" diff --git a/.gitignore b/.gitignore index e993686..d80f0fb 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ devenv.local.nix # System mozillabuild mozillabuild - +/mozconfig From 0b08ee8df7bdb57baa8bc083c06f0a035a519d75 Mon Sep 17 00:00:00 2001 From: trickypr Date: Sun, 10 Nov 2024 15:39:41 +1100 Subject: [PATCH 2/8] add development scripts to devenv --- devenv.nix | 107 +++++++++++++++++++++++++++++++---------------------- gluon.json | 2 +- 2 files changed, 64 insertions(+), 45 deletions(-) diff --git a/devenv.nix b/devenv.nix index debbe98..475ad55 100644 --- a/devenv.nix +++ b/devenv.nix @@ -1,14 +1,32 @@ -{ pkgs, lib, config, inputs, stdenv, ... }: +{ + pkgs, + ... +}: { env.LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; - + languages.c.enable = true; languages.cplusplus.enable = true; languages.rust.enable = true; # https://devenv.sh/reference/options/#languagesrustchannel languages.rust.channel = "stable"; + languages.javascript = { + enable = true; + pnpm = { + enable = true; + install.enable = true; + }; + }; + + scripts = { + gluon.exec = "pnpm gluon $@"; + download.exec = "gluon download"; + import.exec = "gluon import"; + build.exec = "gluon build"; + }; + packages = with pkgs; [ sccache unzip @@ -22,50 +40,51 @@ libclang gcc - libxkbcommon libdrm + libxkbcommon + libdrm -# build time - autoconf - cargo - dump_syms - makeWrapper - mimalloc - nodejs - perl - pkg-config - python3 - rustc - rust-cbindgen - unzip - which + # build time + autoconf + cargo + dump_syms + makeWrapper + mimalloc + nodejs + perl + pkg-config + python3 + rustc + rust-cbindgen + unzip + which -# runtime - bzip2 - dbus - dbus-glib - file - fontconfig - freetype - glib - gnum4 - gtk3 - icu - icu72 - libGL - libGLU - libevent - libffi - libjpeg - libpng - libstartup_notification - libvpx - libwebp - nasm - nspr - nss_latest - pango - zip - zlib + # runtime + bzip2 + dbus + dbus-glib + file + fontconfig + freetype + glib + gnum4 + gtk3 + icu + icu72 + libGL + libGLU + libevent + libffi + libjpeg + libpng + libstartup_notification + libvpx + libwebp + nasm + nspr + nss_latest + pango + zip + zlib bzip2 dbus diff --git a/gluon.json b/gluon.json index e725ca6..19ebb08 100644 --- a/gluon.json +++ b/gluon.json @@ -34,4 +34,4 @@ ], "licenseType": "MPL-2.0" } -} +} \ No newline at end of file From 43ec48054cc91a330777214ee18dc9cfceac868f Mon Sep 17 00:00:00 2001 From: trickypr Date: Sun, 10 Nov 2024 15:48:16 +1100 Subject: [PATCH 3/8] =?UTF-8?q?=F0=9F=90=9B=20fix=20vendor=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/quark-runtime/config/mozconfig | 2 +- src/quark-runtime/moz.configure | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/quark-runtime/config/mozconfig b/src/quark-runtime/config/mozconfig index 67a7b9e..6ed70ef 100644 --- a/src/quark-runtime/config/mozconfig +++ b/src/quark-runtime/config/mozconfig @@ -9,6 +9,6 @@ ac_add_options --enable-application=quark-runtime ac_add_options --with-app-name=experiment-runtime -export MOZ_APP_VENDOR=Fushra +# export MOZ_APP_VENDOR=Fushra export MOZ_APP_DISPLAYNAME=Experiment export MOZ_UPDATE_CHANNEL=dev diff --git a/src/quark-runtime/moz.configure b/src/quark-runtime/moz.configure index bf71366..7e68569 100644 --- a/src/quark-runtime/moz.configure +++ b/src/quark-runtime/moz.configure @@ -3,6 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. imply_option("MOZ_APP_BASENAME", "Experiment") +imply_option("MOZ_APP_VENDOR", "trickypr") # this is required to define mozilla::components::History::GetServiceHelper in objdir/xpcom/components/Components.h imply_option("MOZ_PLACES", True) From b630796feae357997920b445b4011379f239c278 Mon Sep 17 00:00:00 2001 From: trickypr Date: Sun, 10 Nov 2024 17:11:28 +1100 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=9A=A7=20Get=20closer=20to=20a=20full?= =?UTF-8?q?=20compile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devenv.nix | 4 +++- src/quark-runtime/moz.configure | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/devenv.nix b/devenv.nix index 475ad55..85079aa 100644 --- a/devenv.nix +++ b/devenv.nix @@ -24,7 +24,9 @@ gluon.exec = "pnpm gluon $@"; download.exec = "gluon download"; import.exec = "gluon import"; - build.exec = "gluon build"; + build.exec = "unset AS && gluon build"; + # MAR generation generally fails, but we ignore that + package.exec = "gluon package || echo 0"; }; packages = with pkgs; [ diff --git a/src/quark-runtime/moz.configure b/src/quark-runtime/moz.configure index 7e68569..fccc8f6 100644 --- a/src/quark-runtime/moz.configure +++ b/src/quark-runtime/moz.configure @@ -4,6 +4,7 @@ imply_option("MOZ_APP_BASENAME", "Experiment") imply_option("MOZ_APP_VENDOR", "trickypr") +imply_option("MOZ_APP_ID", "{dda969a5-00d5-441a-8fcd-0a0dc55b490b}") # this is required to define mozilla::components::History::GetServiceHelper in objdir/xpcom/components/Components.h imply_option("MOZ_PLACES", True) From 1971025fc3d43a570fc106aca4e5b4332876fabb Mon Sep 17 00:00:00 2001 From: trickypr Date: Sun, 10 Nov 2024 17:28:29 +1100 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=90=9B=20Update=20code=20for=20new=20?= =?UTF-8?q?IPC=20system?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/quark-runtime/app/QuarkRuntime.cpp | 108 +++++++++++-------------- 1 file changed, 45 insertions(+), 63 deletions(-) diff --git a/src/quark-runtime/app/QuarkRuntime.cpp b/src/quark-runtime/app/QuarkRuntime.cpp index 1fc968e..073621f 100644 --- a/src/quark-runtime/app/QuarkRuntime.cpp +++ b/src/quark-runtime/app/QuarkRuntime.cpp @@ -12,6 +12,7 @@ // macOS todos: // TODO: Allow disabling content processes on macOS +#include "XREChildData.h" #include "mozilla/Bootstrap.h" #include #include @@ -24,15 +25,15 @@ #endif #include "nsAppRunner.h" -#include "nsIFile.h" #include "nsCOMPtr.h" -#include "nsMemory.h" #include "nsCRTGlue.h" +#include "nsIFile.h" +#include "nsMemory.h" // #include "nsStringAPI.h" // #include "nsServiceManagerUtils.h" #include "plstr.h" -#include "prprf.h" #include "prenv.h" +#include "prprf.h" // #include "nsINIParser.h" GRE Versioning stuff that needs to be in libxul :( #include "application.ini.h" @@ -45,12 +46,8 @@ #include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL -// NOTE: In firefox this is wrapped in a check that excludes cocoa or android -// because we are not targeting either platform right now, I am going -// exclude that check -// -// This is the required include for content process stuff -#include "../../ipc/contentproc/plugin-container.cpp" +// NOTE: Firefox does not allow content processes on android and coccoa. +// We target neither, so we leave our content process code outside of macros using namespace mozilla; @@ -63,14 +60,14 @@ using namespace mozilla; * @param fmt * printf-style format string followed by arguments. */ -static void Output(bool isError, const char *fmt, ...) -{ +static void Output(bool isError, const char *fmt, ...) { va_list ap; va_start(ap, fmt); #if (defined(XP_WIN) && !MOZ_WINCONSOLE) wchar_t msg[2048]; - _vsnwprintf(msg, sizeof(msg) / sizeof(msg[0]), NS_ConvertUTF8toUTF16(fmt).get(), ap); + _vsnwprintf(msg, sizeof(msg) / sizeof(msg[0]), + NS_ConvertUTF8toUTF16(fmt).get(), ap); UINT flags = MB_OK; if (isError) @@ -89,10 +86,8 @@ static void Output(bool isError, const char *fmt, ...) /** * Return true if |arg| matches the given argument name. */ -static bool IsArg(const char *arg, const char *s) -{ - if (*arg == '-') - { +static bool IsArg(const char *arg, const char *s) { + if (*arg == '-') { if (*++arg == '-') ++arg; return !strcasecmp(arg, s); @@ -140,8 +135,7 @@ static bool IsArg(const char *arg, const char *s) // return NS_OK; // } -static void Usage(const char *argv0) -{ +static void Usage(const char *argv0) { // nsAutoCString milestone; // GetGREVersion(argv0, &milestone, nullptr); @@ -168,11 +162,11 @@ static void Usage(const char *argv0) Bootstrap::UniquePtr gBootstrap; static nsresult initXPCOMGlue(LibLoadingStrategy libLoadingStrategy) { - if (gBootstrap) return NS_OK; + if (gBootstrap) + return NS_OK; UniqueFreePtr exePathPtr = BinaryPath::Get(); - if (!exePathPtr) - { + if (!exePathPtr) { Output(true, "Couldn't calculate the application directory.\n"); return NS_ERROR_FAILURE; } @@ -180,14 +174,14 @@ static nsresult initXPCOMGlue(LibLoadingStrategy libLoadingStrategy) { char *exePath = exePathPtr.get(); char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); - if (!lastSlash || (size_t(lastSlash - exePath) > MAXPATHLEN - sizeof(XPCOM_DLL) - 1)) + if (!lastSlash || + (size_t(lastSlash - exePath) > MAXPATHLEN - sizeof(XPCOM_DLL) - 1)) return NS_ERROR_FAILURE; strcpy(++lastSlash, XPCOM_DLL); auto bootstrapResult = mozilla::GetBootstrap(exePath, libLoadingStrategy); - if (bootstrapResult.isErr()) - { + if (bootstrapResult.isErr()) { Output(true, "Couldn't load XPCOM.\n"); return NS_ERROR_FAILURE; } @@ -199,14 +193,11 @@ static nsresult initXPCOMGlue(LibLoadingStrategy libLoadingStrategy) { return NS_OK; } -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { #if defined(MOZ_ENABLE_FORKSERVER) - if (strcmp(argv[argc - 1], "forkserver") == 0) - { + if (strcmp(argv[argc - 1], "forkserver") == 0) { nsresult rv = InitXPCOMGlue(LibLoadingStrategy::NoReadAhead); - if (NS_FAILED(rv)) - { + if (NS_FAILED(rv)) { return 255; } @@ -219,8 +210,7 @@ int main(int argc, char *argv[]) // argc & argv will be updated with the values passing from the // chrome process. With the new values, this function // continues the reset of the code acting as a content process. - if (gBootstrap->XRE_ForkServer(&argc, &argv)) - { + if (gBootstrap->XRE_ForkServer(&argc, &argv)) { // Return from the fork server in the fork server process. // Stop the fork server. gBootstrap->NS_LogTerm(); @@ -235,31 +225,32 @@ int main(int argc, char *argv[]) // Set the process type. We don't remove the arg here as that will be done // later in common code. SetGeckoProcessType(argv[argc - 1]); + SetGeckoChildID(argv[--argc]); - nsresult initXPCOMGlueResult = initXPCOMGlue(LibLoadingStrategy::NoReadAhead); + nsresult initXPCOMGlueResult = + initXPCOMGlue(LibLoadingStrategy::NoReadAhead); if (NS_FAILED(initXPCOMGlueResult)) { Output(true, "Failed to load xpcom glue"); return 255; } - int contentProcMainResult = content_process_main(gBootstrap.get(), argc, argv); + XREChildData childData; + nsresult contentProcMainResult = + gBootstrap->XRE_InitChildProcess(argc, argv, &childData); // InitXPCOMGlue calls NS_LogInit, so we need to balance it here. gBootstrap->NS_LogTerm(); - return contentProcMainResult; + return NS_FAILED(contentProcMainResult) ? 1 : 0; } - if (argc > 1 && (IsArg(argv[1], "h") || - IsArg(argv[1], "help") || - IsArg(argv[1], "?"))) - { + if (argc > 1 && + (IsArg(argv[1], "h") || IsArg(argv[1], "help") || IsArg(argv[1], "?"))) { Usage(argv[0]); return 0; } - if (argc == 2 && (IsArg(argv[1], "v") || IsArg(argv[1], "version"))) - { + if (argc == 2 && (IsArg(argv[1], "v") || IsArg(argv[1], "version"))) { // nsAutoCString milestone; // nsAutoCString version; // GetGREVersion(argv[0], &milestone, &version); @@ -269,17 +260,14 @@ int main(int argc, char *argv[]) return 0; } - if (argc > 1) - { + if (argc > 1) { // nsAutoCString milestone; // nsresult rv = GetGREVersion(argv[0], &milestone, nullptr); // if (NS_FAILED(rv)) // return 2; - if (IsArg(argv[1], "gre-version")) - { - if (argc != 2) - { + if (IsArg(argv[1], "gre-version")) { + if (argc != 2) { Usage(argv[0]); return 1; } @@ -289,27 +277,23 @@ int main(int argc, char *argv[]) return 0; } - if (IsArg(argv[1], "install-app")) - { - Output(true, "--install-app support has been removed. Use 'python install-app.py' instead.\n"); + if (IsArg(argv[1], "install-app")) { + Output(true, "--install-app support has been removed. Use 'python " + "install-app.py' instead.\n"); return 1; } } const char *appDataFile = getenv("XUL_APP_FILE"); - if (!(appDataFile && *appDataFile)) - { - if (argc < 2) - { + if (!(appDataFile && *appDataFile)) { + if (argc < 2) { Usage(argv[0]); return 1; } - if (IsArg(argv[1], "app")) - { - if (argc == 2) - { + if (IsArg(argv[1], "app")) { + if (argc == 2) { Usage(argv[0]); return 1; } @@ -330,13 +314,10 @@ int main(int argc, char *argv[]) BootstrapConfig config; - if (appDataFile[0] != '-') - { + if (appDataFile[0] != '-') { config.appData = nullptr; config.appDataPath = appDataFile; - } - else - { + } else { config.appData = &sAppData; config.appDataPath = "quark-runtime"; } @@ -347,6 +328,7 @@ int main(int argc, char *argv[]) return 255; } + gBootstrap->XRE_EnableSameExecutableForContentProc(); int xreMainResult = gBootstrap->XRE_main(argc, argv, config); gBootstrap->NS_LogTerm(); From 00fb3a5587b779289f72efc1059f6c1785bd03af Mon Sep 17 00:00:00 2001 From: trickypr Date: Sun, 10 Nov 2024 17:32:25 +1100 Subject: [PATCH 6/8] =?UTF-8?q?=F0=9F=91=B7=20Try=20using=20devenv=20for?= =?UTF-8?q?=20CI=20environment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/artifact.yml | 115 +++++++++++++++------------------ 1 file changed, 52 insertions(+), 63 deletions(-) diff --git a/.github/workflows/artifact.yml b/.github/workflows/artifact.yml index 4369084..e8f1764 100644 --- a/.github/workflows/artifact.yml +++ b/.github/workflows/artifact.yml @@ -20,12 +20,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 20 - - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -40,13 +35,6 @@ jobs: git config --global user.email "trickypr@users.noreply.github.com" git config --global user.name "TrickyPR" - - name: Install system dependencies - run: | - sudo apt-get update --fix-missing - sudo apt-get update - sudo apt-get install meson dos2unix yasm nasm build-essential libgtk2.0-dev libpython3-dev m4 uuid libasound2-dev libcurl4-openssl-dev libdbus-1-dev libdrm-dev libdbus-glib-1-dev libdbus-glib-1-dev libgtk-3-dev libpulse-dev libx11-xcb-dev libxt-dev xvfb lld llvm - pip install pycairo testresources - - name: Free up space run: | sudo rm -rf /usr/share/dotnet @@ -54,67 +42,68 @@ jobs: sudo rm -rf "/usr/local/share/boost" sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Install sccache - env: - LINK: https://github.com/mozilla/sccache/releases/download - SCCACHE_VERSION: 0.2.13 - run: | - SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl - mkdir -p $HOME/.local/bin - curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz - mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache - echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Save sccache - uses: actions/cache@v3 - continue-on-error: false - with: - path: /home/runner/.cache/sccache - key: ${{ runner.os }}-sccache - - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install + # - name: Install sccache + # env: + # LINK: https://github.com/mozilla/sccache/releases/download + # SCCACHE_VERSION: 0.2.13 + # run: | + # SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl + # mkdir -p $HOME/.local/bin + # curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz + # mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache + # echo "$HOME/.local/bin" >> $GITHUB_PATH + + # - name: Save sccache + # uses: actions/cache@v3 + # continue-on-error: false + # with: + # path: /home/runner/.cache/sccache + # key: ${{ runner.os }}-sccache + + # - uses: pnpm/action-setup@v2 + # name: Install pnpm + # id: pnpm-install + # with: + # version: 8 + # run_install: false + + # - name: Get pnpm store directory + # id: pnpm-cache + # shell: bash + # run: | + # echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + # - uses: actions/cache@v3 + # name: Setup pnpm cache + # with: + # path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + # key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + # restore-keys: | + # ${{ runner.os }}-pnpm-store- + + # - name: Install dependencies + # run: pnpm install + + - uses: cachix/install-nix-action@v26 + - uses: cachix/cachix-action@v14 with: - version: 8 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install + name: devenv + - name: Install devenv.sh + run: nix profile install nixpkgs#devenv - name: Download firefox source and dependencies - run: pnpm gluon download + run: devenv shell download - name: Import - run: pnpm gluon import - - - name: Bootstrap - run: | - cd engine - ./mach --no-interactive bootstrap --application-choice browser - cd .. + run: devenv shell import - name: Build - run: pnpm gluon build + run: devenv shell build - name: Package # .mar files are not properly generated, but it should be fine continue-on-error: true - run: pnpm gluon package + run: devenv shell package - name: Rename artifacts run: | From 7872f8cd77537e6949bc3ee42ab58b6d311fba19 Mon Sep 17 00:00:00 2001 From: trickypr Date: Mon, 11 Nov 2024 17:23:30 +1100 Subject: [PATCH 7/8] =?UTF-8?q?=F0=9F=91=B7=20Try=20adding=20glibc=20to=20?= =?UTF-8?q?devenv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devenv.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/devenv.nix b/devenv.nix index 85079aa..9391120 100644 --- a/devenv.nix +++ b/devenv.nix @@ -68,6 +68,7 @@ fontconfig freetype glib + glibc gnum4 gtk3 icu From 1d788a4e2c12fd588109c06e7826b647329f1143 Mon Sep 17 00:00:00 2001 From: trickypr Date: Mon, 11 Nov 2024 17:39:54 +1100 Subject: [PATCH 8/8] =?UTF-8?q?=F0=9F=91=B7=20Remove=20devenv's=20glibc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devenv.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/devenv.nix b/devenv.nix index 9391120..6a86023 100644 --- a/devenv.nix +++ b/devenv.nix @@ -6,7 +6,6 @@ { env.LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; - languages.c.enable = true; languages.cplusplus.enable = true; languages.rust.enable = true; # https://devenv.sh/reference/options/#languagesrustchannel @@ -33,6 +32,7 @@ sccache unzip + glibc libllvm libclang llvm @@ -68,7 +68,6 @@ fontconfig freetype glib - glibc gnum4 gtk3 icu