Skip to content

Commit f8d115a

Browse files
authored
Merge pull request #1065 from NativeScript/master
4.1 RC
2 parents 0917329 + d9ddf2d commit f8d115a

File tree

353 files changed

+63230
-28181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

353 files changed

+63230
-28181
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ bin/
1818
.DS_Store
1919
.settings
2020

21+
.classpath

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
env:
22
global:
33
- NODE_VERSION=6.11.1
4-
- NDK_VERSION=r15c
4+
- NDK_VERSION=r16b
55
- DATE=$(date +%Y-%m-%d)
66
- PACKAGE_VERSION=next-$DATE-$TRAVIS_BUILD_NUMBER
77
- EMULATOR_API_LEVEL=21
@@ -30,6 +30,7 @@ matrix:
3030
- echo no | android create avd --force -n $EMULATOR_NAME-$EMULATOR_API_LEVEL -t android-$EMULATOR_API_LEVEL --abi $ANDROID_ABI -c 12M
3131
- emulator -avd $EMULATOR_NAME-$EMULATOR_API_LEVEL -no-skin -no-audio -no-window &
3232
- android-wait-for-emulator
33+
- "./gradlew runSbgTests --stacktrace"
3334
- "./gradlew runtest --stacktrace"
3435
- adb -e logcat -d 300
3536
before_install:
@@ -62,4 +63,3 @@ cache:
6263

