Build automation (#123)

* preparation

* trying to automate

* fix

* implement logic in powershell

* fix

* tmp

* tmp

* fix

* remove debug stuff

* newline in gitignore

* Remove debug echos
This commit is contained in:
Pavel 2021-08-03 23:13:47 +03:00 committed by GitHub
parent 680d6236b1
commit 0528eb485a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 16 deletions

View File

@ -5,3 +5,4 @@ wasm
# this file is auto-generated
src/wasm.js
src/importObject.ts

View File

@ -2,10 +2,24 @@
New-Item -ItemType Directory -Force -Path ./wasm
wasm-pack build ../../air-interpreter --no-typescript --release -d ../avm/client/wasm
$base64string = [Convert]::ToBase64String([IO.File]::ReadAllBytes('./avm/client/wasm/air_interpreter_client_bg.wasm'))
$base64string = [Convert]::ToBase64String([IO.File]::ReadAllBytes('./wasm/air_interpreter_client_bg.wasm'))
$data = "// auto-generated
module.exports = `"${base64string}`""
$data | Out-File "./src/wasm.js"
$__wbg_callserviceimpl = Get-Content wasm/air_interpreter_client_bg.js | Select-String -Pattern __wbg_callserviceimpl\w+
$__wbg_getcurrentpeeridimpl = Get-Content wasm/air_interpreter_client_bg.js | Select-String -Pattern __wbg_getcurrentpeeridimpl_\w+
$__wbg_callserviceimpl = $__wbg_callserviceimpl.matches[0].value
$__wbg_getcurrentpeeridimpl = $__wbg_getcurrentpeeridimpl.matches[0].value
$data = "// auto-generated
export const __wbg_callserviceimpl = '${__wbg_callserviceimpl}';
export const __wbg_getcurrentpeeridimpl = '${__wbg_getcurrentpeeridimpl}';"
$data | Out-File "./src/importObject.ts"

View File

@ -14,3 +14,13 @@ cat << EOF > ./src/wasm.js
module.exports = "$(base64 -w0 wasm/air_interpreter_client_bg.wasm)";
EOF
callserviceimpl=$(cat wasm/air_interpreter_client_bg.js | grep -o '__wbg_callserviceimpl_\w*')
getcurrentpeeridimpl=$(cat wasm/air_interpreter_client_bg.js | grep -o '__wbg_getcurrentpeeridimpl_\w*')
cat << EOF > ./src/importObject.ts
// auto-generated
export const __wbg_callserviceimpl = "$callserviceimpl";
export const __wbg_getcurrentpeeridimpl = "$getcurrentpeeridimpl";
EOF

View File

@ -17,6 +17,7 @@
import { toByteArray } from 'base64-js';
import { return_current_peer_id, return_call_service_result, getStringFromWasm0, free, invoke, ast } from './wrapper';
import wasmBs64 from './wasm';
import { __wbg_callserviceimpl, __wbg_getcurrentpeeridimpl } from './importObject';
export type LogLevel = 'info' | 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'off';
@ -44,24 +45,24 @@ export type ParticleHandler = (
tetraplets: SecurityTetraplet[][],
) => CallServiceResult;
type ImportObject = {
'./air_interpreter_client_bg.js': {
// fn call_service_impl(service_id: String, fn_name: String, args: String, security_tetraplets: String) -> String;
// prettier-ignore
__wbg_callserviceimpl_34891090e13ace2e: (arg0: any, arg1: any, arg2: any, arg3: any, arg4: any, arg5: any, arg6: any, arg7: any, arg8: any, ) => void;
__wbg_getcurrentpeeridimpl_ecf9cb0901ce08ba: (arg0: any) => void;
__wbindgen_throw: (arg: any) => void;
};
host: LogImport;
};
type Exports = any;
type Instance = any;
type ExportValue = any;
type LogImport = {
log_utf8_string: (level: any, target: any, offset: any, size: any) => void;
};
type Exports = any;
type Instance = any;
type ExportValue = any;
type ImportObject = {
'./air_interpreter_client_bg.js': {
// fn call_service_impl(service_id: String, fn_name: String, args: String, security_tetraplets: String) -> String;
// prettier-ignore
[__wbg_callserviceimpl]: (arg0: any, arg1: any, arg2: any, arg3: any, arg4: any, arg5: any, arg6: any, arg7: any, arg8: any, ) => void;
[__wbg_getcurrentpeeridimpl]: (arg0: any) => void;
__wbindgen_throw: (arg: any) => void;
};
host: LogImport;
};
class HostImportsConfig {
exports: Exports | undefined;
@ -153,7 +154,7 @@ function newImportObject(
// If so, an error with a new name will be occurred after wasm initialization.
'./air_interpreter_client_bg.js': {
// prettier-ignore
__wbg_callserviceimpl_34891090e13ace2e: (arg0: any, arg1: any, arg2: any, arg3: any, arg4: any, arg5: any, arg6: any, arg7: any, arg8: any) => {
[__wbg_callserviceimpl]: (arg0: any, arg1: any, arg2: any, arg3: any, arg4: any, arg5: any, arg6: any, arg7: any, arg8: any) => {
let wasm = cfg.exports;
let serviceId = getStringFromWasm0(wasm, arg1, arg2);
let fnName = getStringFromWasm0(wasm, arg3, arg4);
@ -182,7 +183,7 @@ function newImportObject(
let resultStr = JSON.stringify(serviceResult);
return_call_service_result(wasm, resultStr, arg0);
},
__wbg_getcurrentpeeridimpl_ecf9cb0901ce08ba: (arg0: any) => {
[__wbg_getcurrentpeeridimpl]: (arg0: any) => {
let wasm = cfg.exports;
return_current_peer_id(wasm, peerId, arg0);
},