Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-27745
Browse files Browse the repository at this point in the history
  • Loading branch information
ssekhri authored Apr 15, 2020
2 parents 61bc93f + 11dff9d commit 8ff2356
Show file tree
Hide file tree
Showing 11 changed files with 335 additions and 182 deletions.
1 change: 1 addition & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.gradle/
.idea/*
!/.idea/codeStyles/
!/.idea/inspectionProfiles/
.project/
.settings/
build/
Expand Down
162 changes: 162 additions & 0 deletions android/.idea/inspectionProfiles/Project_Default.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,17 @@ beprovided to handle the result.
holder = holder->FindInstanceInPrototypeChain(getProxyTemplate(isolate));
}
if (holder.IsEmpty() || holder->IsNull()) {
LOGE(TAG, "Couldn't obtain argument holder");
args.GetReturnValue().Set(v8::Undefined(isolate));
return;
if (!moduleInstance.IsEmpty()) {
holder = moduleInstance.Get(isolate);
if (holder.IsEmpty() || holder->IsNull()) {
LOGE(TAG, "Couldn't obtain argument holder");
args.GetReturnValue().Set(v8::Undefined(isolate));
return;
}
} else {
LOGE(TAG, "Couldn't obtain argument holder");
args.GetReturnValue().Set(v8::Undefined(isolate));
return;
}
}
</#macro>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ using namespace v8;
<#assign className = Proxy.className(proxyClassName)>

Persistent<FunctionTemplate> ${className}::proxyTemplate;
Persistent<Object> ${className}::moduleInstance;
jclass ${className}::javaClass = NULL;

${className}::${className}() : titanium::Proxy()
Expand All @@ -60,12 +61,13 @@ void ${className}::bindProxy(Local<Object> exports, Local<Context> context)
Local<String> nameSymbol = NEW_SYMBOL(isolate, "${proxyAttrs.name}"); // use symbol over string for efficiency
<#if isModule>
MaybeLocal<Object> maybeInstance = constructor->NewInstance(context);
Local<Object> moduleInstance;
if (!maybeInstance.ToLocal(&moduleInstance)) {
Local<Object> instance;
if (!maybeInstance.ToLocal(&instance)) {
titanium::V8Util::fatalException(isolate, tryCatch);
return;
}
exports->Set(context, nameSymbol, moduleInstance);
exports->Set(context, nameSymbol, instance);
moduleInstance.Reset(isolate, instance);
<#else>
exports->Set(context, nameSymbol, constructor);
</#if>
Expand All @@ -77,6 +79,9 @@ void ${className}::dispose(Isolate* isolate)
if (!proxyTemplate.IsEmpty()) {
proxyTemplate.Reset();
}
if (!moduleInstance.IsEmpty()) {
moduleInstance.Reset();
}

<#if superProxyClassName??>
<@Proxy.superNamespace/>${superProxyClassName}::dispose(isolate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public:

private:
static v8::Persistent<v8::FunctionTemplate> proxyTemplate;
static v8::Persistent<v8::Object> moduleInstance;

// Methods -----------------------------------------------------------
<@Proxy.listMethods ; isFirst, name, method>
Expand Down
13 changes: 7 additions & 6 deletions build/lib/android/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path');
const fs = require('fs-extra');
const utils = require('../utils');
const exec = require('child_process').exec; // eslint-disable-line security/detect-child-process
const { spawn } = require('child_process'); // eslint-disable-line security/detect-child-process
const copyFile = utils.copyFile;
const copyFiles = utils.copyFiles;
const copyAndModifyFile = utils.copyAndModifyFile;
Expand All @@ -16,6 +16,9 @@ const ROOT_DIR = path.join(__dirname, '..', '..', '..');
const TITANIUM_ANDROID_PATH = path.join(__dirname, '..', '..', '..', 'android');
const DIST_ANDROID_PATH = path.join(__dirname, '..', '..', '..', 'dist', 'android');
const GRADLEW_FILE_PATH = path.join(TITANIUM_ANDROID_PATH, isWindows ? 'gradlew.bat' : 'gradlew');
// On CI server, use plain output to avoid nasty progress bars filling up logs
// But on local dev, use the nice UI
const GRADLE_CONSOLE_MODE = (process.env.TRAVIS || process.env.JENKINS || process.env.CI) ? 'plain' : 'rich';
const V8_STRING_VERSION_REGEXP = /(\d+)\.(\d+)\.\d+\.\d+/;

class Android {
Expand Down Expand Up @@ -165,12 +168,10 @@ class Android {
}
}

async function gradlew(argsString) {
async function gradlew(task) {
await new Promise((resolve, reject) => {
const commandLineString = `"${GRADLEW_FILE_PATH}" ${argsString} --console plain --warning-mode all`;
const childProcess = exec(commandLineString, { cwd: TITANIUM_ANDROID_PATH });
childProcess.stdout.pipe(process.stdout);
childProcess.stderr.pipe(process.stderr);
const args = [ task, '--console', GRADLE_CONSOLE_MODE, '--warning-mode', 'all' ];
const childProcess = spawn(GRADLEW_FILE_PATH, args, { cwd: TITANIUM_ANDROID_PATH, stdio: 'inherit' });
childProcess.on('error', reject);
childProcess.on('exit', (exitCode) => {
if (exitCode === 0) {
Expand Down
6 changes: 2 additions & 4 deletions build/lib/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ class IOS {

return new Promise((resolve, reject) => {
const buildScript = path.join(ROOT_DIR, 'support/iphone/build_titaniumkit.sh');
const child = spawn(buildScript, [ '-v', this.sdkVersion, '-t', this.timestamp, '-h', this.gitHash ]);
child.stdout.on('data', data => console.log(`\n${data}`));
child.stderr.on('data', data => console.log(`\n${data}`));

const child = spawn(buildScript, [ '-v', this.sdkVersion, '-t', this.timestamp, '-h', this.gitHash ], { stdio: 'inherit' });
child.on('error', reject);
child.on('exit', code => {
if (code) {
const err = new Error(`TitaniumKit build exited with code ${code}`);
Expand Down
Loading

0 comments on commit 8ff2356

Please sign in to comment.