diff --git a/experiments/Interop/.idea/gradle.xml b/experiments/Interop/.idea/gradle.xml new file mode 100644 index 00000000000..712ec676d10 --- /dev/null +++ b/experiments/Interop/.idea/gradle.xml @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/experiments/Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml b/experiments/Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml new file mode 100644 index 00000000000..0eb057374b0 --- /dev/null +++ b/experiments/Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/experiments/Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml b/experiments/Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml new file mode 100644 index 00000000000..ae3ca477567 --- /dev/null +++ b/experiments/Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/experiments/Interop/.idea/libraries/KotlinJavaRuntime.xml b/experiments/Interop/.idea/libraries/KotlinJavaRuntime.xml deleted file mode 100644 index c630c0b8796..00000000000 --- a/experiments/Interop/.idea/libraries/KotlinJavaRuntime.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/experiments/Interop/.idea/libraries/com_google_protobuf_protobuf_java_2_6_1.xml b/experiments/Interop/.idea/libraries/com_google_protobuf_protobuf_java_2_6_1.xml deleted file mode 100644 index aee547201d3..00000000000 --- a/experiments/Interop/.idea/libraries/com_google_protobuf_protobuf_java_2_6_1.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/experiments/Interop/.idea/modules.xml b/experiments/Interop/.idea/modules.xml index 4fdba8b4f25..9013d797b60 100644 --- a/experiments/Interop/.idea/modules.xml +++ b/experiments/Interop/.idea/modules.xml @@ -2,11 +2,9 @@ - - - - - + + + \ No newline at end of file diff --git a/experiments/Interop/.idea/modules/Indexer/Indexer.iml b/experiments/Interop/.idea/modules/Indexer/Indexer.iml new file mode 100644 index 00000000000..556176b4b39 --- /dev/null +++ b/experiments/Interop/.idea/modules/Indexer/Indexer.iml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/experiments/Interop/.idea/modules/Runtime/Runtime.iml b/experiments/Interop/.idea/modules/Runtime/Runtime.iml new file mode 100644 index 00000000000..91162e21499 --- /dev/null +++ b/experiments/Interop/.idea/modules/Runtime/Runtime.iml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/experiments/Interop/.idea/modules/StubGenerator/StubGenerator.iml b/experiments/Interop/.idea/modules/StubGenerator/StubGenerator.iml new file mode 100644 index 00000000000..79b649856d6 --- /dev/null +++ b/experiments/Interop/.idea/modules/StubGenerator/StubGenerator.iml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/experiments/Interop/.idea/runConfigurations/Example.xml b/experiments/Interop/.idea/runConfigurations/Example.xml deleted file mode 100644 index c961bf6e578..00000000000 --- a/experiments/Interop/.idea/runConfigurations/Example.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - \ No newline at end of file diff --git a/experiments/Interop/.idea/runConfigurations/Gen_stubs_for_indexer.xml b/experiments/Interop/.idea/runConfigurations/Gen_stubs_for_indexer.xml deleted file mode 100644 index af5b7ffc830..00000000000 --- a/experiments/Interop/.idea/runConfigurations/Gen_stubs_for_indexer.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/experiments/Interop/.idea/runConfigurations/StubGenerator.xml b/experiments/Interop/.idea/runConfigurations/StubGenerator.xml deleted file mode 100644 index c17cafb364d..00000000000 --- a/experiments/Interop/.idea/runConfigurations/StubGenerator.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/experiments/Interop/Example/Example.iml b/experiments/Interop/Example/Example.iml deleted file mode 100644 index 768a1f84fcb..00000000000 --- a/experiments/Interop/Example/Example.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/experiments/Interop/Indexer/Indexer.iml b/experiments/Interop/Indexer/Indexer.iml deleted file mode 100644 index 768a1f84fcb..00000000000 --- a/experiments/Interop/Indexer/Indexer.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/experiments/Interop/Indexer/build.gradle b/experiments/Interop/Indexer/build.gradle new file mode 100644 index 00000000000..da04a20e512 --- /dev/null +++ b/experiments/Interop/Indexer/build.gradle @@ -0,0 +1,45 @@ +buildscript { + ext.kotlin_version = '1.0.3' + + repositories { + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: 'kotlin' + +/* +apply plugin: 'c' + +model { + components { + callback(NativeLibrarySpec) { + binaries.all { + cCompiler.args "-I/System/Library/Frameworks/JavaVM.framework/Headers" + } + } + } + +} +*/ + +sourceSets { + main { + kotlin { + srcDirs 'prebuilt/nativeInteropStubs' + } + } +} + +repositories { + mavenCentral() +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + compile project(':Interop:Runtime') +} diff --git a/experiments/Interop/Indexer/native-src/build-callback.sh b/experiments/Interop/Indexer/native-src/build-callback.sh deleted file mode 100755 index 8b8241f8af8..00000000000 --- a/experiments/Interop/Indexer/native-src/build-callback.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -clang -shared -o../nativelib/libcallback.dylib callback.c -I /System/Library/Frameworks/JavaVM.framework/Headers -pthread - diff --git a/experiments/Interop/Indexer/src/clang/Clang.kt b/experiments/Interop/Indexer/prebuilt/nativeInteropStubs/clang/Clang.kt similarity index 100% rename from experiments/Interop/Indexer/src/clang/Clang.kt rename to experiments/Interop/Indexer/prebuilt/nativeInteropStubs/clang/Clang.kt diff --git a/experiments/Interop/Indexer/prebuilt/nativelibs/build-callback.sh b/experiments/Interop/Indexer/prebuilt/nativelibs/build-callback.sh new file mode 100755 index 00000000000..000ec98b72e --- /dev/null +++ b/experiments/Interop/Indexer/prebuilt/nativelibs/build-callback.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +clang -shared -olibcallback.dylib src/callback/c/callback.c -I /System/Library/Frameworks/JavaVM.framework/Headers -pthread + diff --git a/experiments/Interop/Indexer/nativelib/libcallback.dylib b/experiments/Interop/Indexer/prebuilt/nativelibs/libcallback.dylib similarity index 100% rename from experiments/Interop/Indexer/nativelib/libcallback.dylib rename to experiments/Interop/Indexer/prebuilt/nativelibs/libcallback.dylib diff --git a/experiments/Interop/Indexer/nativelib/libclangbridge.dylib b/experiments/Interop/Indexer/prebuilt/nativelibs/libclangbridge.dylib similarity index 100% rename from experiments/Interop/Indexer/nativelib/libclangbridge.dylib rename to experiments/Interop/Indexer/prebuilt/nativelibs/libclangbridge.dylib diff --git a/experiments/Interop/Indexer/native-src/callback.c b/experiments/Interop/Indexer/src/callback/c/callback.c similarity index 100% rename from experiments/Interop/Indexer/native-src/callback.c rename to experiments/Interop/Indexer/src/callback/c/callback.c diff --git a/experiments/Interop/Indexer/src/clang/Clang.def b/experiments/Interop/Indexer/src/main/kotlin/clang/Clang.def similarity index 100% rename from experiments/Interop/Indexer/src/clang/Clang.def rename to experiments/Interop/Indexer/src/main/kotlin/clang/Clang.def diff --git a/experiments/Interop/Indexer/src/org/jetbrains/kotlin/native/interop/indexer/Callbacks.kt b/experiments/Interop/Indexer/src/main/kotlin/org/jetbrains/kotlin/native/interop/indexer/Callbacks.kt similarity index 100% rename from experiments/Interop/Indexer/src/org/jetbrains/kotlin/native/interop/indexer/Callbacks.kt rename to experiments/Interop/Indexer/src/main/kotlin/org/jetbrains/kotlin/native/interop/indexer/Callbacks.kt diff --git a/experiments/Interop/Indexer/src/org/jetbrains/kotlin/native/interop/indexer/Indexer.kt b/experiments/Interop/Indexer/src/main/kotlin/org/jetbrains/kotlin/native/interop/indexer/Indexer.kt similarity index 100% rename from experiments/Interop/Indexer/src/org/jetbrains/kotlin/native/interop/indexer/Indexer.kt rename to experiments/Interop/Indexer/src/main/kotlin/org/jetbrains/kotlin/native/interop/indexer/Indexer.kt diff --git a/experiments/Interop/Indexer/src/org/jetbrains/kotlin/native/interop/indexer/NativeIndex.kt b/experiments/Interop/Indexer/src/main/kotlin/org/jetbrains/kotlin/native/interop/indexer/NativeIndex.kt similarity index 100% rename from experiments/Interop/Indexer/src/org/jetbrains/kotlin/native/interop/indexer/NativeIndex.kt rename to experiments/Interop/Indexer/src/main/kotlin/org/jetbrains/kotlin/native/interop/indexer/NativeIndex.kt diff --git a/experiments/Interop/Interop.iml b/experiments/Interop/Interop.iml deleted file mode 100644 index 245d3429faa..00000000000 --- a/experiments/Interop/Interop.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/experiments/Interop/README.md b/experiments/Interop/README.md index 716e919e8c5..3195edd2363 100644 --- a/experiments/Interop/README.md +++ b/experiments/Interop/README.md @@ -2,5 +2,12 @@ ## Usage -Open `Interop` project in IDEA. Run `StubGenerator` configuration to process all `.def` files in `Example` module. -Then run `Example` configuration to run the example. +Create a Gradle subproject somewhere under `../`, using `../InteropExample` as a template. + +To generate the interop stubs and libraries you can run the following command from `../`: + + ./gradlew InteropExample:build + +To run the example (if 'application' plugin is enabled): + + ./gradlew InteropExample:run diff --git a/experiments/Interop/Runtime/Runtime.iml b/experiments/Interop/Runtime/Runtime.iml deleted file mode 100644 index 245d3429faa..00000000000 --- a/experiments/Interop/Runtime/Runtime.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/experiments/Interop/Runtime/build.gradle b/experiments/Interop/Runtime/build.gradle new file mode 100644 index 00000000000..e32dec48ca8 --- /dev/null +++ b/experiments/Interop/Runtime/build.gradle @@ -0,0 +1,21 @@ +buildscript { + ext.kotlin_version = '1.0.3' + + repositories { + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: 'kotlin' + +repositories { + mavenCentral() +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" +} diff --git a/experiments/Interop/Runtime/src/kotlin_native/interop/Bridge.kt b/experiments/Interop/Runtime/src/main/kotlin/kotlin_native/interop/Bridge.kt similarity index 100% rename from experiments/Interop/Runtime/src/kotlin_native/interop/Bridge.kt rename to experiments/Interop/Runtime/src/main/kotlin/kotlin_native/interop/Bridge.kt diff --git a/experiments/Interop/Runtime/src/kotlin_native/interop/Types.kt b/experiments/Interop/Runtime/src/main/kotlin/kotlin_native/interop/Types.kt similarity index 100% rename from experiments/Interop/Runtime/src/kotlin_native/interop/Types.kt rename to experiments/Interop/Runtime/src/main/kotlin/kotlin_native/interop/Types.kt diff --git a/experiments/Interop/Runtime/src/kotlin_native/interop/Utils.kt b/experiments/Interop/Runtime/src/main/kotlin/kotlin_native/interop/Utils.kt similarity index 100% rename from experiments/Interop/Runtime/src/kotlin_native/interop/Utils.kt rename to experiments/Interop/Runtime/src/main/kotlin/kotlin_native/interop/Utils.kt diff --git a/experiments/Interop/StubGenerator/StubGenerator.iml b/experiments/Interop/StubGenerator/StubGenerator.iml deleted file mode 100644 index 1c5e543e4d0..00000000000 --- a/experiments/Interop/StubGenerator/StubGenerator.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/experiments/Interop/StubGenerator/build.gradle b/experiments/Interop/StubGenerator/build.gradle new file mode 100644 index 00000000000..a1cd2c0abdf --- /dev/null +++ b/experiments/Interop/StubGenerator/build.gradle @@ -0,0 +1,25 @@ +buildscript { + ext.kotlin_version = '1.0.3' + + repositories { + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: 'kotlin' +apply plugin: 'application' + +mainClassName = "org.jetbrains.kotlin.native.interop.gen.jvm.MainKt" + +repositories { + mavenCentral() +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + compile project(':Interop:Indexer') +} diff --git a/experiments/Interop/StubGenerator/src/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt b/experiments/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt similarity index 100% rename from experiments/Interop/StubGenerator/src/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt rename to experiments/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt diff --git a/experiments/Interop/StubGenerator/src/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt b/experiments/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt similarity index 88% rename from experiments/Interop/StubGenerator/src/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt rename to experiments/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt index 4f7ed8bc851..8fc2ab96f01 100644 --- a/experiments/Interop/StubGenerator/src/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt +++ b/experiments/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt @@ -8,7 +8,8 @@ import kotlin.system.exitProcess fun main(args: Array) { val ktSrcRoot = args[0] - val nativeLibsDir = args[1] + val ktGenRoot = args[1] + val nativeLibsDir = args[2] val defFiles = File(ktSrcRoot).walk().filter { it.name.endsWith(".def") } @@ -27,8 +28,9 @@ fun main(args: Array) { val excludedFunctions = config.getProperty("excludedFunctions")?.split(' ')?.toSet() ?: emptySet() - val outKtFile = defFile.absolutePath.substringBeforeLast(".def") + ".kt" - val outKtPkg = defFile.parentFile.relativeTo(File(ktSrcRoot)).path.replace(File.separatorChar, '.') + val defFileRelative = defFile.relativeTo(File(ktSrcRoot)) + val outKtFile = File(ktGenRoot, defFileRelative.toString().substringBeforeLast(".def") + ".kt") + val outKtPkg = defFileRelative.parentFile.path.replace(File.separatorChar, '.') @@ -36,7 +38,8 @@ fun main(args: Array) { val gen = StubGenerator(nativeIndex, outKtPkg, libName, excludedFunctions) - File(outKtFile).bufferedWriter().use { out -> + outKtFile.parentFile.mkdirs() + outKtFile.bufferedWriter().use { out -> gen.withOutput({ out.appendln(it) }) { gen.generateKotlinFile() } diff --git a/experiments/InteropExample/build.gradle b/experiments/InteropExample/build.gradle new file mode 100644 index 00000000000..bc10e15d947 --- /dev/null +++ b/experiments/InteropExample/build.gradle @@ -0,0 +1,25 @@ +buildscript { + ext.kotlin_version = '1.0.3' + + repositories { + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: 'kotlin' +apply plugin: org.jetbrains.kotlin.NativeInteropPlugin +apply plugin: 'application' + +repositories { + mavenCentral() +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" +} + +mainClassName = 'MainKt' diff --git a/experiments/Interop/Example/src/llvm/LLVM.def b/experiments/InteropExample/src/main/kotlin/llvm/LLVM.def similarity index 98% rename from experiments/Interop/Example/src/llvm/LLVM.def rename to experiments/InteropExample/src/main/kotlin/llvm/LLVM.def index 372e7cce590..6b38a4e8596 100644 --- a/experiments/Interop/Example/src/llvm/LLVM.def +++ b/experiments/InteropExample/src/main/kotlin/llvm/LLVM.def @@ -26,4 +26,4 @@ linkerOpts = -stdlib=libc++ -fPIC -fvisibility-inlines-hidden \ -lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lcurses -lpthread -lz -lm \ -L/opt/local/lib -lffi -excludedFunctions = \ No newline at end of file +excludedFunctions = diff --git a/experiments/Interop/Example/src/main.kt b/experiments/InteropExample/src/main/kotlin/main.kt similarity index 100% rename from experiments/Interop/Example/src/main.kt rename to experiments/InteropExample/src/main/kotlin/main.kt diff --git a/experiments/buildSrc/build.gradle b/experiments/buildSrc/build.gradle new file mode 100644 index 00000000000..1ee376647bb --- /dev/null +++ b/experiments/buildSrc/build.gradle @@ -0,0 +1,5 @@ +apply plugin: 'groovy' +dependencies { + compile gradleApi() + compile localGroovy() +} diff --git a/experiments/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy b/experiments/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy new file mode 100644 index 00000000000..1677ef19e41 --- /dev/null +++ b/experiments/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy @@ -0,0 +1,57 @@ +package org.jetbrains.kotlin + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.tasks.JavaExec + +class NativeInteropPlugin implements Plugin { + + @Override + void apply(Project prj) { + // TODO: handle other source sets + def srcDir = prj.file("src/main/kotlin") + def generatedSrcDir = new File(prj.buildDir, "nativeInteropStubs") + def nativeLibsDir = new File(prj.buildDir, "nativelibs") + + prj.configurations { + interopStubGenerator + } + + prj.dependencies { + compile project(path: ':Interop:Runtime') + interopStubGenerator project(path: ":Interop:StubGenerator") + } + + prj.task("genInteropStubs", type: JavaExec) { + classpath = prj.configurations.interopStubGenerator + main = "org.jetbrains.kotlin.native.interop.gen.jvm.MainKt" + args = [srcDir, generatedSrcDir, nativeLibsDir] + systemProperties "java.library.path" : prj.findProject(":Interop:Indexer").file("prebuilt/nativelibs") + environment "LIBCLANG_DISABLE_CRASH_RECOVERY": "1" + + inputs.files prj.fileTree(srcDir.path).include('**/*.def') + + outputs.dir generatedSrcDir + outputs.dir nativeLibsDir + } + + prj.sourceSets { + main { + kotlin { + srcDirs generatedSrcDir + } + } + } + + prj.tasks.getByName("compileKotlin") { + dependsOn "genInteropStubs" + } + + // FIXME: choose tasks more wisely + prj.tasks.withType(JavaExec) { + if (name != "genInteropStubs") { + systemProperties "java.library.path": nativeLibsDir + } + } + } +} diff --git a/experiments/gradle/wrapper/gradle-wrapper.jar b/experiments/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..6ffa237849e Binary files /dev/null and b/experiments/gradle/wrapper/gradle-wrapper.jar differ diff --git a/experiments/gradle/wrapper/gradle-wrapper.properties b/experiments/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..3c744c05f43 --- /dev/null +++ b/experiments/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Sep 21 13:46:22 MSK 2016 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip diff --git a/experiments/gradlew b/experiments/gradlew new file mode 100755 index 00000000000..9aa616c273d --- /dev/null +++ b/experiments/gradlew @@ -0,0 +1,169 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/experiments/gradlew.bat b/experiments/gradlew.bat new file mode 100644 index 00000000000..e95643d6a2c --- /dev/null +++ b/experiments/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/experiments/settings.gradle b/experiments/settings.gradle new file mode 100644 index 00000000000..8647f551837 --- /dev/null +++ b/experiments/settings.gradle @@ -0,0 +1,4 @@ +include ':Interop:Indexer' +include ':Interop:StubGenerator' +include ':Interop:Runtime' +include ':InteropExample'