Skip to content

Commit

Permalink
Installing deps for integraiton test
Browse files Browse the repository at this point in the history
Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>
  • Loading branch information
ShivanshVij committed Nov 14, 2023
1 parent ce5cc2e commit f45ccb4
Show file tree
Hide file tree
Showing 20 changed files with 3,793 additions and 29 deletions.
4 changes: 2 additions & 2 deletions build/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.V1BetaSchema, error) {
return nil, fmt.Errorf("unable to generate go.mod file: %w", err)
}

mainFile, err := golang.GenerateGoMain(options.Scalefile, functionInfo)
mainFile, err := golang.GenerateGoMain(options.Scalefile, options.SignatureSchema, functionInfo)
if err != nil {
return nil, fmt.Errorf("unable to generate main.go file: %w", err)
}
Expand Down Expand Up @@ -239,7 +239,7 @@ func LocalGolang(options *LocalGolangOptions) (*scalefunc.V1BetaSchema, error) {
return nil, fmt.Errorf("unknown build target %d", options.Target)
}

buildArgs := append([]string{"build", "-o", "scale.wasm", "-gc=conservative", "-opt=s", "-panic=abort"}, options.Args...)
buildArgs := append([]string{"build", "-o", "scale.wasm", "-gc=conservative", "-opt=s"}, options.Args...)
if options.Release {
buildArgs = append(buildArgs, "-no-debug")
}
Expand Down
2 changes: 1 addition & 1 deletion build/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func LocalRust(options *LocalRustOptions) (*scalefunc.V1BetaSchema, error) {
return nil, fmt.Errorf("unable to generate cargo.toml file: %w", err)
}

libFile, err := rust.GenerateRustLib(options.Scalefile)
libFile, err := rust.GenerateRustLib(options.Scalefile, functionInfo)
if err != nil {
return nil, fmt.Errorf("unable to generate lib.rs file: %w", err)
}
Expand Down
9 changes: 6 additions & 3 deletions compile/golang/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"go/format"
"text/template"

"github.com/loopholelabs/scale/signature"

"github.com/loopholelabs/scale/version"

"github.com/loopholelabs/scale/compile/golang/templates"
Expand All @@ -30,8 +32,8 @@ func GenerateGoModfile(signatureInfo *SignatureInfo, functionInfo *FunctionInfo)
return generator.GenerateGoModfile(signatureInfo, functionInfo)
}

