Fixed samples for the latest changes in Gradle plugin.

- Smaller gradle scripts.
- More structure in sample projects.
- Simplified build/run.
- Added gradle to the rest two samples.
- Almost removed all sh scripts.
- Gradle now works only inside of build directory.
- Fixed READMEs according to the new changes.
This commit is contained in:
Alexander Podkhalyuzin
2017-06-08 13:32:13 +03:00
committed by SvyatoslavScherbina
parent f1fa5327f3
commit bc941269f0
75 changed files with 344 additions and 382 deletions
+9 -4
View File
@@ -2,11 +2,16 @@
This example shows how to communicate with libcurl, HTTP/HTTPS/FTP/etc client library.
Debian-like distros may need to `apt-get install libcurl4-openssl-dev`.
To build use `./build.sh` script without arguments (or specify `TARGET` variable if cross-compiling).
You also may use Gradle to build this sample: `../gradlew build`.
To run use
To build use `../gradlew build` or `./build.sh`.
./Curl.kexe https://www.jetbrains.com
To run use `../gradlew run`
To change run arguments, change property runArgs in gradle.propeties file
or pass `-PrunArgs="https://www.jetbrains.com"` to gradle run.
Alternatively you can run artifact directly
./build/konan/bin/Curl/Curl.kexe https://www.jetbrains.com
It will perform HTTP get and print out the data obtained.
-18
View File
@@ -2,31 +2,13 @@ apply plugin: 'konan'
konanInterop {
libcurl {
defFile 'libcurl.def'
includeDirs '/usr/include', '/opt/local/include', '/usr/local/opt/curl/include', '.'
}
}
konanArtifacts {
Curl {
inputFiles project.fileTree('src')
useInterop 'libcurl'
linkerOpts "-L/opt/local/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/opt/curl/lib -lcurl"
}
}
build {
project.ext { outputFile = "${projectDir.canonicalPath}/${file(compileKonanCurl.artifactPath).name}" }
doLast {
copy {
from compileKonanCurl.artifactPath
into projectDir.canonicalPath
}
}
}
clean {
doLast {
delete outputFile
}
}
+13 -5
View File
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
PATH=../../dist/bin:../../bin:$PATH
DIR=.
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )
PATH=$DIR/../../dist/bin:$DIR/../../bin:$PATH
CFLAGS_macbook="-I /opt/local/include"
CFLAGS_macbook=-I/opt/local/include
CFLAGS_linux="-I /usr/include -I /usr/include/x86_64-linux-gnu"
LINKER_ARGS_macbook="-L/opt/local/lib -lcurl"
LINKER_ARGS_linux="-L/usr/lib/x86_64-linux-gnu -lcurl"
@@ -23,5 +23,13 @@ LINKER_ARGS=${!var}
var=COMPILER_ARGS_${TARGET}
COMPILER_ARGS=${!var} # add -opt for an optimized build.
cinterop -compilerOpts "$CFLAGS" -def $DIR/libcurl.def -target $TARGET -o libcurl || exit 1
konanc -target $TARGET src -library libcurl -linkerOpts "$LINKER_ARGS" -o Curl || exit 1
mkdir -p $DIR/build/c_interop/
mkdir -p $DIR/build/bin/
cinterop -compilerOpts "$CFLAGS" -compilerOpts -I$DIR -compilerOpts -I/usr/include -def $DIR/src/main/c_interop/libcurl.def -target $TARGET \
-o $DIR/build/c_interop/libcurl.bc || exit 1
konanc -target $TARGET $DIR/src/main/kotlin -library $DIR/build/c_interop/libcurl.bc -linkerOpts "$LINKER_ARGS" \
-o $DIR/build/bin/Curl.kexe || exit 1
echo "Artifact path is ./build/bin/Curl.kexe"
+1
View File
@@ -0,0 +1 @@
runArgs=https://www.jetbrains.com