Skip to content

Commit

Permalink
Rust new function now includes extensions in cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyaxod committed Sep 22, 2023
1 parent 0482ae0 commit 8c79234
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
11 changes: 9 additions & 2 deletions cmd/function/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,16 @@ func NewCmd(hidden bool) command.SetupCommand[*config.Config] {
extensionData = append(extensionData, extension.ExtensionInfo{
Name: ext.Schema.Name,
Path: path.Join(extensionPath, "golang", "guest"),
Version: "v0.1.0",
Version: "0.1.0",
})
case scalefunc.Rust:
extensionData = append(extensionData, extension.ExtensionInfo{
Name: ext.Schema.Name,
Path: path.Join(extensionPath, "rust", "guest"),
Version: "0.1.0",
})
default:
panic("Only go extension for now")
panic("Only go or rust extension for now")
}
} else {
panic("Only local extension for now")
Expand Down Expand Up @@ -292,6 +298,7 @@ func NewCmd(hidden bool) command.SetupCommand[*config.Config] {
"signature_version": signatureVersion,
"signature_path": signaturePath,
"registry": "scale",
"extensions": extensionData,
})
if err != nil {
_ = dependencyFile.Close()
Expand Down
17 changes: 9 additions & 8 deletions ext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,22 @@ echo "Exporting function"
mkdir ext/fn-rs
echo "Creating function"
./cmd/cmd function new -d ext/fn-rs -s local/testsig:latest -e local/testext:latest -l rust testfnrs:latest
# cat ext/fn_code.rs > ext/fn-rs/main.rs
cat ext/fn_code.rs > ext/fn-rs/lib.rs
echo "Building function"
./cmd/cmd function build -d ext/fn-rs
echo "Exporting function"
./cmd/cmd function export local/testfnrs:latest ext/


# Create a function using the extension in Typescript
mkdir ext/fn-ts
echo "Creating function"
./cmd/cmd function new -d ext/fn-ts -s local/testsig:latest -e local/testext:latest -l rust testfnts:latest
#mkdir ext/fn-ts
#echo "Creating function"
#./cmd/cmd function new -d ext/fn-ts -s local/testsig:latest -e local/testext:latest -l rust testfnts:latest
# cat ext/fn_code.ts > ext/fn-ts/main.ts
echo "Building function"
./cmd/cmd function build -d ext/fn-ts
echo "Exporting function"
./cmd/cmd function export local/testfnts:latest ext/
#echo "Building function"
#./cmd/cmd function build -d ext/fn-ts
#echo "Exporting function"
#./cmd/cmd function export local/testfnts:latest ext/

# Sort out runner
echo "Updating runner go.mod..."
Expand Down
1 change: 1 addition & 0 deletions ext/runner/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ require (




replace signature => /home/jimmy/.config/scale/signatures/local_testsig_latest_e6ddebc792ee929e2654b4281baca1376e05bf5a96d4bdf63a05a2aab5f9e749_signature/golang/host
replace HttpFetch => /home/jimmy/.config/scale/extensions/local_testext_latest_5c7d22390f9101d459292d76c11b5e9f66c327b1766aae34b9cc75f9f40e8206_extension/golang/host
4 changes: 4 additions & 0 deletions template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ path = "lib.rs"
{{ .signature_dependency }} = { package = "{{ .signature_package }}", version = "{{ .signature_version }}", registry = "scale" }
{{ end }}
{{ range $extension := .extensions -}}
{{ $extension.Name }} = { package = "{{ $extension.Name }}", path = "{{ $extension.Path }}" }
{{end -}}
[profile.release]
opt-level = 3
lto = true
Expand Down

0 comments on commit 8c79234

Please sign in to comment.