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
13 changes: 10 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,21 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.emscripten-cache
key: ${{ runner.os }}-emscripten
key: ${{ runner.os }}-emscripten-{{ hashFiles('/home/runner/.emscripten-cache/sanity.txt') }}
restore-keys: |
${{ runner.os }}-emscripten
${{ runner.os }}-emscripten-

- name: Install dependenciesch
- name: Install dependencies
run: |
npm ci

- name: Download MLIR
run: |
npm run download-mlir
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true

- name: Prettier
run: |
npm -w cxx-frontend run prettier
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"update-tests": "zx scripts/update-tests.mjs",
"cxx-gen-ast": "node packages/cxx-gen-ast",
"cxx-gen-lsp": "node packages/cxx-gen-lsp packages/cxx-gen-lsp/metaModel.json packages/cxx-gen-lsp -o src/lsp/cxx/lsp",
"download-lsp-model": "zx scripts/download-lsp-model.mjs"
"download-lsp-model": "zx scripts/download-lsp-model.mjs",
"download-mlir": "gh run download -n mlir --dir build.em/llvm-project/install/"
}
}
31 changes: 30 additions & 1 deletion packages/cxx-frontend/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ $.verbose = true;
// get the root directory of the project
const projectRootSourcePath = path.join(__dirname, "../../..");

const hasMLIR = fs.existsSync(
path.join(
projectRootSourcePath,
"build.em/llvm-project/install/bin/llvm-tblgen.js",
),
);

if (hasMLIR) {
console.log("building with MLIR support");
}

// get the source path of the cxx-frontend package
const cxxFrontendSourcePath = path.join(
projectRootSourcePath,
Expand Down Expand Up @@ -108,6 +119,14 @@ async function dockerBuild() {
);
}

if (hasMLIR) {
cmakeOptions.push(
`-DCXX_ENABLE_MLIR=YES`,
`-DLLVM_DIR=/code/build.em/llvm-project/install/lib/cmake/llvm`,
`-DMLIR_DIR=/code/build.em/llvm-project/install/lib/cmake/mlir`,
);
}

const user = await $`id -u`;

await $`mkdir -p ${emscriptenCacheDir}`;
Expand All @@ -129,6 +148,14 @@ async function emsdkBuild({ cmake, emcmake, flatc, kwgen }) {
`-B ${projectRootSourcePath}/build.em`,
];

if (hasMLIR) {
cmakeOptions.push(
`-DCXX_ENABLE_MLIR=YES`,
`-DLLVM_DIR=${projectRootSourcePath}/build.em/llvm-project/install/lib/cmake/llvm`,
`-DMLIR_DIR=${projectRootSourcePath}/build.em/llvm-project/install/lib/cmake/mlir`,
);
}

if (argv.debug) {
cmakeOptions.push(`-DCMAKE_BUILD_TYPE=Debug`);
} else {
Expand All @@ -146,7 +173,9 @@ async function emsdkBuild({ cmake, emcmake, flatc, kwgen }) {
async function emsdkBuildPresets() {
const cmake = await which("cmake", { nothrow: true });

await $`${cmake} -S ${projectRootSourcePath} --preset emscripten`;
const preset = hasMLIR ? "emscripten-mlir" : "emscripten";

await $`${cmake} -S ${projectRootSourcePath} --preset ${preset}`;

await $`${cmake} --build ${projectRootSourcePath}/build.em --target install`;
}
Expand Down