Skip to content

Commit

Permalink
Merge pull request #73 from golemcloud/1.1_updates
Browse files Browse the repository at this point in the history
1.1 updates
  • Loading branch information
noise64 authored Dec 9, 2024
2 parents 2d81396 + 0882254 commit 7379bf6
Show file tree
Hide file tree
Showing 53 changed files with 471 additions and 672 deletions.
6 changes: 6 additions & 0 deletions examples/go/INSTRUCTIONS-app
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
See the documentation about installing tooling: https://learn.golem.cloud/docs/go-language-guide/setup

Generate wit and bindings, build and link component:
golem-cli app build

The `out/linked-components/component_name.wasm` file is ready to be uploaded to Golem Cloud!
15 changes: 0 additions & 15 deletions examples/go/go-default/Makefile

This file was deleted.

45 changes: 45 additions & 0 deletions examples/go/go-default/golem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Schema for IDEA:
# $schema: https://schema.golem.cloud/app/golem/1.1.0/golem.schema.json
# Schema for vscode-yaml
# yaml-language-server: $schema=https://schema.golem.cloud/app/golem/1.1.0/golem.schema.json

tempDir: build/golem-temp
components:
pack:name:
sourceWit: wit
generatedWit: wit-generated
componentWasm: build/adapted-components/component_name.wasm
linkedWasm: build/linked-components/component_name_linked.wasm
build:
- command: wit-bindgen tiny-go --rename-package binding --out-dir binding ./wit-generated
sources:
- wit-generated
targets:
- binding
- command: tinygo build -target=wasi -tags=purego -o build/components/component_name.wasm main.go
mkdirs:
- build/components
sources:
- component_name
- main.go
targets:
- build/components/component_name.wasm
- command: wasm-tools component embed wit-generated build/components/component_name.wasm --output build/embedded-components/component_name.wasm
mkdirs:
- build/embedded-components
sources:
- wit-generated
- build/components/component_name.wasm
targets:
- build/embedded-components/component_name.wasm
- command: wasm-tools component new build/embedded-components/component_name.wasm -o build/adapted-components/component_name.wasm --adapt adapters/tier1/wasi_snapshot_preview1.wasm
mkdirs:
- build/adapted-components
sources:
- adapters/tier1/wasi_snapshot_preview1.wasm
- build/embedded-components/component_name.wasm
targets:
- build/adapted-components/component_name.wasm
clean:
- build
- binding
4 changes: 2 additions & 2 deletions examples/go/go-default/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"github.com/golemcloud/golem-go/std"

"pack/name/component_name"
"pack/name/binding"
)

type RequestBody struct {
Expand All @@ -15,7 +15,7 @@ type ResponseBody struct {
}

func init() {
component_name.SetExportsPackNameApi(&ComponentNameImpl{})
binding.SetExportsPackNameInterfaceApi(&ComponentNameImpl{})
}

// total State can be stored in global variables
Expand Down
4 changes: 3 additions & 1 deletion examples/go/go-default/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"requiresAdapter": true,
"requiresGolemHostWIT": true,
"requiresWASI": true,
"instructions": "INSTRUCTIONS-app",
"exclude": [
"component_name",
"wit-generated",
"build",
"main.wasm"
]
}
9 changes: 9 additions & 0 deletions examples/js/INSTRUCTIONS-app
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
See the documentation about installing tooling: https://learn.golem.cloud/docs/experimental-languages/js-language-guide/setup

First time node package install:
golem-cli app install

Generate wit and bindings, build and link component:
golem-cli app build

The `out/linked-components/component_name.wasm` file is ready to be uploaded to Golem Cloud!
1 change: 1 addition & 0 deletions examples/js/js-default/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
out/
wit-generated/
31 changes: 31 additions & 0 deletions examples/js/js-default/golem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Schema for IDEA:
# $schema: https://schema.golem.cloud/app/golem/1.1.0/golem.schema.json
# Schema for vscode-yaml
# yaml-language-server: $schema=https://schema.golem.cloud/app/golem/1.1.0/golem.schema.json

