Skip to content

Commit

Permalink
Merge pull request #1798 from polywrap/origin-0.10-dev
Browse files Browse the repository at this point in the history
Origin 0.10.6 | /workflows/release-pr
  • Loading branch information
dOrgJelli authored Jun 30, 2023
2 parents 1bca63a + c8ce7d7 commit 38769d3
Show file tree
Hide file tree
Showing 10 changed files with 418 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-wrap-test-harness.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: nightly-2023-06-15
override: true

- uses: actions/cache@v2
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v17.9.1
v18.15.0
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Polywrap Origin (0.10.6)
## Bugs
**`polywrap` CLI:**
* [PR-1796](https://github.com/polywrap/cli/pull/1796) **`wrap/rust` Builds Now Properly Remove wasm-bindgen Imports**
* The `wasm-bindgen` CLI was emitting an unneeded `__wbindgen_throw` import, so we use `wasm-snip` to remove it.

# Polywrap Origin (0.10.5)
## Bugs
**`@polywrap/schema-bind`:**
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.5
0.10.6
4 changes: 2 additions & 2 deletions packages/cli/src/commands/infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { InfraManifest } from "@polywrap/polywrap-manifest-types-js";
import path from "path";
import { Argument } from "commander";
import chalk from "chalk";
import yaml from "yaml";
import { readdirSync } from "fs";

export enum InfraActions {
Expand Down Expand Up @@ -179,7 +178,8 @@ async function run(
logger.info(JSON.stringify(await infra.getVars(), null, 2));
break;
case InfraActions.CONFIG:
logger.info(yaml.stringify((await infra.config()).data.config, null, 2));
// Calling "docker-compose config" will log to console, so we don't have to
await infra.config();
break;
default:
throw Error(intlMsg.commands_infra_error_never());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,32 @@ mv ./{{dir}}/Cargo-local.toml ./{{dir}}/Cargo.toml
cargo build --manifest-path ./{{dir}}/Cargo.toml \
--target wasm32-unknown-unknown --release

# Make the build directory
# Make the build & build-staging directory
rm -rf ./build
mkdir ./build
rm -rf ./build-staging
mkdir ./build-staging

# Run wasm-bindgen over the module, replacing all placeholder __wbindgen_... imports
wasm-bindgen ./{{dir}}/target/wasm32-unknown-unknown/release/module.wasm --out-dir ./build --out-name bg_module.wasm
# Move the rust module into the staging directory
mv ./{{dir}}/target/wasm32-unknown-unknown/release/module.wasm ./build-staging/module.wasm

# Run wasm-tools strip to remove the wasm-interface-types custom section
wasm-tools strip ./build/bg_module.wasm -d wasm-interface-types -o ./build/strip_module.wasm
rm -rf ./build/bg_module.wasm
# Wasm Post-processing

# Run wasm-snip to trip down the size of the binary, removing any dead code
wasm-snip ./build/strip_module.wasm -o ./build/snipped_module.wasm
rm -rf ./build/strip_module.wasm
# 1. Run `wasm-bindgen` over the module, replacing all placeholder __wbindgen_... imports
wasm-bindgen ./build-staging/module.wasm --out-dir ./build-staging --out-name module_bg.wasm

# Use wasm-opt to perform the "asyncify" post-processing step over all modules
# 2. If wasm-bindgen isn't being used, the only import that will be remaining will be __wbindgen_throw.
# So, let's remove this, and if more extraneous imports exist an error will be raised post-compilation
wasm-snip ./build-staging/module_bg.wasm -o ./build-staging/module_bg_snip.wasm -p .*__wbindgen_throw

# 3. Run `wasm-tools strip` to remove the wasm-interface-types custom section (sometimes get injected)
wasm-tools strip ./build-staging/module_bg_snip.wasm -d wasm-interface-types -o ./build-staging/module_bg_snip_strip.wasm

# 4. Use wasm-opt to perform the "asyncify" post-processing step over all modules
export ASYNCIFY_STACK_SIZE=24576
wasm-opt --asyncify -Os ./build/snipped_module.wasm -o ./build/wrap.wasm
rm -rf ./build/snipped_module.wasm
wasm-opt --asyncify -Os ./build-staging/module_bg_snip_strip.wasm -o ./build-staging/module_bg_snip_strip_opt.wasm

# Finish - Move the result
mv ./build-staging/module_bg_snip_strip_opt.wasm ./build/wrap.wasm

{{/polywrap_module}}
7 changes: 4 additions & 3 deletions packages/cli/src/lib/infra/Infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import path from "path";
import fs, { lstatSync, readdirSync } from "fs";
import YAML from "yaml";
import { copySync } from "fs-extra";
import { IDockerComposeOptions } from "docker-compose";

export interface InfraConfig {
rootDir: string;
Expand Down Expand Up @@ -105,11 +106,11 @@ export class Infra {
ReturnType<DockerCompose["commands"]["config"]>
> {
const modulesWithPaths = await this._fetchModules();

return await this._dockerCompose.commands.config({
const configOptions: Partial<IDockerComposeOptions> = {
...this._defaultDockerOptions,
config: modulesWithPaths.map((m) => m.path),
});
};
return await this._dockerCompose.commands.config(configOptions);
}

public async getVars(): Promise<string[]> {
Expand Down
4 changes: 2 additions & 2 deletions packages/js/manifests/polywrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"@polywrap/logging-js": "0.10.5",
"@polywrap/polywrap-manifest-schemas": "0.10.5",
"jsonschema": "1.4.0",
"semver": "7.5.0",
"semver": "7.5.3",
"yaml": "2.2.2"
},
"devDependencies": {
"@polywrap/os-js": "0.10.5",
"@types/jest": "26.0.8",
"@types/mustache": "4.0.1",
"@types/prettier": "2.6.0",
"@types/semver": "7.3.11",
"@types/semver": "7.5.0",
"jest": "26.6.3",
"json-schema-to-typescript": "11.0.2",
"mustache": "4.0.1",
Expand Down
Loading

0 comments on commit 38769d3

Please sign in to comment.