Skip to content

Commit

Permalink
fix: Build cargo together.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Nov 5, 2023
1 parent 6a95803 commit 8d1348b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
26 changes: 10 additions & 16 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,24 @@ async function buildPackages(builds: BuildInfo[]) {

await fs.promises.mkdir(buildDir);

await Promise.all(
builds.map(async (build) => {
core.debug(`Building ${build.packageName} (mode=release, target=wasm32-wasi)`);
core.debug(`Building (mode=release, target=wasm32-wasi)`);

await exec.exec('cargo', [
'build',
'--release',
'--package',
build.packageName,
'--target',
'wasm32-wasi',
]);
await exec.exec('cargo', [
'build',
'--release',
'--target=wasm32-wasi',
...builds.map((build) => `--package=${build.packageName}`),
]);

await Promise.all(
builds.map(async (build) => {
core.debug(`Optimizing ${build.packageName} (level=${build.optLevel})`);

const fileName = `${build.targetName}.wasm`;
const inputFile = path.join(root, 'target/wasm32-wasi/release', fileName);
const outputFile = path.join(buildDir, fileName);

await exec.exec('wasm-opt', [`-O${build.optLevel}`, inputFile, '--output', outputFile]);

core.debug(`Stripping ${build.packageName}`);

await exec.exec('wasm-strip', [outputFile]);

core.debug(`Hashing ${build.packageName} (checksum=sha256)`);
Expand All @@ -165,10 +160,9 @@ async function buildPackages(builds: BuildInfo[]) {

await fs.promises.writeFile(checksumFile, checksumHash);

core.info(build.packageName);
core.info(`${build.packageName} (${checksumHash})`);
core.info(`--> ${outputFile}`);
core.info(`--> ${checksumFile}`);
core.info(`--> ${checksumHash}`);
}),
);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@moonrepo/build-proto-plugin",
"version": "0.0.4",
"version": "0.0.5",
"description": "A GitHub action to build, optimize, and prepare a proto WASM plugin for release.",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit 8d1348b

Please sign in to comment.