tempDir: out/golem-temp
components:
pack:name:
sourceWit: wit
generatedWit: wit-generated
componentWasm: out/components/component_name.wasm
linkedWasm: out/linked-components/component_name_linked.wasm
build:
- command: npx rollup --config
sources:
- src
- wit-generated
targets:
- out/main.js
- command: npx jco componentize -w wit-generated -o out/components/component_name.wasm out/main.js
mkdirs:
- out/components
sources:
- out/main.js
targets:
- out/components/component_name.wasm
clean:
- src/generated
customCommands:
install:
- command: npm install
4 changes: 3 additions & 1 deletion examples/js/js-default/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"requiresAdapter": false,
"requiresGolemHostWIT": true,
"requiresWASI": true,
"instructions": "INSTRUCTIONS-app",
"exclude": [
"node_modules",
"out"
"out",
"wit-generated"
]
}
5 changes: 0 additions & 5 deletions examples/js/js-default/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"scripts": {
"build": "rollup --config",
"componentize": "npm run build && jco componentize -w wit -o out/component_name.wasm out/main.js",
"clean": "rm -rf out src/generated"
},
"devDependencies": {
"@golemcloud/componentize-js": "0.10.5-golem.3",
"@golemcloud/golem-ts": "1.1.0",
Expand Down
1 change: 1 addition & 0 deletions examples/python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bindings
component_name.wasm
wit-generated
__pycache__
6 changes: 6 additions & 0 deletions examples/python/INSTRUCTIONS-app
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
See the documentation about installing tooling: https://learn.golem.cloud/docs/python-language-guide/setup

Generate wit and bindings, build and link component:
golem-cli app build

The `build/linked-components/component_name_linked.wasm` file is ready to be uploaded to Golem Cloud!
4 changes: 4 additions & 0 deletions examples/python/python-default/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bindings
component_name.wasm
wit-generated
__pycache__
26 changes: 26 additions & 0 deletions examples/python/python-default/golem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Schema for IDEA:
# $schema: https://schema.golem.cloud/app/golem/1.1.0/golem.schema.json
# Schema for vscode-yaml
# yaml-language-server: $schema=https://schema.golem.cloud/app/golem/1.1.0/golem.schema.json

tempDir: build/golem-temp
components:
pack:name:
sourceWit: wit
generatedWit: wit-generated
componentWasm: build/components/component_name.wasm
linkedWasm: build/linked-components/component_name_linked.wasm
build:
- command: componentize-py bindings bindings
sources:
- wit-generated
targets:
- bindings
- command: componentize-py componentize main -o build/components/component_name.wasm
mkdirs:
- build/components
sources:
- bindings
- main.py
targets:
- build/components/component_name.wasm
2 changes: 2 additions & 0 deletions examples/python/python-default/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"requiresAdapter": false,
"requiresGolemHostWIT": true,
"requiresWASI": true,
"instructions": "INSTRUCTIONS-app",
"exclude": [
"component_name.wasm",
"bindings",
"wit-generated ",
"__pycache__"
]
}
11 changes: 11 additions & 0 deletions examples/rust/INSTRUCTIONS-app
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
See the documentation about installing common tooling: https://learn.golem.cloud/docs/rust-language-guide/setup

Compile the Rust component with golem-cli:
golem-cli app build

The result component in target/golem-components/debug/component_name.wasm is ready to be used with Golem!

For compiling with the release build profile, use:
golem-cli app -b release build

The result release component in target/golem-components/debug/component_name.wasm is ready to be used with Golem!
38 changes: 38 additions & 0 deletions examples/rust/rust-default/golem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Schema for IDEA:
# $schema: https://schema.golem.cloud/app/golem/1.1.0/golem.schema.json
# Schema for vscode-yaml
# yaml-language-server: $schema=https://schema.golem.cloud/app/golem/1.1.0/golem.schema.json