func GenerateGoMain(scalefileSchema *scalefile.Schema, functionInfo *FunctionInfo) ([]byte, error) {
return generator.GenerateGoMain(scalefileSchema, functionInfo)
func GenerateGoMain(scalefileSchema *scalefile.Schema, signatureSchema *signature.Schema, functionInfo *FunctionInfo) ([]byte, error) {
return generator.GenerateGoMain(scalefileSchema, signatureSchema, functionInfo)
}

func init() {
Expand Down Expand Up @@ -64,13 +66,14 @@ func (g *Generator) GenerateGoModfile(signatureInfo *SignatureInfo, functionInfo
return buf.Bytes(), nil
}

func (g *Generator) GenerateGoMain(scalefileSchema *scalefile.Schema, functionInfo *FunctionInfo) ([]byte, error) {
func (g *Generator) GenerateGoMain(scalefileSchema *scalefile.Schema, signatureSchema *signature.Schema, functionInfo *FunctionInfo) ([]byte, error) {
functionInfo.normalize()

buf := new(bytes.Buffer)
err := g.template.ExecuteTemplate(buf, "main.go.templ", map[string]interface{}{
"generatorVersion": version.Version(),
"scalefileSchema": scalefileSchema,
"signatureSchema": signatureSchema,
"function": functionInfo,
})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion compile/golang/templates/main.go.templ
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func initialize() uint64 {
//go:export run
func run() uint64 {
var err error
ctx := signature.New{{ .scalefileSchema.Context }}()
ctx := signature.New{{ .signatureSchema.Context }}()
ctx, err = signature.Read(ctx)
if err != nil {
return packUint32(signature.Error(err))
Expand Down
7 changes: 4 additions & 3 deletions compile/rust/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func GenerateRustCargofile(signatureInfo *SignatureInfo, functionInfo *FunctionI
return generator.GenerateRustCargofile(signatureInfo, functionInfo)
}

func GenerateRustLib(scalefileSchema *scalefile.Schema) ([]byte, error) {
return generator.GenerateRustLib(scalefileSchema)
func GenerateRustLib(scalefileSchema *scalefile.Schema, functionInfo *FunctionInfo) ([]byte, error) {
return generator.GenerateRustLib(scalefileSchema, functionInfo)
}

func init() {
Expand Down Expand Up @@ -64,11 +64,12 @@ func (g *Generator) GenerateRustCargofile(signatureInfo *SignatureInfo, function
return buf.Bytes(), nil
}

func (g *Generator) GenerateRustLib(scalefileSchema *scalefile.Schema) ([]byte, error) {
func (g *Generator) GenerateRustLib(scalefileSchema *scalefile.Schema, functionInfo *FunctionInfo) ([]byte, error) {
buf := new(bytes.Buffer)
err := g.template.ExecuteTemplate(buf, "lib.rs.templ", map[string]interface{}{
"generatorVersion": strings.TrimPrefix(version.Version(), "v"),
"scalefileSchema": scalefileSchema,
"function": functionInfo,
})
if err != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions compile/typescript/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func GenerateTypescriptPackageJSON(signatureInfo *SignatureInfo) ([]byte, error)
return generator.GenerateTypescriptPackageJSON(signatureInfo)
}

func GenerateTypescriptIndex(packageSchema *scalefile.Schema, function *FunctionInfo) ([]byte, error) {
return generator.GenerateTypescriptIndex(packageSchema, function)
func GenerateTypescriptIndex(packageSchema *scalefile.Schema, functionInfo *FunctionInfo) ([]byte, error) {
return generator.GenerateTypescriptIndex(packageSchema, functionInfo)
}

func init() {
Expand Down Expand Up @@ -62,14 +62,14 @@ func (g *Generator) GenerateTypescriptPackageJSON(signatureInfo *SignatureInfo)
return buf.Bytes(), nil
}

func (g *Generator) GenerateTypescriptIndex(scalefileSchema *scalefile.Schema, function *FunctionInfo) ([]byte, error) {
function.normalize()
func (g *Generator) GenerateTypescriptIndex(scalefileSchema *scalefile.Schema, functionInfo *FunctionInfo) ([]byte, error) {
functionInfo.normalize()

buf := new(bytes.Buffer)
err := g.template.ExecuteTemplate(buf, "index.ts.templ", map[string]interface{}{
"generatorVersion": strings.TrimPrefix(version.Version(), "v"),
"scalefileSchema": scalefileSchema,
"function": function,
"function": functionInfo,
})
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
////go:build integration && !generate
//go:build integration && !generate

/*
Copyright 2023 Loophole Labs
Expand Down Expand Up @@ -211,7 +211,7 @@ func compileTypescriptGuest(t *testing.T) *scalefunc.V1BetaSchema {
assert.Equal(t, scf.Signature.Tag, schema.Signature.Tag)
assert.Equal(t, s, schema.Signature.Schema)
assert.Equal(t, hex.EncodeToString(hash), schema.Signature.Hash)
assert.Equal(t, scalefunc.Rust, schema.Language)
assert.Equal(t, scalefunc.TypeScript, schema.Language)
assert.Equal(t, 0, len(schema.Extensions))

return schema
Expand Down
2 changes: 1 addition & 1 deletion integration/typescript_tests/host_signature/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by scale-signature 0.4.3, DO NOT EDIT.
// Code generated by scale-signature 0.4.5, DO NOT EDIT.
// output: local-example-latest-host

import { Signature as SignatureInterface } from "@loopholelabs/scale-signature-interfaces";
Expand Down
2 changes: 1 addition & 1 deletion integration/typescript_tests/host_signature/index.js

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/host_signature/index.js.map

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

Loading

0 comments on commit f45ccb4

Please sign in to comment.