Begin work on Go examples for #14

This commit is contained in:
Chad Retz 2018-07-26 17:16:11 -05:00
parent 73862e9bc9
commit 4bc12f4b94
4 changed files with 50 additions and 0 deletions

2
.gitignore vendored
View File

@ -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

View File

@ -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'

View File

@ -0,0 +1,10 @@
package main
import (
"fmt"
"os"
)
func main() {
fmt.Printf("Args: %v", os.Args)
}

View File

@ -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'