tempDir: target/golem-temp
components:
pack:name:
profiles:
debug:
build:
- command: cargo component build
sources:
- src
- wit
targets:
- target/wasm32-wasi/debug/component_name.wasm
sourceWit: wit
generatedWit: wit-generated
componentWasm: target/wasm32-wasi/debug/component_name.wasm
linkedWasm: target/golem-components/debug/component_name.wasm
clean:
- src/bindings.rs
release:
build:
- command: cargo component build --release
sources:
- src
- wit
targets:
- target/wasm32-wasi/release/component_name.wasm
sourceWit: wit
generatedWit: wit-generated
componentWasm: target/wasm32-wasi/release/component_name.wasm
linkedWasm: target/golem-components/release/component_name.wasm
clean:
- src/bindings.rs
defaultProfile: debug
3 changes: 2 additions & 1 deletion examples/rust/rust-default/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"requiresAdapter": false,
"requiresGolemHostWIT": false,
"requiresWASI": false,
"exclude": ["target"]
"instructions": "INSTRUCTIONS-app",
"exclude": ["target", "src/binding"]
}
2 changes: 1 addition & 1 deletion examples/rust/rust-default/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod bindings;

use crate::bindings::exports::pack::name::api::*;
use crate::bindings::exports::golemx::componentx_interface::api::*;
use std::cell::RefCell;

/// This is one of any number of data types that our application
Expand Down
9 changes: 9 additions & 0 deletions examples/ts/INSTRUCTIONS-app
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
See the documentation about installing tooling: https://learn.golem.cloud/docs/experimental-languages/ts-language-guide/setup

First time node package install:
golem-cli app install

Generate wit and bindings, build and link component:
golem-cli app build

The `out/linked-components/component_name.wasm` file is ready to be uploaded to Golem Cloud!
7 changes: 3 additions & 4 deletions examples/ts/INSTRUCTIONS-buildts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
See the documentation about installing tooling: https://learn.golem.cloud/docs/go-language-guide/setup
See the documentation about installing tooling: https://learn.golem.cloud/docs/experimental-languages/ts-language-guide/setup
and see more details in the README.md file about other commands.

Before first time build, install dependencies and generate RPC stubs:
Before first time build, install dependencies:
npm install
npm run updateRpcStubs

Generate bindings, compile and compose components:
npm run build
golem-cli app build

Deploy components to default profile:
npm run deploy
Expand Down
1 change: 1 addition & 0 deletions examples/ts/ts-default/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
out/
src/generated/
wit-generated/
37 changes: 37 additions & 0 deletions examples/ts/ts-default/golem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Schema for IDEA:
# $schema: https://schema.golem.cloud/app/golem/1.1.0/golem.schema.json
# Schema for vscode-yaml
# yaml-language-server: $schema=https://schema.golem.cloud/app/golem/1.1.0/golem.schema.json

tempDir: out/golem-temp
components:
pack:name:
sourceWit: wit
generatedWit: wit-generated
componentWasm: out/components/component_name.wasm
linkedWasm: out/linked-components/component_name_linked.wasm
build:
- command: npx jco stubgen wit-generated -o src/binding
sources:
- wit-generated
targets:
- src/binding
- command: npx rollup --config
sources:
- src
- wit-generated
targets:
- out/main.js
- command: npx jco componentize -w wit-generated -o out/components/component_name.wasm out/main.js
mkdirs:
- out/components
sources:
- out/main.js
targets:
- out/components/component_name.wasm
clean:
- src/binding
- wit-generated
customCommands:
install:
- command: npm install
3 changes: 2 additions & 1 deletion examples/ts/ts-default/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"requiresAdapter": false,
"requiresGolemHostWIT": true,
"requiresWASI": true,
"instructions": "INSTRUCTIONS-app",
"exclude": [
"node_modules",
"out",
"src/generated"
"src/binding"
]
}
6 changes: 0 additions & 6 deletions examples/ts/ts-default/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
"scripts": {
"stub": "jco stubgen wit -o src/generated",
"build": "rollup --config",
"componentize": "npm run stub && npm run build && jco componentize -w wit -o out/component_name.wasm out/main.js",
"clean": "rm -rf out src/generated"
},
"devDependencies": {
"@golemcloud/componentize-js": "0.10.5-golem.3",
"@golemcloud/golem-ts": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/ts/ts-default/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Api } from './generated/component-name.js';
import { Api } from './binding/component-name.js';

let state = BigInt(0);

Expand Down
Loading

0 comments on commit 7379bf6

Please sign in to comment.