Skip to content

Commit

Permalink
Adding builder libs
Browse files Browse the repository at this point in the history
Signed-off-by: Shivansh Vij <[email protected]>
  • Loading branch information
ShivanshVij committed Sep 6, 2023
1 parent 4aa0692 commit ac8fea1
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 56 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/typescript_compiler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Typescript Builder

on:
pull_request:
paths:
- "compile/typescript/builder/**"

jobs:
interpreter:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Rust
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
rustup target add wasm32-wasi
shell: bash

- name: Make interpreter
working-directory: compile/typescript/builder
run: make interpreter

- name: Upload core binary to artifacts
uses: actions/upload-artifact@v3
with:
name: interpreter
path: compile/typescript/builder/interpreter/target/wasm32-wasi/release/js_interpreter.wasm

builder:
name: builder-${{ matrix.name }}
needs: interpreter
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: x86_64-unknown-linux-gnu
os: ubuntu-20.04

- name: aarch64-unknown-linux-gnu
os: ubuntu-20.04

- name: x86_64-apple-darwin
os: macos-latest

- name: aarch64-apple-darwin
os: macos-latest

- name: x86_64-pc-windows-msvc
os: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Rust
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
rustup target add ${{ matrix.name }}
shell: bash

- name: Install ARM GCC toolchain
run: sudo apt-get --assume-yes install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
if: matrix.name == 'aarch64-unknown-linux-gnu'

- uses: actions/download-artifact@v3
with:
name: interpreter
path: compile/typescript/builder/interpreter/target/wasm32-wasi/release/

- name: Build CLI ${{ matrix.name }}
working-directory: compile/typescript/builder
run: make builder-${{ matrix.name }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc

- name: Commit CLI ${{ matrix.name }} Binary
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
commit: "--signoff"
message: "Add: js_builder-${{ matrix.name }}"
add: js_builder-${{ matrix.name }}
8 changes: 0 additions & 8 deletions compile/typescript/builder/Cross.toml

This file was deleted.

12 changes: 5 additions & 7 deletions compile/typescript/builder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@ install:
builder: interpreter
cargo build --release

builder-all-targets: interpreter builder-x86_64-unknown-linux-gnu builder-aarch64-unknown-linux-gnu builder-x86_64-apple-darwin builder-aarch64-apple-darwin builder-x86_64-pc-windows-msvc

builder-x86_64-unknown-linux-gnu:
cargo build --release --target=x86_64-unknown-linux-gnu
cargo build --release --target=x86_64-unknown-linux-gnu && cp target/x86_64-unknown-linux-gnu/release/js_builder js_builder-x86_64-unknown-linux-gnu

builder-aarch64-unknown-linux-gnu:
cargo build --release --target=aarch64-unknown-linux-gnu
cargo build --release --target=aarch64-unknown-linux-gnu && cp target/aarch64-unknown-linux-gnu/release/js_builder js_builder-aarch64-unknown-linux-gnu

builder-x86_64-apple-darwin:
cargo build --release --target=x86_64-apple-darwin
cargo build --release --target=x86_64-apple-darwin && cp target/x86_64-apple-darwin/release/js_builder js_builder-x86_64-apple-darwin

builder-aarch64-apple-darwin:
cargo build --release --target=aarch64-apple-darwin
cargo build --release --target=aarch64-apple-darwin && cp target/aarch64-apple-darwin/release/js_builder js_builder-aarch64-apple-darwin

builder-x86_64-pc-windows-msvc:
cargo build --release --target=x86_64-pc-windows-msvc
cargo build --release --target=x86_64-pc-windows-msvc && cp target/x86_64-pc-windows-msvc/release/js_builder.exe js_builder-x86_64-pc-windows-msvc.exe

interpreter:
cd interpreter && cargo build --release --target=wasm32-wasi && cd -
Expand Down
19 changes: 0 additions & 19 deletions compile/typescript/builder/generate.go

This file was deleted.

15 changes: 10 additions & 5 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class ConfigFunction {
}

export class Config<T extends Signature> {
newSignature: New<T>;
functions: ConfigFunction[] = [];
private newSignature: New<T>;
private functions: ConfigFunction[] = [];

constructor(newSignature: New<T>) {
this.newSignature = newSignature;
}

validate(): Error | null {
public validate(): Error | null {
if (!this) {
return new Error("no config provided");
}
Expand All @@ -59,7 +59,12 @@ export class Config<T extends Signature> {
return null;
}

withFunction(func: ScaleFunc, env?: { [key: string]: string }): Config<T> {
public withSignature(newSignature: New<T>): Config<T> {
this.newSignature = newSignature;
return this;
}

public withFunction(func: ScaleFunc, env?: { [key: string]: string }): Config<T> {
const f = new ConfigFunction(func, env);
f.function = func;

Expand All @@ -71,7 +76,7 @@ export class Config<T extends Signature> {
return this;
}

withFunctions(functions: ScaleFunc[], env?: { [key: string]: string }): Config<T> {
public withFunctions(functions: ScaleFunc[], env?: { [key: string]: string }): Config<T> {
for (const func of functions) {
this.withFunction(func, env);
}
Expand Down
12 changes: 3 additions & 9 deletions integration/golang_tests/signature/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ module signature
go 1.20

require (
github.com/loopholelabs/polyglot v1.1.3
github.com/stretchr/testify v1.8.4
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
github.com/loopholelabs/polyglot v1.1.3
github.com/loopholelabs/scale-signature-interfaces v0.1.7
)
1 change: 1 addition & 0 deletions integration/golang_tests/signature/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/loopholelabs/polyglot v1.1.3 h1:WUTcSZ2TQ1lv7CZ4I9nHFBUjf0hKJN+Yfz1rZZJuTP0=
github.com/loopholelabs/polyglot v1.1.3/go.mod h1:EA88BEkIluKHAWxhyOV88xXz68YkRdo9IzZ+1dj+7Ao=
github.com/loopholelabs/scale-signature-interfaces v0.1.7/go.mod h1:3XLMjJjBf5lYxMtNKk+2XAWye4UyrkvUBJ9L6x2QCAk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
Expand Down
2 changes: 1 addition & 1 deletion integration/golang_tests/signature/guest.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration/rust_tests/signature/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ version = "0.7.0"
version = "1.9.4"

[dependencies.scale_signature_interfaces]
version = "0.1.6"
version = "0.1.7"

[dependencies.polyglot_rs]
version = "1.1.3"
2 changes: 1 addition & 1 deletion integration/typescript_tests/host_signature/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
},
"dependencies": {
"@loopholelabs/polyglot": "^1.1.3",
"@loopholelabs/scale-signature-interfaces": "^0.1.6"
"@loopholelabs/scale-signature-interfaces": "^0.1.7"
}
}
2 changes: 1 addition & 1 deletion integration/typescript_tests/signature/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions integration/typescript_tests/signature/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration/typescript_tests/signature/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
},
"dependencies": {
"@loopholelabs/polyglot": "^1.1.3",
"@loopholelabs/scale-signature-interfaces": "^0.1.6"
"@loopholelabs/scale-signature-interfaces": "^0.1.7"
}
}
2 changes: 1 addition & 1 deletion signature/generator/rust/templates/guest.rs.templ
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn next(ctx: Option<&mut types::{{ .signature_schema.Context }}>) -> Result<
}
}
#[link(wasm_import_module = "scale")]
#[link(wasm_import_module = "env")]
extern "C" {
#[link_name = "next"]
fn _next(ptr: u32, size: u32);
Expand Down

0 comments on commit ac8fea1

Please sign in to comment.