mirror of
https://github.com/fluencelabs/asmble
synced 2025-04-24 14:22:20 +00:00
Begin work on Go examples for #14
This commit is contained in:
parent
73862e9bc9
commit
4bc12f4b94
2
.gitignore
vendored
2
.gitignore
vendored
@ -16,6 +16,8 @@
|
|||||||
/annotations/out
|
/annotations/out
|
||||||
/examples/c-simple/bin
|
/examples/c-simple/bin
|
||||||
/examples/c-simple/build
|
/examples/c-simple/build
|
||||||
|
/examples/go-simple/bin
|
||||||
|
/examples/go-simple/build
|
||||||
/examples/rust-simple/Cargo.lock
|
/examples/rust-simple/Cargo.lock
|
||||||
/examples/rust-simple/bin
|
/examples/rust-simple/bin
|
||||||
/examples/rust-simple/build
|
/examples/rust-simple/build
|
||||||
|
37
build.gradle
37
build.gradle
@ -99,6 +99,31 @@ project(':examples') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Go example helpers
|
||||||
|
|
||||||
|
task goToWasm {
|
||||||
|
doFirst {
|
||||||
|
mkdir 'build'
|
||||||
|
exec {
|
||||||
|
def goFileName = fileTree(dir: '.', includes: ['*.go']).files.iterator().next()
|
||||||
|
environment 'GOOS': 'js', 'GOARCH': 'wasm'
|
||||||
|
commandLine 'go', 'build', '-o', 'build/lib.wasm', goFileName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task compileGoWasm(type: JavaExec) {
|
||||||
|
dependsOn goToWasm
|
||||||
|
classpath configurations.compileClasspath
|
||||||
|
main = 'asmble.cli.MainKt'
|
||||||
|
doFirst {
|
||||||
|
// args 'help', 'compile'
|
||||||
|
def outFile = 'build/wasm-classes/' + wasmCompiledClassName.replace('.', '/') + '.class'
|
||||||
|
file(outFile).parentFile.mkdirs()
|
||||||
|
args 'compile', 'build/lib.wasm', wasmCompiledClassName, '-out', outFile, '-log', 'debug'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Rust example helpers
|
// Rust example helpers
|
||||||
|
|
||||||
ext.rustBuildRelease = true
|
ext.rustBuildRelease = true
|
||||||
@ -160,6 +185,18 @@ project(':examples:c-simple') {
|
|||||||
mainClassName = 'asmble.examples.csimple.Main'
|
mainClassName = 'asmble.examples.csimple.Main'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
project(':examples:go-simple') {
|
||||||
|
apply plugin: 'application'
|
||||||
|
ext.wasmCompiledClassName = 'asmble.generated.GoSimple'
|
||||||
|
dependencies {
|
||||||
|
compile files('build/wasm-classes')
|
||||||
|
}
|
||||||
|
compileJava {
|
||||||
|
dependsOn compileGoWasm
|
||||||
|
}
|
||||||
|
mainClassName = 'asmble.examples.gosimple.Main'
|
||||||
|
}
|
||||||
|
|
||||||
project(':examples:rust-regex') {
|
project(':examples:rust-regex') {
|
||||||
apply plugin: 'application'
|
apply plugin: 'application'
|
||||||
apply plugin: 'me.champeau.gradle.jmh'
|
apply plugin: 'me.champeau.gradle.jmh'
|
||||||
|
10
examples/go-simple/simple.go
Normal file
10
examples/go-simple/simple.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Printf("Args: %v", os.Args)
|
||||||
|
}
|
@ -2,6 +2,7 @@ rootProject.name = 'asmble'
|
|||||||
include 'annotations',
|
include 'annotations',
|
||||||
'compiler',
|
'compiler',
|
||||||
'examples:c-simple',
|
'examples:c-simple',
|
||||||
|
'examples:go-simple',
|
||||||
'examples:rust-regex',
|
'examples:rust-regex',
|
||||||
'examples:rust-simple',
|
'examples:rust-simple',
|
||||||
'examples:rust-string'
|
'examples:rust-string'
|
Loading…
x
Reference in New Issue
Block a user