Skip to content

Commit

Permalink
Adding WASM-specific target for building, and enabling typescript sig…
Browse files Browse the repository at this point in the history
…nature generation

Signed-off-by: Shivansh Vij <[email protected]>
  • Loading branch information
ShivanshVij committed Oct 5, 2023
1 parent b797dc2 commit 5f5dbf6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ type Target int

const (
WASITarget Target = iota
WASMTarget
)
2 changes: 2 additions & 0 deletions build/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.Schema, error) {
switch options.Target {
case WASITarget:
target = "wasi"
case WASMTarget:
target = "wasm"
default:
return nil, fmt.Errorf("unknown build target %d", options.Target)
}
Expand Down
2 changes: 2 additions & 0 deletions build/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) {
switch options.Target {
case WASITarget:
target = "wasm32-wasi"
case WASMTarget:
target = "wasm32-unknown-unknown"
default:
return nil, fmt.Errorf("unknown build target %d", options.Target)
}
Expand Down
2 changes: 2 additions & 0 deletions build/typescript.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ func LocalTypescript(options *LocalTypescriptOptions) (*scalefunc.Schema, error)
switch options.Target {
case WASITarget:
target = api.PlatformNode
case WASMTarget:
target = api.PlatformBrowser
default:
return nil, fmt.Errorf("unknown build target %d", options.Target)
}
Expand Down
16 changes: 12 additions & 4 deletions storage/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
)

const (
defaultVersion = "v0.1.0"
SignatureDirectory = "signatures"
)

Expand Down Expand Up @@ -311,10 +312,13 @@ func GenerateSignature(sig *signature.Schema, name string, tag string, org strin
Signature: sig,

GolangPackageImportPath: "signature",
GolangPackageVersion: "v0.1.0",
GolangPackageVersion: defaultVersion,

RustPackageName: fmt.Sprintf("%s_%s_%s_guest", org, name, tag),
RustPackageVersion: "0.1.0",
RustPackageVersion: defaultVersion,

TypescriptPackageName: fmt.Sprintf("%s-%s-%s-guest", org, name, tag),
TypescriptPackageVersion: defaultVersion,
})
if err != nil {
return err
Expand All @@ -335,9 +339,13 @@ func GenerateSignature(sig *signature.Schema, name string, tag string, org strin
}

hostPackage, err := generator.GenerateHostLocal(&generator.Options{
Signature: sig,
Signature: sig,

GolangPackageImportPath: "signature",
GolangPackageVersion: "v0.1.0",
GolangPackageVersion: defaultVersion,

TypescriptPackageName: fmt.Sprintf("%s-%s-%s-host", org, name, tag),
TypescriptPackageVersion: defaultVersion,
})
if err != nil {
return err
Expand Down

0 comments on commit 5f5dbf6

Please sign in to comment.