6364
install:
6465
- nvm install $NODE_VERSION
65-

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Contains the source code for the NativeScript's Android Runtime. [NativeScript](
1212
- [Build Prerequisites](#build-prerequisites)
1313
- [How to build](#how-to-build)
1414
- [How to run tests](#how-to-run-tests)
15+
- [Misc](#misc)
1516
- [Get Help](#get-help)
1617

1718
<!-- /TOC -->
@@ -39,11 +40,21 @@ For more details on how it works, read the [documentation](https://docs.nativesc
3940
## Build Prerequisites
4041
Following are the minimal prerequisites to build the runtime package.
4142

42-
* Install the latest [Android Studio ](https://developer.android.com/studio/index.html).
43-
* Install Android API Level 22, 23, 24, 25 from Android Studio -> Tools -> Android -> SDK Manager
44-
* Android NDK 15c - [NDK Archives](https://developer.android.com/ndk/downloads/older_releases.html) or [NDK Downloads](https://developer.android.com/ndk/downloads/index.html) if you can't find it in the archives.
45-
* Download Android Support Repository through the Android SDK Manager
46-
* Download Build Tools 25.0.2 through the Android SDK Manager.
43+
* Install the latest [Android Studio](https://developer.android.com/studio/index.html).
44+
* From the SDK Manager (Android Studio -> Tools -> Android -> SDK Manager) install the following components:
45+
* Android API Level 23, 24, 25, 26
46+
* Android NDK
47+
* Android Support Repository
48+
* Download Build Tools
49+
* CMake
50+
* LLDB
51+
* Clone this repository as well as the submodules: `git clone --recurse-submodules [email protected]:NativeScript/android-runtime.git`
52+
53+
## Working with the Runtime in Android Studio
54+
55+
* Open the test-app folder in Android Studio. It represents a valid Android project and you are able to build and run a test application working with the Runtime from the source.
56+
57+
Note: You might need to run the Android Studio from the command line in order to preserve the environment variables. This is in case you get errors like "missing npm" if starting the studio the usual way.
4758

4859
## How to Build
4960

@@ -76,6 +87,12 @@ Following are the minimal prerequisites to build the runtime package.
7687
```Shell
7788
gradlew runtest
7889
```
90+
## Contribute
91+
We love PRs! Check out the [contributing guidelines](CONTRIBUTING.md). If you want to contribute, but you are not sure where to start - look for [issues labeled `help wanted`](https://github.com/NativeScript/android-runtime/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22).
92+
93+
## Misc
94+
95+
* [Implementing additional Chrome DevTools protocol Domains](docs/extending-inspector.md)
7996

8097
## Get Help
8198
Please, use [github issues](https://github.com/NativeScript/android-runtime/issues) strictly for [reporting bugs](CONTRIBUTING.md#reporting-bugs) or [requesting features](CONTRIBUTING.md#requesting-new-features). For general questions and support, check out the [NativeScript community forum](https://discourse.nativescript.org/) or ask our experts in [NativeScript community Slack channel](http://developer.telerik.com/wp-login.php?action=slack-invitation).
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
rootProject.name = "__PROJECT_NAME__"
2-
include ':app' //, ':runtime', ":runtime-binding-generator"
2+
include ':app'//, ':runtime', ':runtime-binding-generator'
33

4-
//project(':runtime').projectDir = new File('path/to/runtime')
5-
//project(':runtime-binding-generator').projectDir = new File('path/to/runtime-binding-generator')
4+
//project(':runtime').projectDir = new File("${System.env.ANDROID_RUNTIME_HOME}/test-app/runtime")
5+
//project(':runtime-binding-generator').projectDir = new File("${System.env.ANDROID_RUNTIME_HOME}/test-app/runtime-binding-generator")
66

77
file("google-services.json").renameTo(file("./app/google-services.json"))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"v8Version": "6.6.346.23"
3+
}

build.gradle

Lines changed: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Usage:
2+
* Usage:
33
* gradlew - Builds the NativeScript Android App Package using an application project template.
44
gradlew -PgitCommitVersion - sets the commit version of the build
55
gradlew -PpreReleaseVersion - sets the pre-release version of the build (as per semver spec "-alpha" value results in 1.0.0-alpha)
@@ -13,6 +13,8 @@ import groovy.json.JsonSlurper
1313
import groovy.json.JsonBuilder
1414
import groovy.json.JsonOutput
1515

16+
def onlyX86 = project.hasProperty("onlyX86")
17+
1618
def isWinOs = System.properties['os.name'].toLowerCase().contains('windows')
1719
def pVersion = "no package version was provided by build.gradle build"
1820
def arVersion = "no commit sha was provided by build.gradle build"
@@ -64,7 +66,7 @@ task getPackageVersion {
6466

6567
println "Using runtime version from package.json '${pVersion}'"
6668

67-
if (project.hasProperty("packageVersion")) {
69+
if (project.hasProperty("packageVersion") && packageVersion != "") {
6870
pVersion += "-" + packageVersion
6971

7072
println "Using packageVersion property '${pVersion}'"
@@ -77,6 +79,10 @@ task getPackageVersion {
7779
println "Adding preReleaseVersion property '${pVersion}' to package version"
7880
}
7981

82+
if(onlyX86) {
83+
pVersion += "-onlyX86"
84+
}
85+
8086
println "The package version is '${pVersion}'"
8187
}
8288
}
@@ -131,19 +137,59 @@ task generateRuntime {
131137
doFirst {
132138
tasks.generateOptimizedRuntimeAar.execute();
133139

140+
tasks.generateOptimizedWithInspectorRuntimeAar.execute();
141+
134142
if (generateRegularRuntimePackage) {
135143
tasks.generateRuntimeAar.execute();
136144
}
137145
}
138146
}
139147

140-
task generateOptimizedRuntimeAar (type: Exec) {
148+
task cleanRuntime (type: Exec) {
141149
doFirst {
142150
workingDir "$TEST_APP_PATH"
143151
if (isWinOs) {
144-
commandLine "cmd", "/c", "gradlew", ":runtime:assembleRelease", "-PpackageVersion=${pVersion}", "-PgitCommitVersion=${arVersion}", "-Poptimized"
152+
commandLine "cmd", "/c", "gradlew", ":runtime:clean"
153+
} else {
154+
commandLine "./gradlew", ":runtime:clean"
155+
}
156+
}
157+
}
158+
159+
task generateOptimizedRuntimeAar (type: Exec) {
160+
doFirst {
161+
workingDir "$TEST_APP_PATH"
162+
if (onlyX86) {
163+
if (isWinOs) {
164+
commandLine "cmd", "/c", "gradlew", ":runtime:assembleRelease", "-PpackageVersion=${pVersion}", "-PgitCommitVersion=${arVersion}", "-Poptimized", "-PonlyX86"
165+
} else {
166+
commandLine "./gradlew", ":runtime:assembleRelease", "-PpackageVersion=${pVersion}", "-PgitCommitVersion=${arVersion}", "-Poptimized", "-PonlyX86"
167+
}
168+
} else {
169+
if (isWinOs) {
170+
commandLine "cmd", "/c", "gradlew", ":runtime:assembleRelease", "-PpackageVersion=${pVersion}", "-PgitCommitVersion=${arVersion}", "-Poptimized"
171+
} else {
172+
commandLine "./gradlew", ":runtime:assembleRelease", "-PpackageVersion=${pVersion}", "-PgitCommitVersion=${arVersion}", "-Poptimized"
173+
}
174+
}
175+
}
176+
}
177+
178+
task generateOptimizedWithInspectorRuntimeAar (type: Exec) {
179+
doFirst {
180+
workingDir "$TEST_APP_PATH"
181+
if (onlyX86) {
182+
if (isWinOs) {
183+
commandLine "cmd", "/c", "gradlew", ":runtime:assembleRelease", "-PpackageVersion=${pVersion}", "-PgitCommitVersion=${arVersion}", "-PoptimizedWithInspector", "-PonlyX86"
184+
} else {
185+
commandLine "./gradlew", ":runtime:assembleRelease", "-PpackageVersion=${pVersion}", "-PgitCommitVersion=${arVersion}", "-PoptimizedWithInspector", "-PonlyX86"
186+
}
145187
} else {
146-
commandLine "./gradlew", ":runtime:assembleRelease", "-PpackageVersion=${pVersion}", "-PgitCommitVersion=${arVersion}", "-Poptimized"
188+
if (isWinOs) {
189+
commandLine "cmd", "/c", "gradlew", ":runtime:assembleRelease", "-PpackageVersion=${pVersion}", "-PgitCommitVersion=${arVersion}", "-PoptimizedWithInspector"
190+
} else {
191+
commandLine "./gradlew", ":runtime:assembleRelease", "-PpackageVersion=${pVersion}", "-PgitCommitVersion=${arVersion}", "-PoptimizedWithInspector"
192+
}
147193
}
148194
}
149195
}
@@ -207,6 +253,11 @@ task copyFilesToProjectTemeplate {
207253
into "$DIST_FRAMEWORK_PATH/app/libs/runtime-libs"
208254
rename "runtime-optimized-release.aar", "nativescript-optimized.aar"
209255
}
256+
copy {
257+
from "$TEST_APP_PATH/runtime/build/outputs/aar/runtime-optimized-with-inspector-release.aar"
258+
into "$DIST_FRAMEWORK_PATH/app/libs/runtime-libs"
259+
rename "runtime-optimized-with-inspector-release.aar", "nativescript-optimized-with-inspector.aar"
260+
}
210261
copy {
211262
from "$TEST_APP_PATH/app/build.gradle"
212263
into "$DIST_FRAMEWORK_PATH/app"
@@ -273,12 +324,9 @@ createDistDir.dependsOn(generateMdgJar)
273324

274325
getPackageVersion.dependsOn(createDistDir)
275326
getCommitVersion.dependsOn(getPackageVersion)
276-
277327
generateRuntime.dependsOn(getCommitVersion)
278-
generateOptimizedRuntimeAar.dependsOn(generateRuntime)
279-
generateRuntimeAar.dependsOn(generateOptimizedRuntimeAar)
280328

281-
copyFilesToProjectTemeplate.dependsOn(generateRuntimeAar)
329+
copyFilesToProjectTemeplate.dependsOn(generateRuntime)
282330
copyProjectTemplate.dependsOn(copyFilesToProjectTemeplate)
283331
copyPackageJson.dependsOn(copyProjectTemplate)
284332
setPackageVersionInPackageJsonFile.dependsOn(copyPackageJson)
@@ -291,7 +339,18 @@ task createPackage {
291339
println "Creating NativeScript Android Package"
292340
}
293341

294-
task runSbgTests (type: Exec) {
342+
task runAstTests (type: Exec) {
343+
doFirst {
344+
workingDir "$TEST_APP_PATH/build-tools/jsparser/tests"
345+
if (isWinOs) {
346+
commandLine "cmd", "/c", "npm", "test"
347+
} else {
348+
commandLine "npm", "test"
349+
}
350+
}
351+
}
352+
353+
task runSbgTests (type: Exec, dependsOn: 'runAstTests') {
295354
doFirst {
296355
workingDir "$TEST_APP_PATH"
297356
if (isWinOs) {
@@ -305,10 +364,18 @@ task runSbgTests (type: Exec) {
305364
task runTests (type: Exec) {
306365
doFirst {
307366
workingDir "$TEST_APP_PATH"
308-
if (isWinOs) {
309-
commandLine "cmd", "/c", "gradlew", "-b", "runtests.gradle", "runtests"
367+
if (onlyX86) {
368+
if (isWinOs) {
369+
commandLine "cmd", "/c", "gradlew", "-b", "runtests.gradle", "runtests", "-PonlyX86"
370+
} else {
371+
commandLine "./gradlew", "-b", "runtests.gradle", "runtests", "-PonlyX86"
372+
}
310373
} else {
311-
commandLine "./gradlew", "-b", "runtests.gradle", "runtests"
374+
if (isWinOs) {
375+
commandLine "cmd", "/c", "gradlew", "-b", "runtests.gradle", "runtests"
376+
} else {
377+
commandLine "./gradlew", "-b", "runtests.gradle", "runtests"
378+
}
312379
}
313380
}
314381
}

build.sh

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env bash
12
###############################################################################################
23
# Android Runtime build script for CI.
34
# This file is used by the CI only and it's not meant for regular development.
@@ -12,32 +13,59 @@ git submodule update --init
1213

1314
echo "Cleanup old build and test artefacts"
1415
rm -rf consoleLog.txt
15-
rm -rf test-app/dist/android_unit_test_results.xml
16+
rm -rf test-app/dist/*.xml
1617

1718
echo "Stopping running emulators if any"
1819
for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
1920
for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
2021
for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
2122

22-
echo "Start emulator"
23-
$ANDROID_HOME/tools/emulator -avd Emulator-Api19-Default -wipe-data -gpu on &
23+
./gradlew cleanRuntime
24+
if [ "$1" != 'unit_tests_only' ]; then
25+
echo "Building Android Runtime with paramerter packageVersion: $PACKAGE_VERSION and commit: $GIT_COMMIT"
26+
./gradlew -PpackageVersion=$PACKAGE_VERSION -PgitCommitVersion=$GIT_COMMIT
27+
cp dist/tns-android-*.tgz dist/tns-android.tgz
28+
else
29+
echo "Building Android Runtime for x86 unit tests with paramerter packageVersion: $PACKAGE_VERSION and commit: $GIT_COMMIT"
30+
./gradlew -PpackageVersion=$PACKAGE_VERSION -PgitCommitVersion=$GIT_COMMIT -PskipUnoptimized -PonlyX86
31+
cp dist/tns-android-*.tgz dist/tns-android.tgz
32+
fi
2433

25-
echo "Building Android Runtime with paramerter packageVersion: $PACKAGE_VERSION and commit: $GIT_COMMIT"
26-
./gradlew -PpackageVersion=$PACKAGE_VERSION -PgitCommitVersion=$GIT_COMMIT
34+
if [ "$2" != '' ]; then
35+
listOfEmulators=$2
36+
else
37+
listOfEmulators="Emulator-Api19-Default"
38+
fi
2739

28-
echo "Run Android Runtime unit tests"
29-
cp dist/tns-android-*.tgz dist/tns-android.tgz
30-
$ANDROID_HOME/platform-tools/adb devices
31-
$ANDROID_HOME/platform-tools/adb -e logcat -c
32-
$ANDROID_HOME/platform-tools/adb -e logcat > consoleLog.txt &
33-
./gradlew runtest
40+
# Run static binding generator unit tests
41+
./gradlew runSbgTests
3442

35-
echo $cwd
43+
for emulator in $listOfEmulators; do
44+
echo "Start emulator $emulator"
45+
$ANDROID_HOME/emulator/emulator -avd ${emulator} -wipe-data -gpu on&
46+
47+
echo "Run Android Runtime unit tests for $emulator"
48+
$ANDROID_HOME/platform-tools/adb devices
49+
$ANDROID_HOME/platform-tools/adb -e logcat -c
50+
$ANDROID_HOME/platform-tools/adb -e logcat > consoleLog.txt&
3651

37-
cd $cwd
52+
if [ "$1" != 'unit_tests_only' ]; then
53+
./gradlew runtest
54+
else
55+
./gradlew runtest -PonlyX86
56+
fi
3857

39-
echo "Stopping running emulators"
40-
for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done || true
41-
for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done || true
42-
for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID &> /dev/null; done || true
58+
echo "Rename unit test result"
59+
(
60+
cd ./test-app/dist
61+
mv android_unit_test_results.xml $emulator.xml
62+
)
4363

64+
echo "Stopping running emulators"
65+
for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
66+
for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
67+
for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
68+
done
69+
70+
echo $cwd
71+
cd $cwd

0 commit comments

Comments
 (0)