Skip to content

Commit 974b926

Browse files
committed
Merge branch 'master' into release
2 parents 368c29d + 6f5519f commit 974b926

File tree

67 files changed

+1353
-1308
lines changed

Some content is hidden

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

67 files changed

+1353
-1308
lines changed

.travis.yml

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,66 @@ env:
77
- EMULATOR_API_LEVEL=21
88
- ANDROID_ABI=armeabi-v7a
99
- EMULATOR_NAME=runtime-emu
10-
sudo: true
11-
language: android
12-
jdk:
13-
- oraclejdk8
14-
git:
15-
submodules: false
10+
11+
matrix:
12+
include:
13+
- stage: "Static Binding Generator Parser Tests"
14+
language: node_js
15+
node_js: "6"
16+
git:
17+
submodules: false
18+
script:
19+
- cd android-static-binding-generator
20+
- npm install && node run-tests
21+
- cd ..
22+
- stage: "Static Binding Generator Class Generator Tests"
23+
language: android
24+
jdk: oraclejdk8
25+
git:
26+
submodules: false
27+
script:
28+
- "android-static-binding-generator/project/staticbindinggenerator/gradlew test --project-dir android-static-binding-generator/project/staticbindinggenerator/"
29+
- stage: "Build and Tests"
30+
sudo: true
31+
language: android
32+
jdk: oraclejdk8
33+
android:
34+
components:
35+
- android-$EMULATOR_API_LEVEL
36+
- extra-android-support
37+
- extra-android-m2repository
38+
- cmake
39+
- sys-img-$ANDROID_ABI-android-$EMULATOR_API_LEVEL
40+
git:
41+
submodules: false
42+
script:
43+
# (master branch) build the runtime twice - optimized, and regular packages, skip on PRs
44+
# test-app/gradlew runtest will take care of building the runtime for its testing needs
45+
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./gradlew -PpreReleaseVersion=$PACKAGE_VERSION -PgitCommitVersion=$TRAVIS_COMMIT --stacktrace; fi'
46+
- echo no | android create avd --force -n $EMULATOR_NAME-$EMULATOR_API_LEVEL -t android-$EMULATOR_API_LEVEL --abi $ANDROID_ABI -c 12M
47+
- emulator -avd $EMULATOR_NAME-$EMULATOR_API_LEVEL -no-skin -no-audio -no-window &
48+
- android-wait-for-emulator
49+
- cd test-app
50+
- "./gradlew runtest --stacktrace"
51+
- adb -e logcat -d 300
52+
- cd ..
53+
before_install:
54+
- echo "y" | sdkmanager "cmake;3.6.4111459"
55+
- sed -i 's/[email protected]:/https:\/\/github.com\//' .gitmodules
56+
- git submodule update --init --recursive
57+
- wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux-x86_64.zip
58+
- chmod +x android-ndk-$NDK_VERSION-linux-x86_64.zip
59+
- "unzip -q android-ndk-$NDK_VERSION-linux-x86_64.zip"
60+
- "rm -rf android-ndk-$NDK_VERSION-linux-x86_64.zip"
61+
- export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
62+
- export PATH=${PATH}:${ANDROID_NDK_HOME}
63+
1664
android:
1765
components:
1866
- platform-tools
1967
- tools
2068
- build-tools-26.0.1
2169
- android-26
22-
- android-$EMULATOR_API_LEVEL
23-
- extra-android-support
24-
- extra-android-m2repository
25-
- cmake
26-
- sys-img-$ANDROID_ABI-android-$EMULATOR_API_LEVEL
2770
licenses:
2871
- 'android-sdk-preview-license-52d11cd2'
2972
- 'android-sdk-license-.+'
@@ -34,23 +77,7 @@ cache:
3477
directories:
3578
- "$HOME/.gradle/caches/"
3679
- "$HOME/.gradle/wrapper/"
37-
before_install:
38-
- echo "y" | sdkmanager "cmake;3.6.4111459"
39-
- sed -i 's/[email protected]:/https:\/\/github.com\//' .gitmodules
40-
- git submodule update --init --recursive
41-
- wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux-x86_64.zip
42-
- chmod +x android-ndk-$NDK_VERSION-linux-x86_64.zip
43-
- "unzip -q android-ndk-$NDK_VERSION-linux-x86_64.zip"
44-
- "rm -rf android-ndk-$NDK_VERSION-linux-x86_64.zip"
45-
- export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
46-
- export PATH=${PATH}:${ANDROID_NDK_HOME}
80+
4781
install:
4882
- nvm install $NODE_VERSION
49-
script:
50-
- "./gradlew -PpreReleaseVersion=$PACKAGE_VERSION -PgitCommitVersion=$TRAVIS_COMMIT --stacktrace"
51-
- echo no | android create avd --force -n $EMULATOR_NAME-$EMULATOR_API_LEVEL -t android-$EMULATOR_API_LEVEL --abi $ANDROID_ABI -c 12M
52-
- emulator -avd $EMULATOR_NAME-$EMULATOR_API_LEVEL -no-skin -no-audio -no-window &
53-
- android-wait-for-emulator
54-
- "cd test-app && ./gradlew runtest --stacktrace"
55-
- adb -e logcat -d 300
56-
- cd ..
83+

