@@ -28,6 +28,13 @@ $.verbose = true;
2828// get the root directory of the project
2929const projectRootSourcePath = path . join ( __dirname , "../../.." ) ;
3030
31+ const hasMLIR = fs . existsSync (
32+ path . join (
33+ projectRootSourcePath ,
34+ "build.em/llvm-project/install/bin/llvm-tblgen.js" ,
35+ ) ,
36+ ) ;
37+
3138// get the source path of the cxx-frontend package
3239const cxxFrontendSourcePath = path . join (
3340 projectRootSourcePath ,
@@ -129,6 +136,14 @@ async function emsdkBuild({ cmake, emcmake, flatc, kwgen }) {
129136 `-B ${ projectRootSourcePath } /build.em` ,
130137 ] ;
131138
139+ if ( hasMLIR ) {
140+ cmakeOptions . push (
141+ `-DCXX_ENABLE_MLIR=YES` ,
142+ `-DLLVM_DIR=${ projectRootSourcePath } /build.em/llvm-project/install/lib/cmake/llvm` ,
143+ `-DMLIR_DIR=${ projectRootSourcePath } /build.em/llvm-project/install/lib/cmake/mlir` ,
144+ ) ;
145+ }
146+
132147 if ( argv . debug ) {
133148 cmakeOptions . push ( `-DCMAKE_BUILD_TYPE=Debug` ) ;
134149 } else {
@@ -146,7 +161,9 @@ async function emsdkBuild({ cmake, emcmake, flatc, kwgen }) {
146161async function emsdkBuildPresets ( ) {
147162 const cmake = await which ( "cmake" , { nothrow : true } ) ;
148163
149- await $ `${ cmake } -S ${ projectRootSourcePath } --preset emscripten` ;
164+ const preset = hasMLIR ? "emscripten-mlir" : "emscripten" ;
165+
166+ await $ `${ cmake } -S ${ projectRootSourcePath } --preset ${ preset } ` ;
150167
151168 await $ `${ cmake } --build ${ projectRootSourcePath } /build.em --target install` ;
152169}
0 commit comments