├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── dockerfiles ├── Dockerfile.builder ├── Dockerfile.buildtools ├── Dockerfile.gn ├── Dockerfile.libffi ├── Dockerfile.libgcc ├── Dockerfile.llvm └── Dockerfile.nodejs ├── patches ├── chromium.patch ├── depot.patch └── electron.patch └── scripts ├── binaries.sh ├── build.sh ├── commit.sh ├── env.sh ├── export.sh ├── extract.sh ├── package.sh ├── patch.sh ├── reset.sh ├── rollup.sh ├── sync.sh └── update.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | Dockerfile.* linguist-language=Dockerfile 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.tar.gz 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 darkyzhou 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Electron for LoongArch (Loong64) 2 | 3 | This project aims to build a version of Electron that supports the Loong64 architecture. 4 | 5 | **Note:** The Electron binaries require `glibc >= 2.38`. 6 | 7 | ## Usage 8 | 9 | 1. Check [releases](https://github.com/darkyzhou/electron-loong64/releases) for available versions. 10 | 2. Install the `electron` npm package with corresponding version and specify the download mirror like this: 11 | 12 | ``` 13 | ELECTRON_MIRROR="https://github.com/darkyzhou/electron-loong64/releases/download/" electron_use_remote_checksums=1 npm install electron@THE_VERSION 14 | ``` 15 | 16 | You may also refer to [darkyzhou/electron-builder-loong64](https://github.com/darkyzhou/electron-builder-loong64) for insturctions on how to build your Electron project with [electron-builder](https://github.com/electron-userland/electron-builder). 17 | 18 | ## Branches 19 | 20 | - `dev`: The development branch, containing the latest patches and build scripts. 21 | - `X.Y.Z`: The release branches, corresponding to the release versions of Electron. 22 | 23 | ## Acknowledgments 24 | 25 | Special thanks to [@jiegec](https://github.com/jiegec) and AOSC team for their invaluable Chromium patches in [AOSC-Dev/chromium-loongarch64](https://github.com/AOSC-Dev/chromium-loongarch64), which make this project possible. 26 | 27 | ## How This Project Works 28 | 29 | 1. This project builds upon the official Electron repository by applying custom patches. See `electron.patch` for details. 30 | 2. The build process runs in a dedicated container environment that includes all necessary build tools and dependencies. See `Dockerfile.builder` for details. 31 | 32 | ## Development 33 | 34 | ### Environment Requirements 35 | 36 | - Linux host machine with Loong64 architecture 37 | - Docker with [docker-buildx](https://github.com/docker/buildx) installed 38 | - [LATX](https://github.com/deuso/latx-build) version 1.4.4 (required for running `ghcr.io/darkyzhou/electron-buildtools` image) 39 | - System resources: minimum 32GiB RAM and 200GiB free disk space 40 | 41 | ### Building from Source 42 | 43 | 1. Launch a `ghcr.io/darkyzhou/electron-buildtools` container. All subsequent steps should be executed inside this container. 44 | 2. Change the variables inside `./scripts/env.sh` according to your environment and needs. 45 | 3. Run following scripts in sequence. 46 | 47 | ```bash 48 | # Clone or update the local electron repository 49 | ./scripts/update.sh 50 | 51 | # Apply patches from electron-loong64 52 | ./scripts/patch.sh 53 | 54 | # Fetch or update the dependencies of electron 55 | # Note: This could take a really long time, grab your coffee or take a sleep! 56 | ./scripts/sync.sh 57 | ``` 58 | 59 | 4. Launch a `ghcr.io/darkyzhou/electron-builder:deepin-25-llvm-20-rustc-188` container. All subsequent steps should be executed inside this container. 60 | 5. Run following scripts in sequence. 61 | 62 | ```bash 63 | # Replace binaries with native ones 64 | ./scripts/binaries.sh 65 | ./scripts/rollup.sh 66 | 67 | # Build the electron 68 | # Note: This could also take a long time, better get some sleep. 69 | ./scripts/build.sh 70 | 71 | # Package the electron 72 | ./scripts/package.sh 73 | ``` 74 | 75 | ### Updating Patches 76 | 77 | 1. Launch a `ghcr.io/darkyzhou/electron-buildtools` container. All subsequent steps should be executed inside this container. 78 | 79 | 2. Update versions and sync sources: 80 | - Edit `ELECTRON_VERSION` to point to the new version to build in `env.sh`. 81 | - Run `scripts/update.sh`. 82 | 83 | 3. Update dependencies: 84 | - Run `scripts/sync.sh`. This will apply all original patches from the Electron repository. 85 | 86 | 4. Apply Chromium patches: 87 | - Apply the consolidated Chromium patch file (e.g., `chromium-131.0.6778.85.diff`) to `$BUILD_ROOT/src`. 88 | - Resolve any conflicts if any. 89 | 90 | 5. Export Chromium patches using `npx e patches` command: 91 | > Note: `$BUILD_ROOT/src` is a git repository containing submodules, including `$BUILD_ROOT/src/electron` and *a few folders* in `$BUILD_ROOT/src/third_party`. 92 | 93 | 1. Run `scripts/export.sh` to commit changes for both chromium and submodule changes. 94 | 2. Run `npx e patches $NAME` to export patches for submodule commits. 95 | 3. Export changes in `$BUILD_ROOT/src/electron` to `patches/`. 96 | 97 | 6. Apply Electron patches from `patches/electron.patch`. 98 | 99 | 7. Run `scripts/sync.sh` again to sync the sources and apply all patches. 100 | 101 | ### Troubleshooting 102 | 103 | Common compilation errors: 104 | 105 | - `relocation R_LARCH_B26 out of range: 172745664 is not in [-134217728, 134217727]` 106 | - Root cause: The library was compiled *without* the `-mcmodel=medium` flag. For more details, see [laelf.adoc](https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#code_models). 107 | - Resolution: Recompile the library with the `-mcmodel=medium` flag. See `Dockerfile.libffi` for implementation examples. 108 | -------------------------------------------------------------------------------- /dockerfiles/Dockerfile.builder: -------------------------------------------------------------------------------- 1 | FROM linuxdeepin/deepin:beige-25-loong64-v1.5.0 2 | 3 | RUN groupadd --gid 1000 builduser && \ 4 | useradd --uid 1000 --gid builduser --shell /bin/bash --create-home builduser 5 | 6 | ENV TEMP=/tmp 7 | RUN chmod a+rwx /tmp 8 | 9 | # Omitted lighttpd, rpm, xcompmgr and xcb as deepin doesn't offer them. Fortunately we could compile without them somehow. 10 | ENV DEBIAN_FRONTEND=noninteractive 11 | RUN echo 'deb https://mirrors.ustc.edu.cn/deepin/beige beige main commercial community' > /etc/apt/sources.list && \ 12 | apt-get update && \ 13 | apt-get install -y --no-install-recommends \ 14 | ca-certificates \ 15 | curl \ 16 | git \ 17 | file \ 18 | gdb \ 19 | gnupg \ 20 | locales \ 21 | lsb-release \ 22 | nano \ 23 | python3-pip \ 24 | sudo \ 25 | vim-nox \ 26 | wget \ 27 | lsof \ 28 | software-properties-common \ 29 | desktop-file-utils \ 30 | xvfb \ 31 | gperf \ 32 | bison \ 33 | python3-dbusmock \ 34 | openjdk-8-jre \ 35 | ninja-build \ 36 | build-essential \ 37 | libnotify-bin \ 38 | libfuse2 \ 39 | libdbus-1-dev \ 40 | libgtk-3-dev \ 41 | libnotify-dev \ 42 | libasound2-dev \ 43 | libcap-dev \ 44 | libcups2-dev \ 45 | libxtst-dev \ 46 | libxss1 \ 47 | libnss3-dev \ 48 | 49 | # Tools needed by our scripts 50 | jq \ 51 | rsync \ 52 | 53 | # From https://chromium.googlesource.com/chromium/src/+/HEAD/build/install-build-deps.py 54 | binutils \ 55 | bison \ 56 | bzip2 \ 57 | cdbs \ 58 | curl \ 59 | dbus-x11 \ 60 | devscripts \ 61 | dpkg-dev \ 62 | elfutils \ 63 | fakeroot \ 64 | flex \ 65 | git-core \ 66 | gperf \ 67 | libasound2-dev \ 68 | libatspi2.0-dev \ 69 | libbrlapi-dev \ 70 | libbz2-dev \ 71 | libc6-dev \ 72 | libcairo2-dev \ 73 | libcap-dev \ 74 | libcups2-dev \ 75 | libcurl4-gnutls-dev \ 76 | libdrm-dev \ 77 | libelf-dev \ 78 | libevdev-dev \ 79 | libffi-dev \ 80 | libfuse2 \ 81 | libgbm-dev \ 82 | libglib2.0-dev \ 83 | libglu1-mesa-dev \ 84 | libgtk-3-dev \ 85 | libkrb5-dev \ 86 | libnspr4-dev \ 87 | libnss3-dev \ 88 | libpam0g-dev \ 89 | libpci-dev \ 90 | libpulse-dev \ 91 | libsctp-dev \ 92 | libspeechd-dev \ 93 | libsqlite3-dev \ 94 | libssl-dev \ 95 | libsystemd-dev \ 96 | libudev-dev \ 97 | libudev1 \ 98 | libva-dev \ 99 | libwww-perl \ 100 | libxshmfence-dev \ 101 | libxslt1-dev \ 102 | libxss-dev \ 103 | libxt-dev \ 104 | libxtst-dev \ 105 | locales \ 106 | openbox \ 107 | p7zip \ 108 | patch \ 109 | perl \ 110 | pkgconf \ 111 | ruby \ 112 | uuid-dev \ 113 | wdiff \ 114 | x11-utils \ 115 | xz-utils \ 116 | zip \ 117 | libatk1.0-0 \ 118 | libatspi2.0-0 \ 119 | libc6 \ 120 | libcairo2 \ 121 | libcap2 \ 122 | libcgi-session-perl \ 123 | libcups2 \ 124 | libdrm2 \ 125 | libegl1 \ 126 | libevdev2 \ 127 | libexpat1 \ 128 | libfontconfig1 \ 129 | libfreetype6 \ 130 | libgbm1 \ 131 | libglib2.0-0 \ 132 | libgl1 \ 133 | libgtk-3-0 \ 134 | libpam0g \ 135 | libpango-1.0-0 \ 136 | libpangocairo-1.0-0 \ 137 | libpci3 \ 138 | libpcre3 \ 139 | libpixman-1-0 \ 140 | libspeechd2 \ 141 | libstdc++6 \ 142 | libsqlite3-0 \ 143 | libuuid1 \ 144 | libwayland-egl1 \ 145 | libwayland-egl1-mesa \ 146 | libx11-6 \ 147 | libx11-xcb1 \ 148 | libxau6 \ 149 | libxcb1 \ 150 | libxcomposite1 \ 151 | libxcursor1 \ 152 | libxdamage1 \ 153 | libxdmcp6 \ 154 | libxext6 \ 155 | libxfixes3 \ 156 | libxi6 \ 157 | libxinerama1 \ 158 | libxrender1 \ 159 | libxtst6 \ 160 | x11-utils \ 161 | x11-xserver-utils \ 162 | xserver-xorg-core \ 163 | xserver-xorg-video-dummy \ 164 | xvfb \ 165 | zlib1g \ 166 | 167 | # From compilation errors 168 | libx11-xcb-dev \ 169 | libxcb-xkb-dev \ 170 | libxkbcommon-x11-dev \ 171 | libdav1d-dev \ 172 | libyuv-dev \ 173 | mesa-common-dev \ 174 | 175 | # LLVM 176 | libxml2 \ 177 | libedit2 \ 178 | libffi8 179 | 180 | # LLVM 181 | ARG LLVM_NAME=llvm-20 182 | COPY llvm.tar.gz . 183 | RUN mkdir llvm && \ 184 | tar -xzvf llvm.tar.gz -C llvm && \ 185 | cp -aPv llvm/usr/* /usr/ && \ 186 | (cd /usr/bin; ln -sv ../lib/${LLVM_NAME}/bin/* .; cd -) && \ 187 | (cd /usr/lib; ln -sv ./${LLVM_NAME}/lib/clang .; cd -) && \ 188 | (cd /usr/lib/loongarch64-linux-gnu; ln -sv ../${LLVM_NAME}/lib/*.so.* .; cd -) && \ 189 | rm -rf llvm llvm.tar.gz && \ 190 | update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 && \ 191 | update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 192 | 193 | # GN 194 | COPY gn.tar.gz . 195 | RUN mkdir gn && \ 196 | tar -xzvf gn.tar.gz && \ 197 | chmod +x out/gn && \ 198 | mv out/gn /usr/bin/ && \ 199 | rm -rf gn gn.tar.gz 200 | 201 | # Node.js 202 | COPY nodejs.tar.gz . 203 | RUN tar -xzf nodejs.tar.gz -C / && \ 204 | rm nodejs.tar.gz && \ 205 | npm i -g yarn @esbuild/linux-loong64@0.25.1 206 | 207 | # Libraries 208 | COPY libgcc.tar.gz libffi.tar.gz . 209 | RUN mkdir libgcc libffi && \ 210 | # Replacing the crtbeginS.o is hacky, we might need to build the whole gcc instead 211 | tar -xzvf libgcc.tar.gz -C libgcc && \ 212 | cp libgcc/gcc/loongarch64-unknown-linux-gnu/*/crtbeginS.o /usr/lib/gcc/loongarch64-linux-gnu/12/ && \ 213 | # Replacing libffi: Also hacky here 214 | tar -xzvf libffi.tar.gz -C libffi && \ 215 | cp libffi/libffi_convenience.a /usr/lib/loongarch64-linux-gnu/libffi_pic.a && \ 216 | # Clean up 217 | rm -rf *.tar.gz libgcc libffi 218 | 219 | # Rust 220 | ENV CARGO_HOME=/usr/local RUSTUP_HOME=/usr/local 221 | RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain 1.88.0 && \ 222 | # Chromium seems to require that bindgen binary lives together with llvm 223 | cargo install bindgen-cli@0.69.1 --root /usr/lib/llvm-20 224 | 225 | RUN echo 'builduser ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-builduser && \ 226 | echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep 227 | 228 | USER builduser 229 | WORKDIR /home/builduser 230 | -------------------------------------------------------------------------------- /dockerfiles/Dockerfile.buildtools: -------------------------------------------------------------------------------- 1 | FROM debian:bookworm-slim 2 | 3 | RUN groupadd --gid 1000 builduser && \ 4 | useradd --uid 1000 --gid builduser --shell /bin/bash --create-home builduser 5 | 6 | ENV DEBIAN_FRONTEND=noninteractive 7 | RUN apt-get update && \ 8 | apt-get install -y --no-install-recommends \ 9 | ca-certificates \ 10 | curl \ 11 | git \ 12 | sudo \ 13 | xz-utils \ 14 | nano \ 15 | fish 16 | 17 | RUN curl --silent --location https://deb.nodesource.com/setup_22.x | bash - && \ 18 | apt-get update && \ 19 | apt-get install -y nodejs && \ 20 | npm install -g npm@latest node-gyp yarn 21 | 22 | RUN echo 'builduser ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-builduser 23 | 24 | USER builduser 25 | WORKDIR /home/builduser 26 | RUN npm install @electron/build-tools 27 | -------------------------------------------------------------------------------- /dockerfiles/Dockerfile.gn: -------------------------------------------------------------------------------- 1 | FROM linuxdeepin/deepin:beige-25-loong64-v1.5.0 2 | 3 | ARG GN_REVISION="ebc8f16ca7b0d36a3e532ee90896f9eb48e5423b" 4 | 5 | ENV DEBIAN_FRONTEND=noninteractive 6 | RUN echo 'deb https://mirrors.ustc.edu.cn/deepin/beige beige main commercial community' > /etc/apt/sources.list && \ 7 | apt-get update && \ 8 | apt-get install -y --no-install-recommends \ 9 | ca-certificates \ 10 | curl \ 11 | git \ 12 | build-essential \ 13 | clang-18 \ 14 | python3 \ 15 | ninja-build && \ 16 | update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 && \ 17 | update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100 18 | 19 | WORKDIR /root 20 | RUN git clone https://gn.googlesource.com/gn && \ 21 | git checkout ${GN_REVISION} && \ 22 | cd gn && \ 23 | python build/gen.py && \ 24 | ninja -C out && \ 25 | tar czf libffi.tar.gz --directory=.libs . 26 | -------------------------------------------------------------------------------- /dockerfiles/Dockerfile.libffi: -------------------------------------------------------------------------------- 1 | FROM linuxdeepin/deepin:beige-loong64-v1.4.0 2 | 3 | ARG LIBFFI_VERSION="3.4.6" 4 | 5 | ENV DEBIAN_FRONTEND=noninteractive 6 | RUN echo 'deb https://mirrors.ustc.edu.cn/deepin/beige beige main commercial community' > /etc/apt/sources.list && \ 7 | apt-get update && \ 8 | apt-get install -y --no-install-recommends \ 9 | ca-certificates \ 10 | curl \ 11 | gcc-13 \ 12 | make \ 13 | autoconf \ 14 | automake \ 15 | libtool \ 16 | pkg-config 17 | 18 | WORKDIR /root 19 | RUN curl -LO https://github.com/libffi/libffi/releases/download/v${LIBFFI_VERSION}/libffi-${LIBFFI_VERSION}.tar.gz && \ 20 | tar xf libffi-${LIBFFI_VERSION}.tar.gz 21 | 22 | RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 \ 23 | --slave /usr/bin/g++ g++ /usr/bin/g++-13 \ 24 | --slave /usr/bin/gcov gcov /usr/bin/gcov-13 \ 25 | --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-13 \ 26 | --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-13 27 | 28 | WORKDIR /root/build 29 | RUN /root/libffi-${LIBFFI_VERSION}/configure \ 30 | CFLAGS="-mcmodel=medium" \ 31 | --prefix=/root/build/out \ 32 | --enable-pax_emutramp \ 33 | --enable-static \ 34 | --disable-docs && \ 35 | make libffi_convenience.la && \ 36 | tar czf libffi.tar.gz --directory=.libs . -------------------------------------------------------------------------------- /dockerfiles/Dockerfile.libgcc: -------------------------------------------------------------------------------- 1 | FROM linuxdeepin/deepin:beige-loong64-v1.4.0 2 | 3 | ARG GCC_VERSION="13.3.0" 4 | 5 | ENV DEBIAN_FRONTEND=noninteractive 6 | RUN echo 'deb https://mirrors.ustc.edu.cn/deepin/beige beige main commercial community' > /etc/apt/sources.list && \ 7 | apt-get update && \ 8 | apt-get install -y --no-install-recommends \ 9 | ca-certificates \ 10 | curl \ 11 | flex \ 12 | gawk \ 13 | bzip2 \ 14 | binutils \ 15 | build-essential \ 16 | libgmp-dev \ 17 | libmpfr-dev \ 18 | libmpc-dev \ 19 | libisl-dev 20 | 21 | WORKDIR /root 22 | RUN curl -LO https://github.com/gcc-mirror/gcc/archive/refs/tags/releases/gcc-${GCC_VERSION}.tar.gz && \ 23 | tar xf gcc-* 24 | 25 | WORKDIR /root/build 26 | RUN /root/gcc-releases-gcc-*/configure \ 27 | -v \ 28 | --prefix=/root/build \ 29 | --enable-languages=c \ 30 | --disable-multilib \ 31 | --disable-bootstrap \ 32 | CC="gcc" CXX="g++" CFLAGS="-g -O2 -mcmodel=medium" CXXFLAGS="-g -O2 -mcmodel=medium" && \ 33 | make -j1 V=s all-target-libgcc MAKEINFO=missing && \ 34 | make install-target-libgcc && \ 35 | tar czf libgcc.tar.gz --directory=lib . 36 | -------------------------------------------------------------------------------- /dockerfiles/Dockerfile.llvm: -------------------------------------------------------------------------------- 1 | FROM linuxdeepin/deepin:beige-25-loong64-v1.5.0 2 | 3 | ARG LLVM_TAG="llvmorg-20.1.5" 4 | 5 | ENV DEBIAN_FRONTEND=noninteractive 6 | RUN echo 'deb https://mirrors.ustc.edu.cn/deepin/beige beige main commercial community' > /etc/apt/sources.list && \ 7 | apt-get update && \ 8 | apt-get install -y --no-install-recommends \ 9 | ca-certificates \ 10 | curl \ 11 | make \ 12 | pkg-config \ 13 | ninja \ 14 | libffi-dev \ 15 | build-essential \ 16 | cmake \ 17 | binutils-dev \ 18 | libxml2 \ 19 | libedit2 \ 20 | libffi8 21 | 22 | WORKDIR /root 23 | ENV CPP_TRIPLE=loongarch64-linux-gnu CFLAGS="-target loongarch64-linux-gnu -mcmodel=medium" CXXFLAGS="-target loongarch64-linux-gnu -mcmodel=medium" 24 | ADD https://github.com/llvm/llvm-project/archive/refs/tags/${LLVM_TAG}.tar.gz . 25 | RUN tar xf ${LLVM_TAG}.tar.gz && \ 26 | cmake /root/llvm-project/llvm \ 27 | -DCMAKE_BUILD_TYPE=Release \ 28 | -DLLVM_BUILD_LLVM_DYLIB=ON \ 29 | -DLLVM_DYLIB_EXPORT_ALL=ON \ 30 | -DLLVM_LINK_LLVM_DYLIB=ON \ 31 | -DLLVM_ENABLE_RTTI=ON \ 32 | -DLLVM_ENABLE_FFI=ON \ 33 | -DLLVM_BUILD_DOCS=OFF \ 34 | -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \ 35 | -DFFI_INCLUDE_DIR="$(pkg-config --variable=includedir libffi)" \ 36 | -DLLVM_BINUTILS_INCDIR=/usr/include \ 37 | -DLLVM_INSTALL_UTILS=ON \ 38 | -DLLVM_INCLUDE_TESTS=OFF \ 39 | -DLIBOMPTARGET_ENABLE_DEBUG=ON \ 40 | -DOPENMP_ENABLE_LIBOMP_PROFILING=ON \ 41 | -DLLVM_ENABLE_PROJECTS="clang;lld;lldb;clang-tools-extra;mlir;bolt;flang;libclc" \ 42 | -DLLVM_ENABLE_RUNTIMES="libunwind;libcxx;libcxxabi;compiler-rt;offload;openmp;pstl" \ 43 | -DLLVM_USE_LINKER=bfd \ 44 | -DLLVM_PARALLEL_LINK_JOBS=2 \ 45 | -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-20 \ 46 | -DLLVM_DEFAULT_TARGET_TRIPLE=${CPP_TRIPLE} \ 47 | -DLLVM_HOST_TRIPLE=${CPP_TRIPLE} \ 48 | -DCMAKE_SKIP_RPATH=NO \ 49 | -DCMAKE_SKIP_INSTALL_RPATH=NO && \ 50 | make && \ 51 | make install DESTDIR=/root/llvm-project/llvm-targets && \ 52 | tar -czf llvm-targets/llvm.tar.gz -C llvm-targets usr 53 | -------------------------------------------------------------------------------- /dockerfiles/Dockerfile.nodejs: -------------------------------------------------------------------------------- 1 | FROM linuxdeepin/deepin:beige-25-loong64-v1.5.0 2 | 3 | ARG NODEJS_VERSION="22.11.0" 4 | 5 | ENV DEBIAN_FRONTEND=noninteractive 6 | RUN echo 'deb https://mirrors.ustc.edu.cn/deepin/beige beige main commercial community' > /etc/apt/sources.list && \ 7 | apt-get update && \ 8 | apt-get install -y --no-install-recommends \ 9 | ca-certificates \ 10 | curl \ 11 | build-essential \ 12 | pkg-config \ 13 | libicu-dev \ 14 | libssl-dev \ 15 | zlib1g-dev \ 16 | python3 17 | 18 | WORKDIR /root 19 | ADD https://nodejs.org/dist/v${NODEJS_VERSION}/node-v${NODEJS_VERSION}.tar.xz . 20 | ENV NOLTO=1 21 | RUN tar xf node-v${NODEJS_VERSION}.tar.xz && \ 22 | cd node-v${NODEJS_VERSION} && \ 23 | ./configure \ 24 | --prefix=/usr \ 25 | --shared-openssl \ 26 | --shared-zlib \ 27 | --with-intl=system-icu && \ 28 | make -j32 && \ 29 | make install DESTDIR=/root/targets && \ 30 | install -Dvm755 \ 31 | /root/targets/usr/lib/node_modules/npm/bin/node-gyp-bin/node-gyp \ 32 | /root/targets/usr/bin/node-gyp 33 | sed -e 's|"`dirname "$0"`/../../|"`dirname "$0"`/../lib/node_modules/npm/|' \ 34 | -i /root/targets/usr/bin/node-gyp && \ 35 | tar -czf /root/targets/nodejs.tar.gz -C /root/targets usr 36 | -------------------------------------------------------------------------------- /patches/depot.patch: -------------------------------------------------------------------------------- 1 | diff --git a/gclient.py b/gclient.py 2 | index 72ecf74a..5ec918fc 100755 3 | --- a/gclient.py 4 | +++ b/gclient.py 5 | @@ -849,7 +849,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): 6 | # exist. 7 | logging.warning( 8 | 'GCS dependency %s new version, removing old.', name) 9 | - shutil.rmtree(gcs_deps[0].output_dir) 10 | + os.system(f'rm -rf {gcs_deps[0].output_dir}') 11 | else: 12 | url = dep_value.get('url') 13 | deps_to_add.append( 14 | -------------------------------------------------------------------------------- /patches/electron.patch: -------------------------------------------------------------------------------- 1 | diff --git a/build/args/ffmpeg.gn b/build/args/ffmpeg.gn 2 | index c25abfd25f..bfe58e4ebe 100644 3 | --- a/build/args/ffmpeg.gn 4 | +++ b/build/args/ffmpeg.gn 5 | @@ -1,7 +1,37 @@ 6 | import("//electron/build/args/all.gn") 7 | is_component_build = false 8 | is_component_ffmpeg = true 9 | -is_official_build = true 10 | -ffmpeg_branding = "Chromium" 11 | enable_dsyms = false 12 | -proprietary_codecs = false 13 | + 14 | +custom_toolchain = "//build/toolchain/linux/unbundle:default" 15 | +host_toolchain = "//build/toolchain/linux/unbundle:default" 16 | +is_clang = true 17 | +clang_base_path = "/usr" 18 | +clang_use_chrome_plugins = false 19 | +clang_version = "20" 20 | +chrome_pgo_phase = 0 21 | +is_debug = false 22 | +is_official_build = true 23 | +fatal_linker_warnings = false 24 | +treat_warnings_as_errors = false 25 | +disable_fieldtrial_testing_config = true 26 | +ffmpeg_branding = "Chrome" 27 | +proprietary_codecs = true 28 | +link_pulseaudio=true 29 | +use_cups=true 30 | +use_sysroot = false 31 | +enable_hangout_services_extension = true 32 | +enable_widevine = false 33 | +enable_nacl = false 34 | +use_vaapi = true 35 | +use_cfi_icall = false 36 | +use_ozone = true 37 | +use_system_libffi = true 38 | +is_cfi = false 39 | +ozone_platform_wayland = true 40 | +ozone_platform_x11 = true 41 | +ozone_auto_platforms = true 42 | +rustc_version = "rustc 1.88.0 (6b00bc388 2025-06-23)" 43 | +rust_sysroot_absolute = "/usr/local" 44 | +rust_bindgen_root = "/usr/lib/llvm-20" 45 | +use_lld = true 46 | diff --git a/build/args/release.gn b/build/args/release.gn 47 | index 77351cc181..99d3f970d4 100644 48 | --- a/build/args/release.gn 49 | +++ b/build/args/release.gn 50 | @@ -1,9 +1,41 @@ 51 | import("//electron/build/args/all.gn") 52 | is_component_build = false 53 | -is_official_build = true 54 | 55 | # By default, Electron builds ffmpeg with proprietary codecs enabled. In order 56 | # to facilitate users who don't want to ship proprietary codecs in ffmpeg, or 57 | # who have an LGPL requirement to ship ffmpeg as a dynamically linked library, 58 | # we build ffmpeg as a shared library. 59 | is_component_ffmpeg = true 60 | + 61 | +custom_toolchain = "//build/toolchain/linux/unbundle:default" 62 | +host_toolchain = "//build/toolchain/linux/unbundle:default" 63 | +is_clang = true 64 | +clang_base_path = "/usr" 65 | +clang_use_chrome_plugins = false 66 | +clang_version = "20" 67 | +chrome_pgo_phase = 0 68 | +is_debug = false 69 | +is_official_build = true 70 | +fatal_linker_warnings = false 71 | +treat_warnings_as_errors = false 72 | +disable_fieldtrial_testing_config = true 73 | +ffmpeg_branding = "Chrome" 74 | +proprietary_codecs = true 75 | +link_pulseaudio = true 76 | +use_cups = true 77 | +use_sysroot = false 78 | +enable_hangout_services_extension = true 79 | +enable_widevine = false 80 | +enable_nacl = false 81 | +use_vaapi = true 82 | +use_cfi_icall = false 83 | +use_ozone = true 84 | +use_system_libffi = true 85 | +is_cfi = false 86 | +ozone_platform_wayland = true 87 | +ozone_platform_x11 = true 88 | +ozone_auto_platforms = true 89 | +rustc_version = "rustc 1.88.0 (6b00bc388 2025-06-23)" 90 | +rust_sysroot_absolute = "/usr/local" 91 | +rust_bindgen_root = "/usr/lib/llvm-20" 92 | +use_lld = true 93 | diff --git a/patches/breakpad/.patches b/patches/breakpad/.patches 94 | new file mode 100644 95 | index 0000000000..5ad22e4bc5 96 | --- /dev/null 97 | +++ b/patches/breakpad/.patches 98 | @@ -0,0 +1 @@ 99 | +loong64_support_for_breakpad.patch 100 | diff --git a/patches/breakpad/loong64_support_for_breakpad.patch b/patches/breakpad/loong64_support_for_breakpad.patch 101 | new file mode 100644 102 | index 0000000000..88f8d41305 103 | --- /dev/null 104 | +++ b/patches/breakpad/loong64_support_for_breakpad.patch 105 | @@ -0,0 +1,43 @@ 106 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 107 | +From: darkyzhou 108 | +Date: Sun, 27 Jul 2025 07:38:27 +0000 109 | +Subject: loong64 support for breakpad 110 | + 111 | + 112 | +diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc 113 | +index f0680a959c0fe71e9f1e404eb33155e42e0c074e..b425761b110a883984d9c5ad68de6a2ca00421dc 100644 114 | +--- a/src/common/linux/dump_symbols.cc 115 | ++++ b/src/common/linux/dump_symbols.cc 116 | +@@ -111,6 +111,10 @@ using google_breakpad::wasteful_vector; 117 | + #define EM_AARCH64 183 118 | + #endif 119 | + 120 | ++#ifdef EM_LOONGARCH 121 | ++#define EM_LOONGARCH 258 122 | ++#endif 123 | ++ 124 | + // Define ZStd compression if host machine does not include this define. 125 | + #ifndef ELFCOMPRESS_ZSTD 126 | + #define ELFCOMPRESS_ZSTD 2 127 | +@@ -1119,6 +1123,7 @@ const char* ElfArchitecture(const typename ElfClass::Ehdr* elf_header) { 128 | + case EM_X86_64: return "x86_64"; 129 | + case EM_RISCV: return "riscv"; 130 | + case EM_NDS32: return "nds32"; 131 | ++ case EM_LOONGARCH: return "loongarch64"; 132 | + default: return nullptr; 133 | + } 134 | + } 135 | +diff --git a/src/common/linux/memory_mapped_file.cc b/src/common/linux/memory_mapped_file.cc 136 | +index 5e54aca5a06569d83cb248e9b5ca7d96930e5c01..203a5174a3ac1b1c2d3b9d147703730001678502 100644 137 | +--- a/src/common/linux/memory_mapped_file.cc 138 | ++++ b/src/common/linux/memory_mapped_file.cc 139 | +@@ -72,7 +72,8 @@ bool MemoryMappedFile::Map(const char* path, size_t offset) { 140 | + 141 | + #if defined(__x86_64__) || defined(__aarch64__) || \ 142 | + (defined(__mips__) && _MIPS_SIM == _ABI64) || \ 143 | +- (defined(__riscv) && __riscv_xlen == 64) 144 | ++ (defined(__riscv) && __riscv_xlen == 64) || \ 145 | ++ (defined(__loongarch__) && __loongarch_grlen == 64) 146 | + 147 | + struct kernel_stat st; 148 | + if (sys_fstat(fd, &st) == -1 || st.st_size < 0) { 149 | diff --git a/patches/config.json b/patches/config.json 150 | index 566515a8b1..d2f133044e 100644 151 | --- a/patches/config.json 152 | +++ b/patches/config.json 153 | @@ -15,5 +15,6 @@ 154 | { "patch_dir": "src/electron/patches/sqlite", "repo": "src/third_party/sqlite/src" }, 155 | { "patch_dir": "src/electron/patches/skia", "repo": "src/third_party/skia" }, 156 | { "patch_dir": "src/electron/patches/swiftshader", "repo": "src/third_party/swiftshader" }, 157 | - { "patch_dir": "src/electron/patches/xnnpack", "repo": "src/third_party/xnnpack/src" } 158 | + { "patch_dir": "src/electron/patches/xnnpack", "repo": "src/third_party/xnnpack/src" }, 159 | + { "patch_dir": "src/electron/patches/breakpad", "repo": "src/third_party/breakpad/breakpad" } 160 | ] 161 | diff --git a/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc b/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc 162 | index b9ebc391e7..4721c3234c 100644 163 | --- a/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc 164 | +++ b/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc 165 | @@ -68,6 +68,8 @@ bool ElectronRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) { 166 | info->arch = extensions::api::runtime::PlatformArch::kX86_32; 167 | } else if (arch == "x64") { 168 | info->arch = extensions::api::runtime::PlatformArch::kX86_64; 169 | + } else if (arch == "loongarch64") { 170 | + info->arch = extensions::api::runtime::PlatformArch::kLoongarch64; 171 | } else { 172 | NOTREACHED(); 173 | } 174 | @@ -80,6 +82,8 @@ bool ElectronRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) { 175 | info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kX86_32; 176 | } else if (nacl_arch == "x86-64") { 177 | info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kX86_64; 178 | + } else if (nacl_arch == "loongarch64") { 179 | + info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kLoongarch64; 180 | } else { 181 | NOTREACHED(); 182 | } 183 | -------------------------------------------------------------------------------- /scripts/binaries.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | source "$SCRIPT_DIR/env.sh" 7 | 8 | pushd "$ROOT_PATH"/src 9 | cp /usr/bin/node third_party/node/linux/node-linux-x64/bin/node 10 | 11 | chmod +w third_party/devtools-frontend/src/third_party/esbuild/esbuild 12 | cp /usr/lib/node_modules/@esbuild/linux-loong64/bin/esbuild third_party/devtools-frontend/src/third_party/esbuild/esbuild 13 | popd -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | source "$SCRIPT_DIR/env.sh" 7 | 8 | SKIP_GEN=false 9 | for arg in "$@"; do 10 | case $arg in 11 | --build) 12 | SKIP_GEN=true 13 | shift 14 | ;; 15 | *) 16 | ;; 17 | esac 18 | done 19 | 20 | rm -f "$OUT_PATH"/electron 21 | pushd "$SRC_PATH" 22 | if [ "$SKIP_GEN" = false ]; then 23 | gn gen "$OUT_PATH" \ 24 | --args="import(\"//electron/build/args/release.gn\")" \ 25 | --script-executable=/usr/bin/python3 \ 26 | --no-check 27 | fi 28 | ninja -C "$OUT_PATH" electron 29 | popd -------------------------------------------------------------------------------- /scripts/commit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | source "$SCRIPT_DIR/env.sh" 7 | 8 | pushd "$ROOT_PATH/src" 9 | 10 | git add . 11 | git restore --staged $(git submodule status | cut -d' ' -f2) 12 | git commit -m "loong64 support for chromium 13 | 14 | Co-authored-by: Jiajie Chen " 15 | npx e patches chromium 16 | 17 | UPDATED_MODULES=$(git submodule foreach --quiet 'if [ -n "$(git status --porcelain)" ]; then echo "$path"; fi') 18 | 19 | for module in $UPDATED_MODULES; do 20 | pushd "$module" 21 | 22 | name=$(echo "$module" | sed -n 's/.*third_party\/\([^/]*\).*/\1/p') 23 | echo "$module -> $name" 24 | 25 | git add . 26 | git commit -m "loong64 support for $name 27 | 28 | Co-authored-by: Jiajie Chen " 29 | 30 | npx e patches "$name" 31 | 32 | read -n 1 -s -r -p "Press any key to continue..." 33 | 34 | popd 35 | done 36 | 37 | popd 38 | -------------------------------------------------------------------------------- /scripts/env.sh: -------------------------------------------------------------------------------- 1 | 2 | # Path to the local electron repository 3 | export REPO_PATH="/home/builduser/electron-loong64" 4 | 5 | # `.electron_build_tools` directory will by default locates at the home directory 6 | export DEPOT_PATH="/home/builduser/.electron_build_tools/third_party/depot_tools" 7 | 8 | # Path to the build root directory 9 | export ROOT_PATH="/home/builduser/buildroot" 10 | 11 | # Path to the build `src` directory 12 | export SRC_PATH="$ROOT_PATH/src" 13 | 14 | # Path to the build output directory 15 | export OUT_PATH="$SRC_PATH/out/Release" 16 | 17 | # Electron repository 18 | export ELECTRON_REPO="https://github.com/electron/electron.git" 19 | 20 | # The version to build 21 | export ELECTRON_VERSION="37.2.5" 22 | 23 | # Path to the release output directory 24 | export RELEASE_PATH="$ROOT_PATH/release/$ELECTRON_VERSION" 25 | 26 | # The rollup version to use in rollup.sh 27 | export ROLLUP_VERSION="4.32.0" 28 | 29 | # For compiling electron 30 | export CC=clang CXX=clang++ AR=ar NM=nm RUSTC_BOOTSTRAP=1 -------------------------------------------------------------------------------- /scripts/export.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | source "$SCRIPT_DIR/env.sh" 7 | 8 | pushd "$SRC_PATH" 9 | 10 | # Add all changes to staging area 11 | git add . 12 | 13 | # Exclude submodules since electron build tools might ignore them 14 | git restore --staged $(git submodule status | cut -d' ' -f2) 15 | 16 | # Commit changes in the main repository 17 | git commit -m "loong64 support 18 | 19 | Co-authored-by: Jiajie Chen " || echo "No changes to commit in main repository" 20 | 21 | # Export patches for chromium (main repository) 22 | npx e patches chromium 23 | 24 | # Handle submodules that have changes 25 | echo "Checking submodules for changes..." 26 | CHANGED_SUBMODULES=() 27 | 28 | # Collect submodules with changes 29 | while IFS= read -r submodule_name; do 30 | if [ -n "$(git -C "$submodule_name" status --porcelain)" ]; then 31 | echo "Changes found in submodule: $submodule_name" 32 | git -C "$submodule_name" add . 33 | git -C "$submodule_name" commit -m "loong64 support 34 | 35 | Co-authored-by: Jiajie Chen " || echo "No changes to commit in submodule: $submodule_name" 36 | CHANGED_SUBMODULES+=("$submodule_name") 37 | fi 38 | done < <(git submodule status | cut -d' ' -f2) 39 | 40 | # Print the list of changed submodules 41 | echo "" 42 | echo "=== Summary of changed submodules ===" 43 | if [ ${#CHANGED_SUBMODULES[@]} -eq 0 ]; then 44 | echo "No submodules have changes." 45 | else 46 | echo "The following submodules have changes:" 47 | for submodule in "${CHANGED_SUBMODULES[@]}"; do 48 | echo " - $submodule" 49 | done 50 | fi 51 | 52 | popd -------------------------------------------------------------------------------- /scripts/extract.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | 4 | usage() { 5 | echo "Usage: $0 [local-path]" 6 | exit 1 7 | } 8 | 9 | [[ $# -lt 2 ]] && usage 10 | 11 | IMAGE="$1" 12 | IN_PATH="$2" 13 | OUT_PATH="${3:-$(basename "$IN_PATH")}" # default to file name in cwd 14 | 15 | # make OUT_PATH absolute and ensure parent dir exists 16 | OUT_PATH="$(realpath -m "$OUT_PATH")" 17 | mkdir -p "$(dirname "$OUT_PATH")" 18 | 19 | # extract 20 | docker run --rm \ 21 | -v "$OUT_PATH":/out \ 22 | "$IMAGE" \ 23 | sh -c "cp -r '$IN_PATH' /out/" 24 | 25 | echo "Extracted to: $OUT_PATH" 26 | -------------------------------------------------------------------------------- /scripts/package.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | source "$SCRIPT_DIR/env.sh" 7 | 8 | function main() { 9 | local function_name=${1:-package} 10 | 11 | if [[ "$(type -t ${function_name})" != "function" ]]; then 12 | echo "Error: Function '${function_name}' not found" 13 | exit 1 14 | fi 15 | 16 | ${function_name} 17 | } 18 | 19 | function package() { 20 | pushd "$ROOT_PATH"/src 21 | echo ">>> Package Debug Symbols and Strip Binaries <<<" 22 | 23 | rm -rf "$OUT_PATH"/breakpad_symbols 24 | 25 | electron/script/copy-debug-symbols.py -d "$OUT_PATH" --out-dir="$OUT_PATH"/debug --compress 26 | electron/script/strip-binaries.py -d "$OUT_PATH" --verbose 27 | electron/script/add-debug-link.py -d "$OUT_PATH" --debug-dir="$OUT_PATH"/debug 28 | 29 | ninja -C "$OUT_PATH" electron:licenses 30 | ninja -C "$OUT_PATH" electron:electron_version_file 31 | DELETE_DSYMS_AFTER_ZIP=1 electron/script/zip-symbols.py -b "$OUT_PATH" 32 | 33 | rm -rf "$RELEASE_PATH" 34 | mkdir -p "$RELEASE_PATH" 35 | mv "$OUT_PATH"/debug.zip "$RELEASE_PATH"/electron-v$ELECTRON_VERSION-linux-loong64-debug.zip 36 | mv "$OUT_PATH"/symbols.zip "$RELEASE_PATH"/electron-v$ELECTRON_VERSION-linux-loong64-symbols.zip 37 | 38 | echo ">>> Package Electron <<<" 39 | 40 | ninja -C "$OUT_PATH" electron:electron_dist_zip 41 | mv "$OUT_PATH"/dist.zip "$RELEASE_PATH"/electron-v$ELECTRON_VERSION-linux-loong64.zip 42 | 43 | popd 44 | 45 | build_mksnapshot 46 | } 47 | 48 | function build_mksnapshot() { 49 | pushd "$ROOT_PATH"/src 50 | echo ">>> Build Mksnapshot <<<" 51 | 52 | ninja -C "$OUT_PATH" electron:electron_mksnapshot 53 | gn desc "$OUT_PATH" v8:run_mksnapshot_default args > "$OUT_PATH"/mksnapshot_args 54 | 55 | # Remove unused args from mksnapshot_args 56 | sed -i '/.*builtins-pgo/d' "$OUT_PATH"/mksnapshot_args 57 | sed -i '/--turbo-profiling-input/d' "$OUT_PATH"/mksnapshot_args 58 | electron/script/strip-binaries.py --file "$OUT_PATH"/mksnapshot --verbose 59 | electron/script/strip-binaries.py --file "$OUT_PATH"/v8_context_snapshot_generator --verbose 60 | 61 | ninja -C "$OUT_PATH" electron:electron_mksnapshot_zip 62 | cd "$OUT_PATH" 63 | zip mksnapshot.zip mksnapshot_args gen/v8/embedded.S 64 | mv "$OUT_PATH"/mksnapshot.zip "$RELEASE_PATH"/mksnapshot-v$ELECTRON_VERSION-linux-loong64.zip 65 | 66 | popd 67 | 68 | chromedriver 69 | } 70 | 71 | function chromedriver() { 72 | pushd "$ROOT_PATH"/src 73 | echo ">>> Build Chromedriver <<<" 74 | EU_STRIP_PATH="$ROOT_PATH"/src/buildtools/third_party/eu-strip/bin/eu-strip 75 | rm -rf "$EU_STRIP_PATH" 76 | ln -sv `which eu-strip` "$EU_STRIP_PATH" 77 | 78 | ninja -C "$OUT_PATH" electron:electron_chromedriver 79 | ninja -C "$OUT_PATH" electron:electron_chromedriver_zip 80 | mv "$OUT_PATH"/chromedriver.zip "$RELEASE_PATH"/chromedriver-v$ELECTRON_VERSION-linux-loong64.zip 81 | 82 | popd 83 | nodejs 84 | } 85 | 86 | function nodejs() { 87 | pushd "$ROOT_PATH"/src 88 | 89 | echo ">>> Build Node.js headers <<<" 90 | ELECTRON_OUT_DIR=Release ninja -C "$OUT_PATH" electron:node_headers 91 | mv "$OUT_PATH"/gen/node_headers.tar.gz "$RELEASE_PATH"/node-v$ELECTRON_VERSION-headers.tar.gz 92 | 93 | popd 94 | ffmpeg 95 | } 96 | 97 | function ffmpeg() { 98 | pushd "$ROOT_PATH"/src 99 | 100 | echo ">>> Build ffmpeg <<<" 101 | gn gen "$OUT_PATH"/ffmpeg --args="import(\"//electron/build/args/ffmpeg.gn\")" --script-executable=/usr/bin/python3 102 | ninja -C "$OUT_PATH"/ffmpeg electron:electron_ffmpeg_zip 103 | mv "$OUT_PATH"/ffmpeg/ffmpeg.zip "$RELEASE_PATH"/ffmpeg-v$ELECTRON_VERSION-linux-loong64.zip 104 | 105 | popd 106 | hunspell 107 | } 108 | 109 | function hunspell() { 110 | pushd "$ROOT_PATH"/src 111 | 112 | echo ">>> Build hunspell <<<" 113 | ninja -C "$OUT_PATH" electron:hunspell_dictionaries_zip 114 | mv "$OUT_PATH"/hunspell_dictionaries.zip "$RELEASE_PATH"/hunspell-dictionaries.zip 115 | 116 | popd 117 | libcxx 118 | } 119 | 120 | function libcxx() { 121 | pushd "$ROOT_PATH"/src 122 | 123 | echo ">>> Build libcxx <<<" 124 | ninja -C "$OUT_PATH" electron:libcxx_headers_zip 125 | ninja -C "$OUT_PATH" electron:libcxxabi_headers_zip 126 | ninja -C "$OUT_PATH" electron:libcxx_objects_zip 127 | mv "$OUT_PATH"/libcxx_headers.zip "$RELEASE_PATH"/libcxx-headers.zip 128 | mv "$OUT_PATH"/libcxxabi_headers.zip "$RELEASE_PATH"/libcxxabi-headers.zip 129 | mv "$OUT_PATH"/libcxx_objects.zip "$RELEASE_PATH"/libcxx-objects-v$ELECTRON_VERSION-linux-loong64.zip 130 | 131 | popd 132 | shasum256 133 | } 134 | 135 | function shasum256() { 136 | pushd "$RELEASE_PATH" 137 | 138 | rm -f SHASUMS256.txt 139 | for file in *; do 140 | checksum=$(sha256sum "$file" | cut -d ' ' -f 1) 141 | echo "$checksum *$file" >> SHASUMS256.txt 142 | done 143 | 144 | popd 145 | } 146 | 147 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then 148 | main "$@" 149 | fi 150 | -------------------------------------------------------------------------------- /scripts/patch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | source "$SCRIPT_DIR/env.sh" 7 | 8 | pushd "$ROOT_PATH/src/electron" 9 | 10 | git reset --hard HEAD && git clean -fd && git checkout v$ELECTRON_VERSION 11 | git apply --reject "$REPO_PATH"/patches/chromium.patch 12 | git add . 13 | git commit -m "chromium.patch" --no-verify 14 | git apply --reject "$REPO_PATH"/patches/electron.patch 15 | git add . 16 | git commit -m "electron.patch" --no-verify 17 | 18 | popd 19 | 20 | -------------------------------------------------------------------------------- /scripts/reset.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | source "$SCRIPT_DIR/env.sh" 7 | 8 | pushd "$ROOT_PATH" 9 | 10 | git -C src clean -fd || true; git -C src am --abort || true; git -C src reset --hard HEAD; 11 | git -C src submodule foreach 'git clean -fd || true; git am --abort || true; git reset --hard HEAD'; 12 | git -C src/electron clean -fd || true; git -C src/electron reset --hard HEAD; 13 | 14 | popd 15 | -------------------------------------------------------------------------------- /scripts/rollup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | source "$SCRIPT_DIR/env.sh" 7 | 8 | # Shamelessly copied from https://github.com/lcpu-club/loongarch-packages/blob/master/electron34/loong.patch 9 | 10 | pushd "$ROOT_PATH"/src/third_party/node 11 | sed -i -e 's/@rollup/rollup/' -e "s/'wasm-node',//" node_modules.py 12 | jq ".dependencies.rollup=\"$ROLLUP_VERSION\"" package.json > package.json.new 13 | mv package.json{.new,} 14 | ./update_npm_deps 15 | popd 16 | 17 | pushd "$ROOT_PATH"/src/third_party/devtools-frontend/src 18 | sed -i -e 's/@rollup/rollup/' -e "s/'wasm-node',//" scripts/devtools_paths.py 19 | jq ".devDependencies.rollup=\"$ROLLUP_VERSION\" | .devDependencies.\"@rollup/rollup-linux-loongarch64-gnu\"=\"$ROLLUP_VERSION\"" package.json > package.json.new 20 | mv package.json{.new,} 21 | 22 | # Chromium hosts a custom registry at https://npm.skia.org/chrome-devtools/ and rejects some packages: 23 | # Package fs-extra with version 11.3.0 was created 108h0m0s time ago. This is less than 1 week and so failed the audit. 24 | sed -i /registry/d .npmrc 25 | 26 | # Replace direct invocation of wasm rollup 27 | sed -i 's\@rollup/wasm-node\rollup\' \ 28 | inspector_overlay/BUILD.gn \ 29 | front_end/models/live-metrics/web-vitals-injected/BUILD.gn \ 30 | front_end/Images/BUILD.gn \ 31 | front_end/panels/recorder/injected/BUILD.gn \ 32 | scripts/build/ninja/bundle.gni 33 | 34 | python3 scripts/deps/manage_node_deps.py 35 | popd -------------------------------------------------------------------------------- /scripts/sync.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | source "$SCRIPT_DIR/env.sh" 7 | 8 | pushd "$ROOT_PATH" 9 | 10 | git -C "$DEPOT_PATH" reset --hard HEAD 11 | 12 | if ! npx e sync --three-way -f; then 13 | # Workaround for a strange Python error: "Cannot call rmtree on a symbolic link" 14 | git -C "$DEPOT_PATH" apply "$REPO_PATH/patches/depot.patch" 15 | npx e sync --three-way -f 16 | fi 17 | 18 | popd 19 | -------------------------------------------------------------------------------- /scripts/update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ex 4 | 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 6 | source "$SCRIPT_DIR/env.sh" 7 | 8 | pushd "$ROOT_PATH" 9 | 10 | if [ ! -d "src/electron" ]; then 11 | npx e init -i release -r "$ROOT_PATH" electron-loong64 12 | git clone "$ELECTRON_REPO" src/electron 13 | fi 14 | 15 | git -C src clean -fd || true; git -C src am --abort || true; git -C src reset --hard HEAD; 16 | git -C src submodule foreach 'git clean -fd || true; git am --abort || true; git reset --hard HEAD'; 17 | 18 | git -C src/electron clean -fd || true; git -C src/electron reset --hard HEAD; 19 | git -C src/electron remote set-url origin "$ELECTRON_REPO" 20 | git -C src/electron fetch origin --tags 21 | git -C src/electron switch --detach "v$ELECTRON_VERSION" 22 | 23 | popd 24 | --------------------------------------------------------------------------------