build: combine build-pkgs*.sh into build.nu (#6231)
* build: combine build-pkgs* into build.nu Signed-off-by: pyranota <pyra@duck.com> * nit refactor Signed-off-by: pyranota <pyra@duck.com> --------- Signed-off-by: pyranota <pyra@duck.com>
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eou pipefail
|
||||
|
||||
#-# bun and deno
|
||||
OUT_DIR="../../../cli/wasm/ts"
|
||||
mkdir -p $OUT_DIR
|
||||
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "ts-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-ts"/' $OUT_DIR/package.json
|
||||
rm $OUT_DIR/.gitignore
|
||||
|
||||
#-# sql languages, graphql and bash/powershell, since they all use regex
|
||||
OUT_DIR="../../../cli/wasm/regex"
|
||||
mkdir -p $OUT_DIR
|
||||
wasm-pack build --release --target deno --out-dir $OUT_DIR \
|
||||
--features "sql-parser,graphql-parser,bash-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-regex"/' $OUT_DIR/package.json
|
||||
rm $OUT_DIR/.gitignore
|
||||
|
||||
#-# python
|
||||
OUT_DIR="../../../cli/wasm/python"
|
||||
mkdir -p $OUT_DIR
|
||||
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "py-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-py"/' $OUT_DIR/package.json
|
||||
rm $OUT_DIR/.gitignore
|
||||
|
||||
#-# go
|
||||
OUT_DIR="../../../cli/wasm/go"
|
||||
mkdir -p $OUT_DIR
|
||||
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "go-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-go"/' $OUT_DIR/package.json
|
||||
rm $OUT_DIR/.gitignore
|
||||
|
||||
#-# php
|
||||
OUT_DIR="../../../cli/wasm/php"
|
||||
mkdir -p $OUT_DIR
|
||||
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "php-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-php"/' $OUT_DIR/package.json
|
||||
rm $OUT_DIR/.gitignore
|
||||
|
||||
#-# rust
|
||||
OUT_DIR="../../../cli/wasm/rust"
|
||||
mkdir -p $OUT_DIR
|
||||
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "rust-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-rust"/' $OUT_DIR/package.json
|
||||
rm $OUT_DIR/.gitignore
|
||||
|
||||
#-# ansible
|
||||
OUT_DIR="../../../cli/wasm/yaml"
|
||||
mkdir -p $OUT_DIR
|
||||
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "ansible-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-yaml"/' $OUT_DIR/package.json
|
||||
rm $OUT_DIR/.gitignore
|
||||
|
||||
#-# C# (needs some more stuff to compile C tree sitter into wasm)
|
||||
OUT_DIR="../../../cli/wasm/csharp"
|
||||
mkdir -p $OUT_DIR
|
||||
CFLAGS_wasm32_unknown_unknown="-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin" RUSTFLAGS="-Zwasm-c-abi=spec" wasm-pack build --release --target deno --out-dir $OUT_DIR --features "csharp-parser"
|
||||
# sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-csharp"/' $OUT_DIR/package.json
|
||||
rm $OUT_DIR/.gitignore
|
||||
|
||||
#-# Nu
|
||||
OUT_DIR="../../../cli/wasm/nu"
|
||||
mkdir -p $OUT_DIR
|
||||
wasm-pack build --release --target deno --out-dir $OUT_DIR --features "nu-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
rm $OUT_DIR/.gitignore
|
||||
|
||||
#-# Java
|
||||
OUT_DIR="../../../cli/wasm/java"
|
||||
mkdir -p $OUT_DIR
|
||||
CFLAGS_wasm32_unknown_unknown="-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin" RUSTFLAGS="-Zwasm-c-abi=spec" wasm-pack build --release --target deno --out-dir $OUT_DIR --features "java-parser"
|
||||
rm $OUT_DIR/.gitignore
|
||||
@@ -1,68 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -eou pipefail
|
||||
|
||||
#-# full pkg
|
||||
OUT_DIR="pkg"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --all-features \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
|
||||
#-# bun and deno
|
||||
OUT_DIR="pkg-ts"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "ts-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-ts"/' $OUT_DIR/package.json
|
||||
|
||||
#-# sql languages, graphql and bash/powershell, since they all use regex
|
||||
OUT_DIR="pkg-regex"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR \
|
||||
--features "sql-parser,graphql-parser,bash-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-regex"/' $OUT_DIR/package.json
|
||||
|
||||
#-# python
|
||||
OUT_DIR="pkg-py"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "py-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-py"/' $OUT_DIR/package.json
|
||||
|
||||
#-# go
|
||||
OUT_DIR="pkg-go"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "go-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-go"/' $OUT_DIR/package.json
|
||||
|
||||
#-# php
|
||||
OUT_DIR="pkg-php"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "php-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-php"/' $OUT_DIR/package.json
|
||||
|
||||
#-# rust
|
||||
OUT_DIR="pkg-rust"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "rust-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-rust"/' $OUT_DIR/package.json
|
||||
|
||||
#-# ansible
|
||||
OUT_DIR="pkg-yaml"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "ansible-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-yaml"/' $OUT_DIR/package.json
|
||||
|
||||
#-# C# (needs some more stuff to compile C tree sitter into wasm)
|
||||
# TODO: hasn't been tested on mac, might need fixing
|
||||
OUT_DIR="pkg-csharp"
|
||||
CFLAGS_wasm32_unknown_unknown="-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin" RUSTFLAGS="-Zwasm-c-abi=spec" wasm-pack build --release --target web --out-dir $OUT_DIR --features "csharp-parser"
|
||||
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-csharp"/' $OUT_DIR/package.json
|
||||
|
||||
#-# nu
|
||||
# TODO: hasn't been tested on mac, might need fixing
|
||||
OUT_DIR="pkg-nu"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "nu-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-nu"/' $OUT_DIR/package.json
|
||||
|
||||
#-# Java (needs some more stuff to compile C tree sitter into wasm)
|
||||
OUT_DIR="pkg-java"
|
||||
CFLAGS_wasm32_unknown_unknown="-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin" RUSTFLAGS="-Zwasm-c-abi=spec" wasm-pack build --release --target web --out-dir $OUT_DIR --features "java-parser"
|
||||
sed -i '' 's/"windmill-parser-wasm"/"windmill-parser-wasm-java"/' $OUT_DIR/package.json
|
||||
@@ -1,66 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eou pipefail
|
||||
|
||||
#-# full pkg
|
||||
OUT_DIR="pkg"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --all-features \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
|
||||
#-# bun and deno
|
||||
OUT_DIR="pkg-ts"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "ts-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-ts"/' $OUT_DIR/package.json
|
||||
|
||||
#-# sql languages, graphql and bash/powershell, since they all use regex
|
||||
OUT_DIR="pkg-regex"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR \
|
||||
--features "sql-parser,graphql-parser,bash-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-regex"/' $OUT_DIR/package.json
|
||||
|
||||
#-# python
|
||||
OUT_DIR="pkg-py"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "py-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-py"/' $OUT_DIR/package.json
|
||||
|
||||
#-# go
|
||||
OUT_DIR="pkg-go"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "go-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-go"/' $OUT_DIR/package.json
|
||||
|
||||
#-# php
|
||||
OUT_DIR="pkg-php"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "php-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-php"/' $OUT_DIR/package.json
|
||||
|
||||
#-# rust
|
||||
OUT_DIR="pkg-rust"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "rust-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-rust"/' $OUT_DIR/package.json
|
||||
|
||||
#-# ansible
|
||||
OUT_DIR="pkg-yaml"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "ansible-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-yaml"/' $OUT_DIR/package.json
|
||||
|
||||
#-# C# (needs some more stuff to compile C tree sitter into wasm)
|
||||
OUT_DIR="pkg-csharp"
|
||||
CFLAGS_wasm32_unknown_unknown="-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin" RUSTFLAGS="-Zwasm-c-abi=spec" wasm-pack build --release --target web --out-dir $OUT_DIR --features "csharp-parser"
|
||||
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-csharp"/' $OUT_DIR/package.json
|
||||
|
||||
#-# Nu
|
||||
OUT_DIR="pkg-nu"
|
||||
wasm-pack build --release --target web --out-dir $OUT_DIR --features "nu-parser" \
|
||||
-Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-nu"/' $OUT_DIR/package.json
|
||||
|
||||
#-# Java (needs some more stuff to compile C tree sitter into wasm)
|
||||
OUT_DIR="pkg-java"
|
||||
CFLAGS_wasm32_unknown_unknown="-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin" RUSTFLAGS="-Zwasm-c-abi=spec" wasm-pack build --release --target web --out-dir $OUT_DIR --features "java-parser"
|
||||
sed -i 's/"windmill-parser-wasm"/"windmill-parser-wasm-java"/' $OUT_DIR/package.json
|
||||
132
backend/parsers/windmill-parser-wasm/build.nu
Executable file
132
backend/parsers/windmill-parser-wasm/build.nu
Executable file
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env nu
|
||||
const targets = [
|
||||
{
|
||||
ident: "ts", # OUT_DIR inferred from this
|
||||
desc: "Bun and Deno"
|
||||
features: "ts-parser",
|
||||
env: "default", # available: default, tree-sitter
|
||||
}, {
|
||||
ident: "regex",
|
||||
desc: "Sql languages, Graphql and Bash/Powershell"
|
||||
features: "sql-parser,graphql-parser,bash-parser",
|
||||
env: "default",
|
||||
}, {
|
||||
ident: "py",
|
||||
desc: "Python",
|
||||
features: "py-parser",
|
||||
env: "default",
|
||||
}, {
|
||||
ident: "go",
|
||||
desc: "Go (Go-lang)",
|
||||
features: "go-parser",
|
||||
env: "default",
|
||||
}, {
|
||||
ident: "php",
|
||||
desc: "Php",
|
||||
features: "php-parser",
|
||||
env: "default",
|
||||
}, {
|
||||
ident: "rust",
|
||||
desc: "Rust",
|
||||
features: "rust-parser",
|
||||
env: "default",
|
||||
}, {
|
||||
ident: "yaml",
|
||||
desc: "Ansible",
|
||||
features: "ansible-parser",
|
||||
env: "default",
|
||||
}, {
|
||||
ident: "csharp",
|
||||
desc: "C#",
|
||||
features: "csharp-parser",
|
||||
env: "tree-sitter",
|
||||
}, {
|
||||
ident: "nu",
|
||||
desc: "Nu (Nushell)",
|
||||
features: "nu-parser",
|
||||
env: "tree-sitter",
|
||||
}, {
|
||||
ident: "java",
|
||||
desc: "Java",
|
||||
features: "java-parser",
|
||||
env: "tree-sitter",
|
||||
# }, {
|
||||
# ident: "ruby",
|
||||
# desc: "Ruby",
|
||||
# features: "ruby-parser",
|
||||
# env: "tree-sitter",
|
||||
},
|
||||
# ^^^ Add new entry here ^^^
|
||||
];
|
||||
# NOTE: This is legacy command for building all, but it is not more used
|
||||
# #-# full pkg
|
||||
# OUT_DIR="pkg"
|
||||
# wasm-pack build --release --target web --out-dir $OUT_DIR --all-features \
|
||||
# -Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
|
||||
# Build all separately
|
||||
def 'main all' [ --no-opt(-n), --cli] {
|
||||
if ($no_opt) {
|
||||
if ($cli) {
|
||||
$targets | each { main $in.ident -n --cli }
|
||||
} else {
|
||||
$targets | each { main $in.ident -n }
|
||||
}
|
||||
} else {
|
||||
if ($cli) {
|
||||
$targets | each { main $in.ident --cli }
|
||||
} else {
|
||||
$targets | each { main $in.ident }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Build specific language
|
||||
def main [
|
||||
target: string, # Language, e.g.: py, ts, rust
|
||||
--no-opt(-n), # Compile in debug mode for dev
|
||||
--cli # Compile and place binaries in cli.
|
||||
] {
|
||||
let t = $targets | where ident == $target;
|
||||
|
||||
if ($t | is-empty) {
|
||||
let pretty = $targets | each {|t| $"• ($t.ident) - ($t.desc)"} | str join "\n";
|
||||
panic $"Target '($target)' does not exist\n\nAvailable targets:\n($pretty)"
|
||||
} else {
|
||||
let t = $t | get 0;
|
||||
mut profile = "";
|
||||
mut tar = "";
|
||||
|
||||
if ($cli) {
|
||||
$env.OUT_DIR = $"../../../cli/wasm/($t.ident)"
|
||||
$tar = "deno"
|
||||
} else {
|
||||
$env.OUT_DIR = $"pkg-($t.ident)"
|
||||
$tar = "web"
|
||||
}
|
||||
if ($no_opt) {
|
||||
$profile = "--no-opt"
|
||||
} else {
|
||||
$profile = "--release"
|
||||
}
|
||||
print $"Building in ($profile) mode ($env.OUT_DIR)"
|
||||
match $t.env {
|
||||
"default" => {
|
||||
wasm-pack build ($profile) --target ($tar) --out-dir $env.OUT_DIR --features ($t.features) -Z build-std=panic_abort,std -Z build-std-features=panic_immediate_abort
|
||||
},
|
||||
"tree-sitter" => {
|
||||
$env.CFLAGS_wasm32_unknown_unknown = "-I$(pwd)/wasm-sysroot -Wbad-function-cast -Wcast-function-type -fno-builtin"
|
||||
$env.RUSTFLAGS = "-Zwasm-c-abi=spec"
|
||||
wasm-pack build ($profile) --target ($tar) --out-dir $env.OUT_DIR --features $t.features
|
||||
},
|
||||
_ => { panic $"Unknown env template: ($t.env)" },
|
||||
}
|
||||
|
||||
if ($cli) {
|
||||
rm ($env.OUT_DIR)/.gitignore
|
||||
} else {
|
||||
let p = ($env.OUT_DIR)/package.json
|
||||
open $p | update name $"windmill-parser-wasm-($t.ident)" | save -f $p
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,22 +4,9 @@
|
||||
# and perform installation to frontend
|
||||
def "main" [
|
||||
lang: string # Example: nu
|
||||
--release(-r)
|
||||
] {
|
||||
let out_dir = $'pkg-($lang)'
|
||||
if $release {
|
||||
open build-pkgs.sh
|
||||
| split row '#-'
|
||||
| find $out_dir
|
||||
| bash -c $"RUST_LOG=trace ($in.0)"
|
||||
} else {
|
||||
open build-pkgs.sh
|
||||
| split row '#-'
|
||||
| find $out_dir
|
||||
| str replace "--release" "--no-opt"
|
||||
| bash -c $"WASM_OPT=-Oz ($in.0)"
|
||||
}
|
||||
./build.nu $lang --no-opt
|
||||
(
|
||||
cd ../../../frontend; npm install ../backend/parsers/windmill-parser-wasm/($out_dir)
|
||||
cd ../../../frontend; npm install ../backend/parsers/windmill-parser-wasm/pkg-($lang)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ await build({
|
||||
"nu",
|
||||
"ts",
|
||||
"regex",
|
||||
"python",
|
||||
"py",
|
||||
"go",
|
||||
"php",
|
||||
"rust",
|
||||
|
||||
@@ -523,7 +523,7 @@ export async function inferSchema(
|
||||
let inferedSchema: any;
|
||||
if (language === "python3") {
|
||||
const { parse_python } = await import(
|
||||
"./wasm/python/windmill_parser_wasm.js"
|
||||
"./wasm/py/windmill_parser_wasm.js"
|
||||
);
|
||||
inferedSchema = JSON.parse(parse_python(content));
|
||||
} else if (language === "nativets") {
|
||||
|
||||
13
cli/test.nu
13
cli/test.nu
@@ -22,7 +22,7 @@ const languages = [
|
||||
"graphql",
|
||||
"bash",
|
||||
"powershell",
|
||||
# "php",
|
||||
"php",
|
||||
"rust",
|
||||
"csharp",
|
||||
"nu",
|
||||
@@ -37,29 +37,36 @@ def main [] {
|
||||
|
||||
def 'main test deno' [] {
|
||||
main clean;
|
||||
print $"Testing Deno"
|
||||
$languages | each { |l|
|
||||
print $"+ ($l)"
|
||||
deno run -A ../cli/main.ts script bootstrap $"f/tests/(random uuid)" $l
|
||||
}
|
||||
deno run -A ../cli/main.ts script generate-metadata
|
||||
print $"\nDeno has passed!\n"
|
||||
}
|
||||
|
||||
def 'main test node' [] {
|
||||
# TODO: Use node
|
||||
main clean;
|
||||
print $"Testing Node"
|
||||
$languages | each { |l|
|
||||
print $"+ ($l)"
|
||||
node ../cli/npm/esm/main.js script bootstrap $"f/tests/(random uuid)" $l
|
||||
}
|
||||
node ../cli/npm/esm/main.js script generate-metadata
|
||||
print $"\nNode has passed!\n"
|
||||
}
|
||||
|
||||
def 'main clean' [] {
|
||||
print $"Cleaning"
|
||||
rm -rf f/tests/*
|
||||
mkdir f/tests
|
||||
}
|
||||
|
||||
def 'main build' [] {
|
||||
../cli/build.sh
|
||||
print $"Building..."
|
||||
cd ../cli; ./build.sh
|
||||
cd ../local
|
||||
}
|
||||
|
||||
# def main [] {
|
||||
|
||||
4
cli/wasm/py/windmill_parser_wasm.d.ts
vendored
Normal file
4
cli/wasm/py/windmill_parser_wasm.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export function parse_python(code: string, main_override?: string | null): string;
|
||||
export function parse_assets_py(code: string): string;
|
||||
147
cli/wasm/py/windmill_parser_wasm.js
Normal file
147
cli/wasm/py/windmill_parser_wasm.js
Normal file
@@ -0,0 +1,147 @@
|
||||
|
||||
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
|
||||
let cachedUint8ArrayMemory0 = null;
|
||||
|
||||
function getUint8ArrayMemory0() {
|
||||
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
||||
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachedUint8ArrayMemory0;
|
||||
}
|
||||
|
||||
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
||||
|
||||
const encodeString = function (arg, view) {
|
||||
return cachedTextEncoder.encodeInto(arg, view);
|
||||
};
|
||||
|
||||
function passStringToWasm0(arg, malloc, realloc) {
|
||||
|
||||
if (realloc === undefined) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
const ptr = malloc(buf.length, 1) >>> 0;
|
||||
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
||||
WASM_VECTOR_LEN = buf.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
let len = arg.length;
|
||||
let ptr = malloc(len, 1) >>> 0;
|
||||
|
||||
const mem = getUint8ArrayMemory0();
|
||||
|
||||
let offset = 0;
|
||||
|
||||
for (; offset < len; offset++) {
|
||||
const code = arg.charCodeAt(offset);
|
||||
if (code > 0x7F) break;
|
||||
mem[ptr + offset] = code;
|
||||
}
|
||||
|
||||
if (offset !== len) {
|
||||
if (offset !== 0) {
|
||||
arg = arg.slice(offset);
|
||||
}
|
||||
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
||||
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
||||
const ret = encodeString(arg, view);
|
||||
|
||||
offset += ret.written;
|
||||
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
||||
}
|
||||
|
||||
WASM_VECTOR_LEN = offset;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function isLikeNone(x) {
|
||||
return x === undefined || x === null;
|
||||
}
|
||||
|
||||
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
||||
|
||||
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
||||
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
ptr = ptr >>> 0;
|
||||
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
/**
|
||||
* @param {string} code
|
||||
* @param {string | null} [main_override]
|
||||
* @returns {string}
|
||||
*/
|
||||
export function parse_python(code, main_override) {
|
||||
let deferred3_0;
|
||||
let deferred3_1;
|
||||
try {
|
||||
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
var ptr1 = isLikeNone(main_override) ? 0 : passStringToWasm0(main_override, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
var len1 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.parse_python(ptr0, len0, ptr1, len1);
|
||||
deferred3_0 = ret[0];
|
||||
deferred3_1 = ret[1];
|
||||
return getStringFromWasm0(ret[0], ret[1]);
|
||||
} finally {
|
||||
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} code
|
||||
* @returns {string}
|
||||
*/
|
||||
export function parse_assets_py(code) {
|
||||
let deferred2_0;
|
||||
let deferred2_1;
|
||||
try {
|
||||
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const len0 = WASM_VECTOR_LEN;
|
||||
const ret = wasm.parse_assets_py(ptr0, len0);
|
||||
deferred2_0 = ret[0];
|
||||
deferred2_1 = ret[1];
|
||||
return getStringFromWasm0(ret[0], ret[1]);
|
||||
} finally {
|
||||
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
const imports = {
|
||||
__wbindgen_placeholder__: {
|
||||
__wbindgen_init_externref_table: function() {
|
||||
const table = wasm.__wbindgen_export_0;
|
||||
const offset = table.grow(4);
|
||||
table.set(0, undefined);
|
||||
table.set(offset + 0, undefined);
|
||||
table.set(offset + 1, null);
|
||||
table.set(offset + 2, true);
|
||||
table.set(offset + 3, false);
|
||||
;
|
||||
},
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
const wasm_url = new URL('windmill_parser_wasm_bg.wasm', import.meta.url);
|
||||
let wasmCode = '';
|
||||
switch (wasm_url.protocol) {
|
||||
case 'file:':
|
||||
wasmCode = await Deno.readFile(wasm_url);
|
||||
break
|
||||
case 'https:':
|
||||
case 'http:':
|
||||
wasmCode = await (await fetch(wasm_url)).arrayBuffer();
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported protocol: ${wasm_url.protocol}`);
|
||||
}
|
||||
|
||||
const wasmInstance = (await WebAssembly.instantiate(wasmCode, imports)).instance;
|
||||
const wasm = wasmInstance.exports;
|
||||
export const __wasm = wasm;
|
||||
|
||||
wasm.__wbindgen_start();
|
||||
|
||||
BIN
cli/wasm/py/windmill_parser_wasm_bg.wasm
Normal file
BIN
cli/wasm/py/windmill_parser_wasm_bg.wasm
Normal file
Binary file not shown.
10
cli/wasm/py/windmill_parser_wasm_bg.wasm.d.ts
vendored
Normal file
10
cli/wasm/py/windmill_parser_wasm_bg.wasm.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const memory: WebAssembly.Memory;
|
||||
export const parse_python: (a: number, b: number, c: number, d: number) => [number, number];
|
||||
export const parse_assets_py: (a: number, b: number) => [number, number];
|
||||
export const __wbindgen_export_0: WebAssembly.Table;
|
||||
export const __wbindgen_malloc: (a: number, b: number) => number;
|
||||
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
||||
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
||||
export const __wbindgen_start: () => void;
|
||||
Reference in New Issue
Block a user