android-static-binding-generator/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"name": "static_analysis",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "project/parse.js",
5+
"main": "project/parser",
66
"scripts": {
7-
"test": "jasmine JASMINE_CONFIG_PATH=jasmine.json"
7+
"test": "node run-tests.js"
88
},
9+
"repository": "https://github.com/NativeScript/android-runtime/",
910
"author": "",
1011
"license": "ISC",
1112
"dependencies": {
@@ -15,6 +16,7 @@
1516
"lazy": "^1.0.11"
1617
},
1718
"devDependencies": {
18-
"jasmine-node": "^1.14.5"
19+
"jasmine": "2.8.0",
20+
"jasmine-node": "1.14.5"
1921
}
2022
}

android-static-binding-generator/project/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def cachedJarsFilePath = "$projectDir/cached.txt"
1414
def jsParserP = "$projectDir/parser/js_parser.js"
1515
def jsFilesParametersP = "$projectDir/jsFilesParameters.txt"
1616

17-
def webpackWorkersExcludePath = "$projectDir/../../src/main/assets/app/__worker-chunks.json"
17+
def webpackWorkersExcludePath = "$rootDir/app/src/main/assets/app/__worker-chunks.json"
1818
def webpackWorkersExcludesList = [];
1919

2020
def workersExcludeFile = file(webpackWorkersExcludePath);
@@ -40,8 +40,13 @@ if (project.hasProperty("outDir")) {
4040
def absoluteJsCodeDir;
4141
def jsCodeAbsolutePath;
4242
if (!project.hasProperty("test")) {
43-
absoluteJsCodeDir = project.jsCodeDir
44-
jsCodeAbsolutePath = absoluteJsCodeDir.getAbsolutePath()
43+
println project.jsCodeDir.equals(null)
44+
if(project.jsCodeDir.exists()) {
45+
absoluteJsCodeDir = project.jsCodeDir
46+
jsCodeAbsolutePath = absoluteJsCodeDir.getAbsolutePath()
47+
} else {
48+
logger.log(LogLevel.WARN, "The input jsCodeDir: ${jsCodeDir} folder could not be found. Please make sure you've passed the correct folder containing the .js files that need to be parsed.");
49+
}
4550
}
4651

4752
def utf8 = StandardCharsets.UTF_8

android-static-binding-generator/project/parser/visitors/es5-visitors.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ var es5_visitors = (function () {
599599
}
600600

601601
function _generateLineToWrite(classNameFromDecorator, extendClass, overriddenMethodNames, extendInfo, filePath, implementedInterfaces) {
602-
var lineToWrite = extendClass + "*" + extendInfo.replace(/[\\/\\-]/g, "_") + "*" + overriddenMethodNames + "*" + classNameFromDecorator + "*" + filePath + "*" + (implementedInterfaces ? implementedInterfaces : "");
602+
var sanitizedExtendInfo = extendInfo.replace(/[-\\/\\.]/g, "_");
603+
var lineToWrite = extendClass + "*" + sanitizedExtendInfo + "*" + overriddenMethodNames + "*" + classNameFromDecorator + "*" + filePath + "*" + (implementedInterfaces ? implementedInterfaces : "");
603604
return lineToWrite;
604605
}
605606

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
(function () {
2+
let { spawnSync, execSync } = require('child_process');
3+
4+
console.log("Installing JavaScript parser test dependencies.");
5+
6+
let npmInstallResult = execSync('npm install');
7+
8+
console.log(npmInstallResult.toString());
9+
10+
console.log("Executing JavaScript parser tests using Jasmine.");
11+
12+
const subprocess = spawnSync('node', ['./node_modules/jasmine/bin/jasmine.js', 'JASMINE_CONFIG_PATH=jasmine.json'], { cwd: __dirname });
13+
14+
let stdout = subprocess.stdout.toString();
15+
let stderr = subprocess.stderr.toString();
16+
let code = subprocess.status;
17+
let err = subprocess.error;
18+
19+
if (code !== 0) {
20+
console.log("Tests runner exited with a non-zero code.");
21+
22+
let errorString = stdout;
23+
24+
if (err) {
25+
errorString = err;
26+
}
27+
28+
if (stderr) {
29+
errorString = stderr;
30+
}
31+
32+
throw new Error(errorString);
33+
}
34+
35+
console.log(stdout);
36+
}());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
android.telephony.PhoneStateListener.extend({});
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
(function() {
2+
var __extends_ts = function (d, b) {
3+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4+
function __() { this.constructor = d; }
5+
__.prototype = b.prototype;
6+
d.prototype = new __();
7+
};
8+
9+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
10+
var c = arguments.length;
11+
var r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
12+
13+
if (typeof global.Reflect === "object" && typeof global.Reflect.decorate === "function") {
14+
r = global.Reflect.decorate(decorators, target, key, desc);
15+
}
16+
else {
17+
for (var i = decorators.length - 1; i >= 0; i--) {
18+
if (d = decorators[i]) {
19+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
20+
}
21+
}
22+
}
23+
return c > 3 && r && Object.defineProperty(target, key, r), r;
24+
};
25+
26+
var __native = function(thiz) {
27+
var result = thiz.__proto__;
28+
29+
for (var prop in thiz)
30+
{
31+
if (thiz.hasOwnProperty(prop))
32+
{
33+
thiz.__proto__[prop] = thiz[prop];
34+
delete thiz[prop];
35+
}
36+
}
37+
38+
thiz.constructor = undefined;
39+
thiz.__proto__ = undefined;
40+
Object.freeze(thiz);
41+
Object.preventExtensions(thiz)
42+
return result;
43+
};
44+
45+
var __extends = function(Child, Parent) {
46+
47+
if (Parent.extend) {
48+
if (Parent.__isPrototypeImplementationObject) {
49+
throw new Error("Can not extend an already extended native object.");
50+
}
51+
52+
function extend(child, parent) {
53+
__log("TS extend called");
54+
if (!child.__extended) {
55+
child.__extended = parent.extend(child.name, child.prototype);
56+
}
57+
58+
return child.__extended;
59+
};
60+
61+
Parent.__activityExtend = function(parent, name, implementationObject) {
62+
__log("__activityExtend called");
63+
return parent.extend(name, implementationObject);
64+
};
65+
66+
Parent.call = function(thiz) {
67+
var Extended = extend(thiz.__proto__.__child, thiz.__proto__.__parent);
68+
if (arguments.length > 1)
69+
{
70+
thiz.__proto__ = new (Function.prototype.bind.apply(Extended, [null].concat(Array.prototype.slice.call(arguments, 1))));
71+
}
72+
else
73+
{
74+
thiz.__proto__ = new Extended();
75+
}
76+
};
77+
78+
Parent.apply = function(thiz, args) {
79+
var Extended = extend(thiz.__proto__.__child, thiz.__proto__.__parent);
80+
if (args && args.length > 0)
81+
{
82+
thiz.__proto__ = new (Function.prototype.bind.apply(Extended, [null].concat(args)));
83+
}
84+
else
85+
{
86+
thiz.__proto__ = new Extended();
87+
}
88+
};
89+
}
90+
91+
__extends_ts(Child, Parent);
92+
93+
94+
if (Parent.extend) {
95+
Child.__isPrototypeImplementationObject = true;
96+
Child.__proto__ = Parent;
97+
Child.prototype.__parent = Parent;
98+
Child.prototype.__child = Child;
99+
}
100+
}
101+
102+
function JavaProxy(className) {
103+
return function (target) {
104+
var extended = target.extend(className, target.prototype)
105+
extended.name = className;
106+
return extended;
107+
};
108+
}
109+
110+
function Interfaces(interfacesArr) {
111+
return function (target) {
112+
if(interfacesArr instanceof Array) {
113+
// attach interfaces: [] to the object
114+
target.prototype.interfaces = interfacesArr;
115+
}
116+
}
117+
}
118+
119+
global.__native = __native;
120+
global.__extends = __extends;
121+
global.__decorate = __decorate;
122+
global.JavaProxy = JavaProxy;
123+
global.Interfaces = Interfaces;
124+
})()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
android.telephony.PhoneStateListener.extend({});

0 commit comments

Comments
 (0)