Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build windows
on:
push:
branches:
- main
paths:
- packages/**
- .github/workflows/build-windows.yml
pull_request:
branches:
- main
paths:
- packages/cpp.js/**
- packages/cppjs-plugin-*/**
- .github/workflows/build-windows.yml

permissions: {}
jobs:
build:
runs-on: Windows
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: pnpm install
- name: Build for windows
run: pnpm run ci:windows:build
1 change: 0 additions & 1 deletion .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
paths:
- website/**
- .github/workflows/deploy-website.yml
pull_request:

jobs:
deploy:
Expand Down
4 changes: 2 additions & 2 deletions packages/cpp.js/src/actions/getAllBridges.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { glob } from 'glob';
import findFiles from '../utils/findFiles.js';
import state from '../state/index.js';

export default function getAllBridges() {
return [
...glob.sync(`${state.config.paths.build}/bridge/*.i.cpp`, { absolute: true }),
...findFiles(`${state.config.paths.build}/bridge/*.i.cpp`),
];
}
6 changes: 3 additions & 3 deletions packages/cpp.js/src/actions/getDependLibs.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { glob } from 'glob';
import findFiles from '../utils/findFiles.js';
import state from '../state/index.js';

export default function getDependLibs() {
let dependLibs = [
...glob.sync(`${state.config.paths.build}/Source-Release/Emscripten-x86_64/dependencies/**/*.a`, { absolute: true, cwd: state.config.paths.project }),
...findFiles(`${state.config.paths.build}/Source-Release/Emscripten-x86_64/dependencies/**/*.a`, { cwd: state.config.paths.project }),
];
state.config.dependencyParameters.cmakeDepends.forEach((d) => {
if (d.export.libName) {
d.export.libName.forEach((fileName) => {
if (d.platform['Emscripten-x86_64'].ignoreLibName?.includes(fileName)) return;
dependLibs.push(...glob.sync(`${d.paths.output}/prebuilt/Emscripten-x86_64/lib/lib${fileName}.a`, { absolute: true, cwd: d.paths.project }));
dependLibs.push(...findFiles(`${d.paths.output}/prebuilt/Emscripten-x86_64/lib/lib${fileName}.a`, { cwd: d.paths.project }));
});
}
});
Expand Down
8 changes: 4 additions & 4 deletions packages/cpp.js/src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import fs from 'node:fs';
import { execFileSync } from 'node:child_process';
import { Command, Option } from 'commander';
import { glob } from 'glob';
import replace from 'replace';

import { state } from './index.js';
Expand All @@ -18,6 +17,7 @@ import systemKeys from './utils/systemKeys.js';

import { getDockerImage } from './utils/pullDockerImage.js';
import { getContentHash } from './utils/hash.js';
import findFiles from './utils/findFiles.js';

const packageJSON = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)));

Expand Down Expand Up @@ -262,8 +262,8 @@ function buildLib(platform) {

const modules = [];
state.config.paths.module.forEach((modulePath) => {
modules.push(...glob.sync('**/*.i', { absolute: true, cwd: modulePath }));
modules.push(...glob.sync('*.i', { absolute: true, cwd: modulePath }));
modules.push(...findFiles('**/*.i', { cwd: modulePath }));
modules.push(...findFiles('*.i', { cwd: modulePath }));
});
if (modules.length > 0) {
fs.mkdirSync(`${state.config.paths.output}/prebuilt/${p}/swig`, { recursive: true });
Expand All @@ -289,7 +289,7 @@ function buildLib(platform) {
async function createWasmJs() {
let headers = [];
state.config.paths.header.forEach((headerPath) => {
headers.push(glob.sync('**/*.h', { absolute: true, cwd: headerPath }));
headers.push(findFiles('**/*.h', { cwd: headerPath }));
});
headers = headers.filter((path) => !!path.toString()).flat();

Expand Down
2 changes: 1 addition & 1 deletion packages/cpp.js/src/state/loadConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function getFilledConfig(config, options = { isDepend: false }) {
newConfig.paths.bridge = (newConfig.paths.bridge || [...newConfig.paths.native, newConfig.paths.build])
.map((p) => getPath(p));
newConfig.paths.output = getPath(newConfig.paths.output) || newConfig.paths.build;
newConfig.paths.cmake = options.isDepend ? getCMakeListsFilePath(newConfig.paths.output) : (
newConfig.paths.cmake = options.isDepend ? getPath(getCMakeListsFilePath(newConfig.paths.output)) : (
getPath(newConfig.paths.cmake || getCMakeListsFilePath(newConfig.paths.project))
);
newConfig.paths.cmakeDir = getParentPath(newConfig.paths.cmake);
Expand Down
5 changes: 5 additions & 0 deletions packages/cpp.js/src/utils/findFiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { glob } from 'glob';

export default function findFiles(regex, options = {}) {
return glob.sync(regex, { absolute: true, posix: true, ...options }).map(p => p.replace('//?/', ''));
}
2 changes: 1 addition & 1 deletion packages/cpp.js/src/utils/getAbsolutePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function getAbsolutePath(projectPath, path) {
return null;
}
if (upath.isAbsolute(path)) {
return path;
return upath.resolve(path);
}
if (projectPath) {
return upath.resolve(upath.join(upath.resolve(projectPath), path));
Expand Down
6 changes: 3 additions & 3 deletions packages/cpp.js/src/utils/getCMakeListsFilePath.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { glob } from 'glob';
import getParentPath from './getParentPath.js';
import findFiles from './findFiles.js';

export default function getCMakeListsFilePath(basePath = process.cwd()) {
let temp = glob.sync('CMakeLists.txt', { absolute: true, cwd: basePath });
let temp = findFiles('CMakeLists.txt', { cwd: basePath });
if (temp.length === 0) {
temp = glob.sync('*/CMakeLists.txt', { absolute: true, cwd: basePath, ignore: ['node_modules/*', 'dist/*', 'build/*'] });
temp = findFiles('*/CMakeLists.txt', { cwd: basePath, ignore: ['node_modules/*', 'dist/*', 'build/*'] });
}

if (temp.length > 0) return temp[0];
Expand Down
74 changes: 74 additions & 0 deletions packages/cppjs-core-docker/DraftWindowsDockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
FROM winamd64/openjdk:24-nanoserver

SHELL ["cmd", "/S", "/C"]

RUN curl -o python.zip -L https://www.python.org/ftp/python/3.13.1/python-3.13.1-embed-amd64.zip && \
mkdir C:\Python && \
tar -xf python.zip -C C:\Python && \
del python.zip

RUN curl -o nodejs.zip -L https://nodejs.org/dist/v22.12.0/node-v22.12.0-win-x64.zip && \
mkdir C:\NodeJS && \
tar -xf nodejs.zip -C C:\NodeJS && \
del nodejs.zip

RUN curl -o cmake.zip -L https://github.com/Kitware/CMake/releases/download/v3.31.3/cmake-3.31.3-windows-x86_64.zip && \
mkdir C:\CMake && \
tar -xf cmake.zip -C C:\CMake && \
del cmake.zip

RUN curl -o mingit.zip -L https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/MinGit-2.47.1-64-bit.zip && \
mkdir C:\Git && \
tar -xf mingit.zip -C C:\Git && \
del mingit.zip

RUN curl -o C:\cacert.pem -L https://curl.se/ca/cacert.pem

USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Python;C:\NodeJS\node-v22.12.0-win-x64;C:\CMake\cmake-3.31.3-windows-x86_64\bin;C:\Git\cmd;C:\emsdk"
RUN setx /M SSL_CERT_FILE "C:\cacert.pem"
USER ContainerUser

RUN git clone https://github.com/emscripten-core/emsdk.git C:\emsdk && \
cd C:\emsdk && \
emsdk install 3.1.51

RUN emsdk activate 3.1.51

USER ContainerAdministrator
RUN setx /M PATH "C:\emsdk\upstream\emscripten;%PATH%"
RUN setx /M EMSDK "C:\emsdk"
RUN setx /M EMSDK_NODE "C:\emsdk\node\20.18.0_64bit\bin\node.exe"
RUN setx /M EMSDK_PYTHON "C:\emsdk\python\3.9.2-nuget_64bit\python.exe"
RUN setx /M NDK_VERSION "25.2.9519653"
RUN setx /M ANDROID_SDK_ROOT "c:\android-sdk"
RUN setx /M ANDROID_HOME "c:\android-sdk"
RUN setx /M NDK_ROOT "%ANDROID_SDK_ROOT%/ndk/${NDK_VERSION}"
USER ContainerUser

RUN curl -o android-sdk.zip https://dl.google.com/android/repository/commandlinetools-win-11076708_latest.zip && \
mkdir %ANDROID_SDK_ROOT% && \
tar -xf android-sdk.zip -C %ANDROID_SDK_ROOT%
RUN mkdir %ANDROID_SDK_ROOT%\licenses
RUN node -e "require('fs').writeFileSync('c:/android-sdk/licenses/android-sdk-license', '24333f8a63b6825ea9c5514f83c2829b004d1fee')"
RUN node -e "require('fs').writeFileSync('c:/android-sdk/licenses/android-sdk-preview-license', '84831b9409646a918e30573bab4c9c91346d8abd')"
RUN %ANDROID_SDK_ROOT%\cmdline-tools\bin\sdkmanager --sdk_root=%ANDROID_SDK_ROOT% --install "ndk;%NDK_VERSION%"
RUN del android-sdk.zip

WORKDIR c:/emsdk/upstream/emscripten/src/embind
RUN curl -o embind.js -L https://raw.githubusercontent.com/bugra9/emscripten/embind-overloading-support/src/embind/embind.js

WORKDIR c:/emsdk/upstream/emscripten
RUN node -e "const fs = require('fs'); const filePath = './system/include/emscripten/bind.h'; const data = fs.readFileSync(filePath, 'utf8').replace(/smart_ptr<SmartPtr>\(smartPtrName\);/g, ' '); fs.writeFileSync(filePath, data);"
RUN node -e "const fs = require('fs'); const filePath = './cache/sysroot/include/emscripten/bind.h'; const data = fs.readFileSync(filePath, 'utf8').replace(/smart_ptr<SmartPtr>\(smartPtrName\);/g, ' '); fs.writeFileSync(filePath, data);"

WORKDIR c:/
RUN curl -o add-embind-support.zip -L https://github.com/bugra9/swig/archive/refs/heads/add-embind-support.zip
RUN tar -xf add-embind-support.zip -C c:/

#WORKDIR c:/swig-add-embind-support
#RUN cmake .
#RUN make
#RUN make install

ENTRYPOINT [ "cmd", "/c" ]
Loading