diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c178578..9516d54 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,9 +1,13 @@ on: - release: - types: [created] + push: + branches: + - fix-build jobs: build: - runs-on: ubuntu-16.04 + runs-on: ubuntu-18.04 + strategy: + matrix: + arch: ['x64'] steps: - uses: actions/setup-node@master with: @@ -12,15 +16,16 @@ jobs: uses: actions/setup-python@v1 with: python-version: 3.8 + - name: Ubuntu dependencies - run: sudo apt-get install libgtk-3-dev + run: sudo apt-get install libgtk-3-dev g++ build-essential ninja-build gcc-aarch64-linux-gnu g++-aarch64-linux-gnu build-essential autoconf libtool cmake pkg-config git python-dev swig3.0 libpcre3-dev nodejs-dev - uses: actions/checkout@v2 with: ref: ${{ github.ref }} - name: Build Qode binary - run: node build.js + run: TARGET_ARCH=${{ matrix.arch }} node build.js env: SYNC_GIT_SUBMODULE: 1 @@ -28,20 +33,20 @@ jobs: uses: a7ul/tar-action@v1.0.2 with: command: c - cwd: ./node/out/Release + cwd: ./out/Release files: | ./qode - outPath: qode-linux-x64-${{github.event.release.tag_name}}.tar.gz + outPath: qode-linux-${{ matrix.arch }}-test.tar.gz - uses: actions/upload-artifact@v1 with: - name: qode-linux-x64-${{github.event.release.tag_name}}.tar.gz - path: qode-linux-x64-${{github.event.release.tag_name}}.tar.gz + name: qode-linux-${{ matrix.arch }}-test.tar.gz + path: qode-linux-${{ matrix.arch }}-test.tar.gz - - name: Release - uses: softprops/action-gh-release@master - with: - files: qode-linux-x64-${{github.event.release.tag_name}}.tar.gz - tag_name: ${{ github.event.release.tag_name }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Release + # uses: softprops/action-gh-release@master + # with: + # files: qode-linux-${{ matrix.arch }}-test.tar.gz + # tag_name: ${{ github.event.release.tag_name }} + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index b5f69fc..295b752 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -1,6 +1,7 @@ on: - release: - types: [created] + push: + branches: + - fix-build2 jobs: build: runs-on: macos-latest @@ -19,7 +20,10 @@ jobs: - uses: actions/checkout@v2 with: ref: ${{ github.ref }} - + + - name: Install dependencies + run: brew install ninja + - name: Build Qode binary run: TARGET_ARCH=${{ matrix.arch }} node build.js env: @@ -29,20 +33,20 @@ jobs: uses: a7ul/tar-action@v1.0.2 with: command: c - cwd: ./node/out/Release + cwd: ./out/Release files: | ./qode - outPath: qode-darwin-${{ matrix.arch }}-${{github.event.release.tag_name}}.tar.gz + outPath: qode-darwin-${{ matrix.arch }}-test.tar.gz - uses: actions/upload-artifact@v1 with: - name: qode-darwin-${{ matrix.arch }}-${{github.event.release.tag_name}}.tar.gz - path: qode-darwin-${{ matrix.arch }}-${{github.event.release.tag_name}}.tar.gz + name: qode-darwin-${{ matrix.arch }}-test.tar.gz + path: qode-darwin-${{ matrix.arch }}-test.tar.gz - - name: Release - uses: softprops/action-gh-release@master - with: - files: qode-darwin-${{ matrix.arch }}-${{github.event.release.tag_name}}.tar.gz - tag_name: ${{ github.event.release.tag_name }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Release + # uses: softprops/action-gh-release@master + # with: + # files: qode-darwin-${{ matrix.arch }}-test.tar.gz + # tag_name: ${{ github.event.release.tag_name }} + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index a0b3735..45c1870 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,9 +1,10 @@ on: - release: - types: [created] + push: + branches: + - fix-build2 jobs: build: - runs-on: windows-2016 + runs-on: windows-2019 steps: - uses: actions/setup-node@master with: @@ -14,6 +15,9 @@ jobs: python-version: 3.8 - name: "Setup NASM for windows" uses: ilammy/setup-nasm@v1 + + - name: "Install deps" + run: choco install ninja - uses: actions/checkout@v2 with: @@ -29,22 +33,22 @@ jobs: id: compress with: command: c - cwd: ./node/out/Release + cwd: ./out/Release files: | ./qode.exe ./qode.lib ./qode.exp - outPath: qode-win32-x64-${{github.event.release.tag_name}}.tar.gz + outPath: qode-win32-x64-test.tar.gz - uses: actions/upload-artifact@v1 with: - name: qode-win32-x64-${{github.event.release.tag_name}}.tar.gz - path: qode-win32-x64-${{github.event.release.tag_name}}.tar.gz + name: qode-win32-x64-test.tar.gz + path: qode-win32-x64-test.tar.gz - - name: Release - uses: softprops/action-gh-release@master - with: - files: qode-win32-x64-${{github.event.release.tag_name}}.tar.gz - tag_name: ${{ github.event.release.tag_name }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Release + # uses: softprops/action-gh-release@master + # with: + # files: qode-win32-x64-test.tar.gz + # tag_name: ${{ github.event.release.tag_name }} + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 47098e8..0526145 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.swp /out +/out2 .vscode *.vcproj arch.gypi \ No newline at end of file diff --git a/build.js b/build.js index 6cd5c4e..1ba30fa 100755 --- a/build.js +++ b/build.js @@ -2,8 +2,8 @@ const path = require("path"); const os = require("os"); -const cp = require('child_process'); -const fs = require('fs'); +const cp = require("child_process"); +const fs = require("fs"); const HOST_ARCH = os.arch(); //================================== @@ -44,51 +44,83 @@ if (process.env.SYNC_GIT_SUBMODULE) { } // Find out where VS is installed. -if (process.platform === 'win32') { - const vswhere = path.join(process.env['ProgramFiles(x86)'], 'Microsoft Visual Studio', 'Installer', 'vswhere.exe') - const args = ['-format', 'json'] - const result = JSON.parse(String(cp.execFileSync(vswhere, args))) - if (result.length == 0) - throw new Error('Unable to find Visual Studio') - const vs = result[0] - process.env.GYP_MSVS_VERSION = vs.displayName.match(/(\d+)$/)[1] - process.env.GYP_MSVS_OVERRIDE_PATH = vs.installationPath +if (process.platform === "win32") { + const vswhere = path.join( + process.env["ProgramFiles(x86)"], + "Microsoft Visual Studio", + "Installer", + "vswhere.exe" + ); + const args = ["-format", "json"]; + const result = JSON.parse(String(cp.execFileSync(vswhere, args))); + if (result.length == 0) throw new Error("Unable to find Visual Studio"); + const vs = result[0]; + process.env.GYP_MSVS_VERSION = vs.displayName.match(/(\d+)$/)[1]; + process.env.GYP_MSVS_OVERRIDE_PATH = vs.installationPath; } // Required for cross compilation on macOS. -if (host_arch !== target_arch && process.platform === 'darwin') { - process.env.GYP_CROSSCOMPILE = '1' +if (host_arch !== target_arch && ["darwin"].includes(process.platform)) { + function archConvert(arch = "arm64") { + if (arch === "arm64") { + return "arm64"; + } + return "x86_64"; + } + process.env.GYP_CROSSCOMPILE = "1"; + const compileTargetArch = archConvert(target_arch); + const compileHostArch = archConvert(host_arch); Object.assign(process.env, { - CC: `cc -arch ${target_arch}`, - CXX: `c++ -arch ${target_arch}`, - CC_target: `cc -arch ${target_arch}`, - CXX_target: `c++ -arch ${target_arch}`, - CC_host: 'cc -arch x86_64', - CXX_host: 'c++ -arch x86_64', - }) + CC: `cc -arch ${compileTargetArch}`, + CXX: `c++ -arch ${compileTargetArch}`, + CC_target: `cc -arch ${compileTargetArch}`, + CXX_target: `c++ -arch ${compileTargetArch}`, + CC_host: `cc -arch ${compileHostArch}`, + CXX_host: `c++ -arch ${compileHostArch}`, + }); } +// Required for cross compilation on linux. +if (host_arch !== target_arch && ["linux"].includes(process.platform)) { + process.env.GYP_CROSSCOMPILE = "1"; + Object.assign(process.env, { + CC: `aarch64-linux-gnu-gcc`, + CXX: `aarch64-linux-gnu-g++`, + CC_target: `aarch64-linux-gnu-gcc`, + CXX_target: `aarch64-linux-gnu-g++`, + CC_host: `gcc`, + CXX_host: `g++`, + }); +} // Generate some dynamic gyp files. -execSync(`python3 configure --with-intl=small-icu --openssl-no-asm --dest-cpu=${target_arch}`, { - cwd: "node" -}); +execSync( + `python3 configure --with-intl=small-icu --openssl-no-asm --dest-cpu=${target_arch}`, + { + cwd: "node", + } +); // Update the build configuration. const config = { variables: { target_arch, host_arch, - want_separate_host_toolset: host_arch === target_arch ? 0 : 1 - } -} -if (process.platform === 'darwin') { + want_separate_host_toolset: host_arch === target_arch ? 0 : 1, + }, +}; +if (process.platform === "darwin") { // Set SDK version to the latest installed. - const sdks = String(execSync('xcodebuild -showsdks', {stdio: null})).trim() - const SDKROOT = sdks.match(/-sdk (macosx\d+\.\d+)/)[1] - config.xcode_settings = {SDKROOT} + const sdks = String(execSync("xcodebuild -showsdks", { stdio: null })).trim(); + const SDKROOT = sdks.match(/-sdk (macosx\d+\.\d+)/)[1]; + config.xcode_settings = { SDKROOT }; } -fs.writeFileSync(path.join(__dirname, 'arch.gypi'), JSON.stringify(config, null, ' ')) -execSync('python3 node/tools/gyp/gyp_main.py qode.gyp --no-parallel -f ninja -Iarch.gypi -Icommon.gypi --depth .') +fs.writeFileSync( + path.join(__dirname, "arch.gypi"), + JSON.stringify(config, null, " ") +); +execSync( + "python3 node/tools/gyp/gyp_main.py qode.gyp --no-parallel -f ninja -Iarch.gypi -Icommon.gypi --depth ." +); // Build. const epath = `${path.join("..", "bin", "ninja")}${path.delimiter}${ @@ -96,5 +128,5 @@ const epath = `${path.join("..", "bin", "ninja")}${path.delimiter}${ }`; execSync(`ninja -j${os.cpus().length} -C out/Release qode`, { - env: { PATH: epath } + env: { PATH: epath }, }); diff --git a/node b/node index af564e0..9aaac5c 160000 --- a/node +++ b/node @@ -1 +1 @@ -Subproject commit af564e0ab09f43cda3b4838a5e5d582241718269 +Subproject commit 9aaac5c2c309cea8bec473178efdd1dcd6f77795 diff --git a/qode.gyp b/qode.gyp index 4a49d99..8ec4bfb 100644 --- a/qode.gyp +++ b/qode.gyp @@ -97,10 +97,10 @@ 'src/integration/node_integration_linux.cc', ], 'libraries': [ - ' +#include #include namespace qode {