2017-03-02 16:23:08 -06:00
|
|
|
group 'asmble'
|
2018-03-02 17:58:40 -06:00
|
|
|
version '0.2.0'
|
2017-03-02 16:23:08 -06:00
|
|
|
|
|
|
|
buildscript {
|
2018-07-20 09:23:27 -05:00
|
|
|
ext.kotlin_version = '1.2.51'
|
2017-03-21 17:53:32 -05:00
|
|
|
ext.asm_version = '5.2'
|
2017-03-02 16:23:08 -06:00
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
2017-11-28 17:00:38 -06:00
|
|
|
maven {
|
|
|
|
url "https://plugins.gradle.org/m2/"
|
|
|
|
}
|
2017-03-02 16:23:08 -06:00
|
|
|
}
|
|
|
|
dependencies {
|
|
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
2017-12-06 03:13:52 -06:00
|
|
|
classpath 'me.champeau.gradle:jmh-gradle-plugin:0.4.5'
|
2017-03-02 16:23:08 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-24 18:49:54 -05:00
|
|
|
allprojects {
|
|
|
|
apply plugin: 'java'
|
2018-07-20 15:59:03 -05:00
|
|
|
group 'com.github.cretz.asmble'
|
2018-08-14 12:11:48 +04:00
|
|
|
version '0.4.0-fl'
|
2017-03-26 16:40:30 -05:00
|
|
|
|
2017-04-24 18:49:54 -05:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
}
|
2017-03-02 16:23:08 -06:00
|
|
|
}
|
|
|
|
|
2018-07-20 15:59:03 -05:00
|
|
|
project(':annotations') {
|
|
|
|
javadoc {
|
|
|
|
options.links 'https://docs.oracle.com/javase/8/docs/api/'
|
|
|
|
// TODO: change when https://github.com/gradle/gradle/issues/2354 is fixed
|
|
|
|
options.addStringOption 'Xdoclint:all', '-Xdoclint:-missing'
|
|
|
|
}
|
|
|
|
|
|
|
|
publishSettings(project, 'asmble-annotations', 'Asmble WASM Annotations', true)
|
|
|
|
}
|
|
|
|
|
2017-04-24 18:49:54 -05:00
|
|
|
project(':compiler') {
|
|
|
|
apply plugin: 'kotlin'
|
|
|
|
apply plugin: 'application'
|
|
|
|
|
|
|
|
applicationName = "asmble"
|
|
|
|
mainClassName = "asmble.cli.MainKt"
|
|
|
|
|
|
|
|
distTar.archiveName = 'asmble.tar'
|
|
|
|
distZip.archiveName = 'asmble.zip'
|
|
|
|
|
|
|
|
dependencies {
|
2018-03-02 13:55:17 -06:00
|
|
|
compile project(':annotations')
|
2017-04-24 18:49:54 -05:00
|
|
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
|
|
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
|
|
|
compile "org.ow2.asm:asm-tree:$asm_version"
|
|
|
|
compile "org.ow2.asm:asm-util:$asm_version"
|
|
|
|
testCompile 'junit:junit:4.12'
|
|
|
|
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
|
|
|
testCompile "org.ow2.asm:asm-debug-all:$asm_version"
|
|
|
|
}
|
2018-07-20 15:59:03 -05:00
|
|
|
|
|
|
|
publishSettings(project, 'asmble-compiler', 'Asmble WASM Compiler', false)
|
2017-03-02 16:23:08 -06:00
|
|
|
}
|
2017-11-28 17:00:38 -06:00
|
|
|
|
|
|
|
project(':examples') {
|
|
|
|
subprojects {
|
|
|
|
dependencies {
|
|
|
|
compileOnly project(':compiler')
|
|
|
|
}
|
|
|
|
|
2018-07-26 17:16:11 -05:00
|
|
|
// 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'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-15 14:43:21 -06:00
|
|
|
// Rust example helpers
|
|
|
|
|
2017-11-29 13:03:36 -06:00
|
|
|
ext.rustBuildRelease = true
|
|
|
|
|
2017-11-28 17:00:38 -06:00
|
|
|
task rustToWasm(type: Exec) {
|
2017-11-29 13:03:36 -06:00
|
|
|
if (rustBuildRelease) {
|
|
|
|
commandLine 'cargo', 'build', '--release'
|
|
|
|
} else {
|
|
|
|
commandLine 'cargo', 'build'
|
|
|
|
}
|
2017-11-28 17:00:38 -06:00
|
|
|
}
|
|
|
|
|
2017-11-29 16:42:12 -06:00
|
|
|
ext.rustWasmFileName = { ->
|
2017-11-29 13:03:36 -06:00
|
|
|
def buildType = rustBuildRelease ? 'release' : 'debug'
|
|
|
|
def wasmFiles = fileTree(dir: "target/wasm32-unknown-unknown/$buildType", includes: ['*.wasm']).files
|
2017-11-28 17:00:38 -06:00
|
|
|
if (wasmFiles.size() != 1) throw new GradleException('Expected single WASM file, got ' + wasmFiles.size())
|
|
|
|
return wasmFiles.iterator().next()
|
|
|
|
}
|
|
|
|
|
2017-11-29 16:42:12 -06:00
|
|
|
task rustWasmFile() {
|
2017-11-28 17:00:38 -06:00
|
|
|
dependsOn rustToWasm
|
|
|
|
doFirst {
|
2017-11-29 16:42:12 -06:00
|
|
|
println 'File: ' + rustWasmFileName()
|
2017-11-28 17:00:38 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 16:42:12 -06:00
|
|
|
task showRustWast(type: JavaExec) {
|
2017-11-28 17:00:38 -06:00
|
|
|
dependsOn rustToWasm
|
|
|
|
classpath configurations.compileClasspath
|
|
|
|
main = 'asmble.cli.MainKt'
|
|
|
|
doFirst {
|
2017-11-29 16:42:12 -06:00
|
|
|
args 'translate', rustWasmFileName()
|
2017-11-28 17:00:38 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 16:42:12 -06:00
|
|
|
task compileRustWasm(type: JavaExec) {
|
2017-11-28 17:00:38 -06:00
|
|
|
dependsOn rustToWasm
|
|
|
|
classpath configurations.compileClasspath
|
|
|
|
main = 'asmble.cli.MainKt'
|
|
|
|
doFirst {
|
|
|
|
// args 'help', 'compile'
|
|
|
|
def outFile = 'build/wasm-classes/' + wasmCompiledClassName.replace('.', '/') + '.class'
|
|
|
|
file(outFile).parentFile.mkdirs()
|
2017-11-29 16:42:12 -06:00
|
|
|
args 'compile', rustWasmFileName(), wasmCompiledClassName, '-out', outFile
|
2017-11-28 17:00:38 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-15 14:43:21 -06:00
|
|
|
|
2018-07-26 17:16:11 -05:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
|
2018-07-25 10:35:37 +04:00
|
|
|
// todo temporary disable Rust regex, because some strings in wasm code exceed the size in 65353 bytes.
|
|
|
|
|
2018-08-10 13:10:28 +04:00
|
|
|
// project(':examples:rust-regex') {
|
|
|
|
// apply plugin: 'application'
|
|
|
|
// apply plugin: 'me.champeau.gradle.jmh'
|
|
|
|
// ext.wasmCompiledClassName = 'asmble.generated.RustRegex'
|
|
|
|
// dependencies {
|
|
|
|
// compile files('build/wasm-classes')
|
|
|
|
// testCompile 'junit:junit:4.12'
|
|
|
|
// }
|
|
|
|
// compileJava {
|
|
|
|
// dependsOn compileRustWasm
|
|
|
|
// }
|
|
|
|
// mainClassName = 'asmble.examples.rustregex.Main'
|
|
|
|
// test {
|
|
|
|
// testLogging.showStandardStreams = true
|
|
|
|
// testLogging.events 'PASSED', 'SKIPPED'
|
|
|
|
// }
|
|
|
|
// jmh {
|
|
|
|
// iterations = 5
|
|
|
|
// warmupIterations = 5
|
|
|
|
// fork = 3
|
|
|
|
// }
|
|
|
|
// }
|
2017-11-29 16:42:12 -06:00
|
|
|
|
2017-11-28 17:00:38 -06:00
|
|
|
project(':examples:rust-simple') {
|
|
|
|
apply plugin: 'application'
|
|
|
|
ext.wasmCompiledClassName = 'asmble.generated.RustSimple'
|
|
|
|
dependencies {
|
|
|
|
compile files('build/wasm-classes')
|
|
|
|
}
|
|
|
|
compileJava {
|
2017-11-29 16:42:12 -06:00
|
|
|
dependsOn compileRustWasm
|
2017-11-28 17:00:38 -06:00
|
|
|
}
|
|
|
|
mainClassName = 'asmble.examples.rustsimple.Main'
|
2017-11-29 13:03:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
project(':examples:rust-string') {
|
|
|
|
apply plugin: 'application'
|
|
|
|
ext.wasmCompiledClassName = 'asmble.generated.RustString'
|
|
|
|
dependencies {
|
|
|
|
compile files('build/wasm-classes')
|
|
|
|
}
|
|
|
|
compileJava {
|
2017-11-29 16:42:12 -06:00
|
|
|
dependsOn compileRustWasm
|
2017-11-29 13:03:36 -06:00
|
|
|
}
|
|
|
|
mainClassName = 'asmble.examples.ruststring.Main'
|
2018-07-20 15:59:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
def publishSettings(project, projectName, projectDescription, includeJavadoc) {
|
|
|
|
project.with {
|
2018-08-14 12:11:48 +04:00
|
|
|
if (!bintrayUser || !bintrayKey) return
|
2018-07-20 15:59:03 -05:00
|
|
|
apply plugin: 'maven'
|
|
|
|
apply plugin: 'signing'
|
|
|
|
|
|
|
|
archivesBaseName = projectName
|
|
|
|
|
|
|
|
task packageSources(type: Jar) {
|
|
|
|
classifier = 'sources'
|
|
|
|
from sourceSets.main.allSource
|
|
|
|
}
|
|
|
|
|
|
|
|
if (includeJavadoc) {
|
|
|
|
task packageJavadoc(type: Jar, dependsOn: 'javadoc') {
|
|
|
|
from javadoc.destinationDir
|
|
|
|
classifier = 'javadoc'
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
task packageJavadoc(type: Jar) {
|
|
|
|
// Empty to satisfy Sonatype's javadoc.jar requirement
|
|
|
|
classifier 'javadoc'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
archives packageSources, packageJavadoc
|
|
|
|
}
|
|
|
|
|
|
|
|
uploadArchives {
|
|
|
|
repositories {
|
|
|
|
mavenDeployer {
|
2018-08-14 12:11:48 +04:00
|
|
|
|
|
|
|
println(bintrayKey)
|
|
|
|
repository(url: 'https://dl.bintray.com/fluencelabs/releases/') {
|
|
|
|
authentication(userName: bintrayUser, password: bintrayKey)
|
2018-07-20 15:59:03 -05:00
|
|
|
}
|
2018-08-14 12:11:48 +04:00
|
|
|
// snapshotRepository(url: 'https://dl.bintray.com/fluencelabs/snapshots/') {
|
|
|
|
// authentication(userName: bintrayUser, password: bintrayKey)
|
|
|
|
// }
|
2018-07-20 15:59:03 -05:00
|
|
|
pom.project {
|
|
|
|
name projectName
|
|
|
|
packaging 'jar'
|
|
|
|
description projectDescription
|
2018-08-14 12:11:48 +04:00
|
|
|
url 'https://github.com/fluencelabs/asmble'
|
2018-07-20 15:59:03 -05:00
|
|
|
scm {
|
2018-08-14 12:11:48 +04:00
|
|
|
connection 'scm:git:git@github.com:fluencelabs/asmble.git'
|
|
|
|
developerConnection 'scm:git:git@github.com:fluencelabs/asmble.git'
|
|
|
|
url 'git@github.com:fluencelabs/asmble.git'
|
2018-07-20 15:59:03 -05:00
|
|
|
}
|
|
|
|
licenses {
|
|
|
|
license {
|
|
|
|
name 'MIT License'
|
|
|
|
url 'https://opensource.org/licenses/MIT'
|
|
|
|
}
|
|
|
|
}
|
2018-08-14 12:11:48 +04:00
|
|
|
developers {
|
2018-07-20 15:59:03 -05:00
|
|
|
developer {
|
2018-08-14 12:11:48 +04:00
|
|
|
id 'fluencelabs'
|
|
|
|
name 'Fluencelabs'
|
|
|
|
url 'https://github.com/fluencelabs'
|
2018-07-20 15:59:03 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-11-28 17:00:38 -06:00
|
|
|
}
|