Skip to content

Commit

Permalink
Merge pull request #1928 from polywrap/feat-build-only-schema
Browse files Browse the repository at this point in the history
feat: add --no-wasm option to build command
  • Loading branch information
dOrgJelli authored Nov 23, 2023
2 parents 7b52e35 + 782f91a commit fef53c9
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 2 deletions.
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.12.2)
## Features
**`polywrap` CLI:**
* [PR-1928](https://github.com/polywrap/cli/pull/1928) **Add `--no-wasm` Option To `polywrap build`**
* `build` command now supports the `--no-wasm` option, which disables the wasm compilation step when compiling projects.

# Polywrap Origin (0.12.1)
## Features
**`polywrap` CLI:**
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ Currently, `build` can be run for Wasm, Plugin and Interface projects.
Skip codegen before building.
By default, `build` performs a `codegen` step before building your Project. This option skips this step.

- `--no-wasm`
Skip wasm compilation.
By default, `build` performs wasm compilation. This option skips this step.

- `-s, --strategy <strategy>`
Specify which build strategy to use. By default, the `vm` build strategy is used.
Available strategies:
Expand Down
1 change: 1 addition & 0 deletions packages/cli/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"commands_build_options_options": "options",
"commands_build_options_t": "Use the development server's ENS instance",
"commands_build_options_codegen": "Skip code generation before build",
"commands_build_options_no_wasm": "Skip wasm compilation",
"commands_build_options_codegen_dir": "Codegen output directory (default: {default})",
"commands_build_options_s": "Strategy to use for building the wrapper (default: {default})",
"commands_build_options_s_strategy": "strategy",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"commands_build_options_options": "options",
"commands_build_options_t": "Use the development server's ENS instance",
"commands_build_options_codegen": "Skip code generation before build",
"commands_build_options_no_wasm": "Skip wasm compilation",
"commands_build_options_codegen_dir": "Codegen output directory (default: {default})",
"commands_build_options_s": "Strategy to use for building the wrapper (default: {default})",
"commands_build_options_s_strategy": "strategy",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/__tests__/e2e/p2/build.wasm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Options:
-c, --client-config <config-path> Add custom configuration to the
PolywrapClient
-n, --no-codegen Skip code generation before build
--no-wasm Skip wasm compilation
--codegen-dir Codegen output directory (default:
./src/wrap)
--wrapper-envs <envs-path> Path to a JSON file containing wrapper
Expand Down Expand Up @@ -265,7 +266,7 @@ describe("e2e tests for build command", () => {
expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`);
});
})

describe("test-cases", () => {
for (let i = 0; i < testCases.length; i++) {
const testCaseName = testCases[i];
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface BuildCommandOptions extends BaseCommandOptions {
clientConfig: string | false;
wrapperEnvs: string | false;
noCodegen: boolean;
noWasm: boolean;
codegenDir: string | false;
watch: boolean;
strategy: `${SupportedStrategies}`;
Expand Down Expand Up @@ -80,6 +81,7 @@ export const build: Command = {
`${intlMsg.commands_common_options_config()}`
)
.option(`-n, --no-codegen`, `${intlMsg.commands_build_options_codegen()}`)
.option(`--no-wasm`, `${intlMsg.commands_build_options_no_wasm()}`)
.option(
`--codegen-dir`,
`${intlMsg.commands_build_options_codegen_dir({
Expand Down Expand Up @@ -117,6 +119,7 @@ export const build: Command = {
outputDir: parseDirOption(options.outputDir, defaultOutputDir),
bindgen: options.bindgen || false,
noCodegen: !options.codegen || false,
noWasm: !options.wasm || false,
codegenDir: parseDirOptionNoDefault(options.codegenDir),
strategy: options.strategy || defaultStrategy,
watch: options.watch || false,
Expand Down Expand Up @@ -174,6 +177,7 @@ async function run(options: Required<BuildCommandOptions>) {
bindgen,
strategy,
noCodegen,
noWasm,
codegenDir,
verbose,
quiet,
Expand Down Expand Up @@ -220,7 +224,7 @@ async function run(options: Required<BuildCommandOptions>) {

const isInterface = language === "interface";

if (isInterface) {
if (isInterface || noWasm) {
buildStrategy = new NoopBuildStrategy({
project: project as PolywrapProject,
outputDir,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"noWasm": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"wrap.info"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"stdout": [
"WRAP manifest written in ./build"
],
"exitCode": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@polywrap/test-project",
"version": "0.1.0",
"license": "MIT",
"private": true,
"scripts": {
"build": "polywrap build"
},
"dependencies": {
"@polywrap/wasm-as": "../../../../../../../wasm/as"
},
"devDependencies": {
"assemblyscript": "0.19.23"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
format: 0.2.0
strategies:
image:
node_version: "14.16.0"
include:
- ./package.json
linked_packages:
- name: "@polywrap/wasm-as"
path: ../../../../../../../wasm/as
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
format: 0.5.0
project:
name: test-project
type: wasm/assemblyscript
source:
module: ./src/index.ts
schema: ./src/schema.graphql
extensions:
build: ./polywrap.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Args_method, ModuleBase } from "./wrap";

export class Module extends ModuleBase {
method(args: Args_method): string {
this fails to compile
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Module {
method(
arg: String!
): String!
}

0 comments on commit fef53c9

Please sign in to comment.