Skip to content

Commit

Permalink
Feat: Add Typescript Guest Support (#103)
Browse files Browse the repository at this point in the history
* Adding typescript guest templates & standardizing compile templates

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>

* Fixing golang linter

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>

* invalid wasm modules being outputted

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>

* Add: js_builder-x86_64-unknown-linux-gnu

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Add: js_builder-aarch64-unknown-linux-gnu

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Add: js_builder-aarch64-apple-darwin

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Add: js_builder-x86_64-apple-darwin

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Add: js_builder-x86_64-pc-windows-msvc

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Working integration tests

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>

* Adding typescript stdout and stderr

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>

* Fixing linter errors

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>

* Add: js_builder-aarch64-unknown-linux-gnu

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Add: js_builder-x86_64-unknown-linux-gnu

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Add: js_builder-x86_64-apple-darwin

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Add: js_builder-aarch64-apple-darwin

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Add: js_builder-x86_64-pc-windows-msvc

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Updating some error files

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>

* Adding node_modules for signature and typescript function

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>

* Add: js_builder-x86_64-pc-windows-msvc

Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

---------

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>
Signed-off-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
ShivanshVij and github-actions[bot] authored Sep 12, 2023
1 parent 8e861cc commit 6904ec4
Show file tree
Hide file tree
Showing 4,427 changed files with 1,248,455 additions and 924 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
37 changes: 11 additions & 26 deletions build/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"io"
"os"
"os/exec"
"path"
Expand All @@ -38,8 +39,8 @@ var (
)

type LocalGolangOptions struct {
// Version is the generator version
Version string
// Output is the output writer for the various build commands
Output io.Writer

// Scalefile is the scalefile to be built
Scalefile *scalefile.Schema
Expand Down Expand Up @@ -155,25 +156,12 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.Schema, error) {
_ = options.Storage.Delete(build)
}()

dependencies := []*scalefunc.Dependency{
{
Name: "signature",
Version: "v0.1.0",
Metadata: nil,
},
{
Name: options.Scalefile.Name,
Version: "v0.1.0",
Metadata: nil,
},
}

modfile, err := golang.GenerateGoModfile(options.Scalefile, signatureDependencyPath, signatureDependencyVersion, options.SourceDirectory, dependencies, "compile")
modfile, err := golang.GenerateGoModfile(options.Scalefile, signatureDependencyPath, signatureDependencyVersion, options.SourceDirectory)
if err != nil {
return nil, fmt.Errorf("unable to generate go.mod file: %w", err)
}

mainFile, err := golang.GenerateGoMain(options.SignatureSchema, options.Scalefile, options.Version)
mainFile, err := golang.GenerateGoMain(options.Scalefile, options.SignatureSchema)
if err != nil {
return nil, fmt.Errorf("unable to generate main.go file: %w", err)
}
Expand All @@ -197,11 +185,10 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.Schema, error) {

cmd := exec.Command(options.GoBin, "mod", "tidy")
cmd.Dir = compilePath
output, err := cmd.CombinedOutput()
cmd.Stdout = options.Output
cmd.Stderr = options.Output
err = cmd.Run()
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
return nil, fmt.Errorf("unable to compile scale function: %s", output)
}
return nil, fmt.Errorf("unable to compile scale function: %w", err)
}

Expand All @@ -221,12 +208,10 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.Schema, error) {

cmd = exec.Command(options.TinyGoBin, buildArgs...)
cmd.Dir = compilePath

output, err = cmd.CombinedOutput()
cmd.Stdout = options.Output
cmd.Stderr = options.Output
err = cmd.Run()
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
return nil, fmt.Errorf("unable to compile scale function: %s", output)
}
return nil, fmt.Errorf("unable to compile scale function: %w", err)
}

Expand Down
26 changes: 12 additions & 14 deletions build/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"io"
"os"
"os/exec"
"path"
Expand All @@ -37,8 +38,8 @@ var (
)

type LocalRustOptions struct {
// Version is the generator version
Version string
// Output is the output writer for the various build commands
Output io.Writer

// Scalefile is the scalefile to be built
Scalefile *scalefile.Schema
Expand Down Expand Up @@ -132,12 +133,12 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) {
_ = options.Storage.Delete(build)
}()

cargofile, err := rust.GenerateRustCargofile(options.Scalefile, signatureDependency, options.SourceDirectory, nil, "compile", "0.1.0")
cargofile, err := rust.GenerateRustCargofile(options.Scalefile, signatureDependency, options.SourceDirectory)
if err != nil {
return nil, fmt.Errorf("unable to generate cargo.toml file: %w", err)
}

libFile, err := rust.GenerateRustLib(options.SignatureSchema, options.Scalefile, options.Version)
libFile, err := rust.GenerateRustLib(options.Scalefile)
if err != nil {
return nil, fmt.Errorf("unable to generate lib.rs file: %w", err)
}
Expand All @@ -161,11 +162,10 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) {

cmd := exec.Command(options.CargoBin, "check")
cmd.Dir = compilePath
output, err := cmd.CombinedOutput()
cmd.Stdout = options.Output
cmd.Stderr = options.Output
err = cmd.Run()
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
return nil, fmt.Errorf("unable to compile scale function: %s", output)
}
return nil, fmt.Errorf("unable to compile scale function: %w", err)
}

Expand All @@ -185,12 +185,10 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) {

cmd = exec.Command(options.CargoBin, buildArgs...)
cmd.Dir = compilePath

output, err = cmd.CombinedOutput()
cmd.Stdout = options.Output
cmd.Stderr = options.Output
err = cmd.Run()
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
return nil, fmt.Errorf("unable to compile scale function: %s", output)
}
return nil, fmt.Errorf("unable to compile scale function: %w", err)
}

Expand All @@ -215,7 +213,7 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.Schema, error) {
SignatureName: fmt.Sprintf("%s/%s:%s", options.Scalefile.Signature.Organization, options.Scalefile.Signature.Name, options.Scalefile.Signature.Tag),
SignatureSchema: options.SignatureSchema,
SignatureHash: hex.EncodeToString(hash),
Language: scalefunc.Go,
Language: scalefunc.Rust,
Stateless: options.Scalefile.Stateless,
Dependencies: nil,
Function: data,
Expand Down
Loading

0 comments on commit 6904ec4

Please sign in to comment.