Skip to content

Commit

Permalink
Merge pull request #39 from thewtex/bindgen-test
Browse files Browse the repository at this point in the history
ENH: Test TypeScript bindings generation
  • Loading branch information
thewtex committed Mar 30, 2023
2 parents c7ecc65 + cb2c6c2 commit b65be46
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
"description": "npm scripts to generate itk-wasm artifacts.",
"type": "module",
"scripts": {
"build": "npm run build:emscripten && npm run build:wasi",
"build:emscripten": "itk-wasm -i itkwasm/emscripten:20230315-07caf9ca build",
"build:emscripten:debug": "itk-wasm -i itkwasm/emscripten:20230315-07caf9ca-debug build -- -DCMAKE_BUILD_TYPE:STRING=Debug",
"build:wasi": "itk-wasm -i itkwasm/wasi:20230315-07caf9ca build",
"build:wasi:debug": "itk-wasm -i itkwasm/wasi:20230315-07caf9ca-debug build -- -DCMAKE_BUILD_TYPE:STRING=Debug",
"build": "npm run build:emscripten && npm run build:wasi && npm run bindgen:typescript",
"build:emscripten": "itk-wasm -i itkwasm/emscripten:20230328-71e6501e build",
"build:emscripten:debug": "itk-wasm -i itkwasm/emscripten:20230328-71e6501e-debug build -- -DCMAKE_BUILD_TYPE:STRING=Debug",
"build:wasi": "itk-wasm -i itkwasm/wasi:20230328-71e6501e build",
"build:wasi:debug": "itk-wasm -i itkwasm/wasi:20230328-71e6501e-debug build -- -DCMAKE_BUILD_TYPE:STRING=Debug",
"bindgen:typescript": "itk-wasm -b emscripten-build bindgen --output-dir wasm/typescript --package-name @itk-wasm/cleaver --package-description \"The Cleaver multimaterial tetrahedral meshing tool.\" --repository 'https://github.com/SCIInstitute/Cleaver2'",
"test": "npm run test:wasi",
"test:wasi": "itk-wasm test --test-dir wasm",
"clean": "git clean -fdx -e node_modules"
},
"license": "Apache-2.0",
"devDependencies": {
"itk-wasm": "^1.0.0-b.87"
"itk-wasm": "^1.0.0-b.91"
}
}
3 changes: 2 additions & 1 deletion wasm/ITKCleaverWasm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PipelineFunctor

using InputImageType = itk::wasm::InputImage<ImageType>;
std::vector<InputImageType> inputImages;
pipeline.add_option("-i,--input", inputImages, "Input label image or multiple indicator function images")->type_name("INPUT_IMAGE");
auto inputImagesOption = pipeline.add_option("-i,--input", inputImages, "Input label image or multiple indicator function images")->type_name("INPUT_IMAGE");

ITK_WASM_PRE_PARSE(pipeline);

Expand All @@ -94,6 +94,7 @@ class PipelineFunctor
loadedInputImages[ii] = inputImages[ii].Get();
}

inputImagesOption->required();
int result = Mesher<ImageType>(pipeline, loadedInputImages);
return result;
}
Expand Down
Binary file modified wasm/typescript/dist/pipelines/itk-cleaver.wasm
Binary file not shown.
18 changes: 10 additions & 8 deletions wasm/typescript/src/itk-cleaver-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ async function itkCleaverNode(
args.push('0')
// Options
args.push('--memory-io')
if (options.input.length < 1) {
throw new Error('"input" option must have a length > 0')
if (typeof options.input !== "undefined") {
if(options.input.length < 1) {
throw new Error('"input" option must have a length > 1')
}
args.push('--input')
options.input.forEach((value) => {
const inputCountString = inputs.length.toString()
inputs.push({ type: InterfaceTypes.Image, data: value as Image})
args.push(inputCountString)
})
}
args.push('--input')
options.input.forEach((inputImage, index) => {
args.push((index+0).toString())
inputs.push({ type: InterfaceTypes.Image, data: inputImage as Image})

})
if (typeof options.sigma !== "undefined") {
args.push('--sigma', options.sigma.toString())
}
Expand Down
18 changes: 10 additions & 8 deletions wasm/typescript/src/itk-cleaver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ async function itkCleaver(
args.push('0')
// Options
args.push('--memory-io')
if (options.input.length < 1) {
throw new Error('"input" option must have a length > 0')
if (typeof options.input !== "undefined") {
if(options.input.length < 1) {
throw new Error('"input" option must have a length > 1')
}
args.push('--input')
options.input.forEach((value) => {
const inputCountString = inputs.length.toString()
inputs.push({ type: InterfaceTypes.Image, data: value as Image})
args.push(inputCountString)
})
}
args.push('--input')
options.input.forEach((inputImage, index) => {
args.push((index+0).toString())
inputs.push({ type: InterfaceTypes.Image, data: inputImage as Image})

})
if (typeof options.sigma !== "undefined") {
args.push('--sigma', options.sigma.toString())
}
Expand Down

0 comments on commit b65be46

Please sign in to comment.