Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #43 from crosswalk-project/maxw-remove-embedded
Browse files Browse the repository at this point in the history
Maxw remove embedded
  • Loading branch information
townxelliot committed Mar 14, 2014
2 parents bdb0bd6 + e9fbc0e commit ede415d
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 67 deletions.
10 changes: 6 additions & 4 deletions README.md
Expand Up @@ -186,21 +186,23 @@ Crosswalk applications can run in one of two *modes*:

(NB `adb` is the Android SDK installation tool; you will need it on your PATH for the above to work.)

The generator will build an application in shared mode if you don't specify any architecture. Specify the architecture by setting the `arch` property (if using the API) or the `--arch` option (if using `xwalk_apkgen`).

* *Embedded mode*

An application in this mode includes the Crosswalk runtime inside its apk. Consequently, an embedded mode application is self-contained: it can be installed on an Android device without requiring the runtime library to be installed first. However, embedded mode apk files are platform-specific, unlike shared mode apk files: they will only work on the platform for which they were built.

The default application mode can be modified by setting the `embedded` property for the application to `true`. This can be done in the App config if using the API, e.g.
The default application mode can be modified by setting the `arch` property for the application to either `x86` or `arm`. This can be done in the App config if using the API, e.g.

{
"appRoot": "/home/me/projects/myapp",
"appLocalPath": "index.html",
"name": "My app",
"package": "me.myname.myapp",
"embedded": true
"arch": "x86"
}

or via the `--embedded` command line flag if using `xwalk_apkgen`:
or via the `--arch` command line flag if using `xwalk_apkgen`:

xwalk_apkgen --androidSDKDir /home/me/android-sdk-linux \
--xwalkAndroidDir /home/me/xwalk-android/xwalk_app_template \
Expand All @@ -209,7 +211,7 @@ or via the `--embedded` command line flag if using `xwalk_apkgen`:
--name "My app" \
--package "me.myname.myapp" \
--outDir build \
--embedded
--arch x86

# Permissions

Expand Down
18 changes: 6 additions & 12 deletions src/env.js
Expand Up @@ -213,7 +213,7 @@ var locateXwalkPieces = function (finder, config) {
}

// extra components required for embedded mode
if (!config.xwalkEmbeddedJar) {
if (config.arch && !config.xwalkEmbeddedJar) {
xwalkPieces.xwalkEmbeddedJar = {
files: ['xwalk_core_embedded.dex.jar', 'xwalk_runtime_embedded.dex.jar'],
guessDirs: ['libs']
Expand Down Expand Up @@ -256,7 +256,7 @@ var locateXwalkPieces = function (finder, config) {
};
}

if (!config.nativeLibs) {
if (config.arch && !config.nativeLibs) {
var nativeLibsDir = path.join('native_libs', 'armeabi-v7a', 'libs');

if (config.arch === 'x86') {
Expand All @@ -268,7 +268,7 @@ var locateXwalkPieces = function (finder, config) {
};
}

if (!config.xwalkAssets) {
if (config.arch && !config.xwalkAssets) {
xwalkPieces.xwalkAssets = {
directory: 'native_libs_res'
};
Expand Down Expand Up @@ -330,13 +330,9 @@ var locateXwalkPieces = function (finder, config) {
* version string to pass to javac's "-source" option
* @param {string} [config.targetJavaVersion=Env.CONFIG_DEFAULTS.targetJavaVersion] -
* version string to pass to javac's "-target" option
* @param {string} [config.arch=arm] - architecture to build for; "x86" or "arm"
* @param {string} [config.arch=arm] - architecture to build for; "x86" or "arm"; if this is not set, the apk will be built for shared mode
* @param {string} [config.aapt=derived from androidSDKDir] - location of the
* aapt binary (part of the Android SDK)
* @param {boolean} [config.embedded=Env.CONFIG_DEFAULTS.embedded] -
* set to true to bundle Crosswalk with the output apk file, false
* to use shared mode (requires XWalkRuntimeLib.apk to installed
* on the device to run the application)
* @param {string} [config.dx=derived from androidSDKDir] - location of the
* dx binary (part of the Android SDK)
* @param {string} [config.anttasksJar=derived from androidSDKDir] - location
Expand Down Expand Up @@ -441,7 +437,6 @@ var Env = function (config, deps) {
* @property {string} sourceJavaVersion - set to "1.5"
* @property {string} targetJavaVersion - set to "1.5"
* @property {string} arch - set to "arm"
* @property {boolean} embedded - set to true
* @property {string} androidAPILevel - "19"
* @property {string} keystore - set to xwalk-android keystore
* @property {string} keystoreAlias - set to "xwalkdebugkey"
Expand All @@ -455,8 +450,7 @@ Env.CONFIG_DEFAULTS = {

sourceJavaVersion: '1.5',
targetJavaVersion: '1.5',
arch: 'x86',
embedded: true,
arch: null,

androidSDKDir: null,
androidAPILevel: null,
Expand Down Expand Up @@ -537,7 +531,7 @@ Env.prototype.build = function (app, locations) {

// if the app is in embedded mode, add jars and other resources
// to support that
if (this.embedded) {
if (this.arch) {
locations.addJars(this.xwalkEmbeddedJar);
locations.addAssets(this.xwalkAssets);
locations.addNativeLibs(this.nativeLibs);
Expand Down
6 changes: 1 addition & 5 deletions src/locations.js
Expand Up @@ -58,7 +58,6 @@ var Locations = function (app, env, destDir) {

var name = app.sanitisedName;
var pkg = app.pkg;
var embedded = env.embedded;
var arch = env.arch;

if (typeof name !== 'string') {
Expand All @@ -67,9 +66,6 @@ var Locations = function (app, env, destDir) {
else if (typeof pkg !== 'string') {
throw new Error('app.pkg should be a string');
}
else if (embedded !== true && embedded !== false) {
throw new Error('env.embedded should be a boolean');
}

/**
* @member
Expand All @@ -89,7 +85,7 @@ var Locations = function (app, env, destDir) {
var resPackageSuffix = '.ap_';
var apkSuffix = '.apk';

if (embedded) {
if (arch) {
resPackageSuffix = '.' + arch + resPackageSuffix;
apkSuffix = '.' + arch + apkSuffix;
}
Expand Down
25 changes: 2 additions & 23 deletions src/xwalk-apkgen.js
Expand Up @@ -115,15 +115,8 @@ var cliOpts = {
},

'arch': {
describe: 'Architecture to build for (x86 or arm)',
section: 'Environment (env)',
default: Env.CONFIG_DEFAULTS.arch
},

'embedded': {
describe: 'set to true to enable embedded mode; or false for shared mode',
section: 'Environment (env)',
defaultDescription: Env.CONFIG_DEFAULTS.embedded
describe: 'Architecture to build for (x86 or arm), undefined for shared',
section: 'Environment (env)'
},

// app required (if no app-config file)
Expand Down Expand Up @@ -192,14 +185,6 @@ var cliOpts = {
default: App.CONFIG_DEFAULTS.jars
},

'mode': {
describe: '"shared" to use the shared xwalk runtime library; "embedded" ' +
'to bundle the library with the app (NB this is retained for ' +
'backwards compatibility with make_apk.py)',
section: 'Application (app)',
default: (App.CONFIG_DEFAULTS.embedded === true ? 'embedded' : 'shared')
},

// help
'help': {
alias: 'h',
Expand Down Expand Up @@ -262,12 +247,6 @@ _.each(Env.CONFIG_DEFAULTS, function (value, key) {
envConfig[key] = nconf.get(key);
});

// set the mode
envConfig.embedded = nconf.get('embedded');
if (envConfig.embedded === undefined) {
envConfig.embedded = (nconf.get('mode') === 'embedded');
}

// START
logger.log('\n*** STARTING BUILD');

Expand Down
2 changes: 1 addition & 1 deletion test/functional/all.sh
Expand Up @@ -38,7 +38,7 @@ $WD/make-apk.test.sh --arch $ARCH

echo
echo "--------------------- MAKE-APK-SHARED.TEST.SH"
$WD/make-apk-shared.test.sh --arch $ARCH
$WD/make-apk-shared.test.sh

echo
echo "--------------------- MAKE-APK-WITH_EXTENSIONS.TEST.SH"
Expand Down
6 changes: 2 additions & 4 deletions test/functional/embedded-api-example.js
Expand Up @@ -52,10 +52,8 @@ var envConfig = {
// script (part of this project; see the README for details)
xwalkAndroidDir: xwalkAndroidDir,

arch: arch,

// make an embedded mode apk
embedded: true
// make an embedded mode apk for arch
arch: arch
};

// application configuration
Expand Down
3 changes: 1 addition & 2 deletions test/functional/extensions-api-example.js
Expand Up @@ -59,8 +59,7 @@ var envConfig = {
// script (part of this project; see the README for details)
xwalkAndroidDir: xwalkAndroidDir,

arch: arch,
embedded: true
arch: arch
};

// application configuration
Expand Down
2 changes: 1 addition & 1 deletion test/functional/make-apk-with-extensions.test.sh
Expand Up @@ -18,4 +18,4 @@ fi
WD=`dirname $0`
OUT_DIR=$WD/build/make-apk-with-extensions

$WD/../../bin/xwalk_apkgen --orientation portrait --embedded --app-root $WD/app-with-extensions/app --app-local-path index.html --name "X make apk with extensions test sh" --package "make.apk.with.extensions" --remoteDebugging --ext-config $WD/app-with-extensions/xwalk-extensions/config.json --jars $WD/app-with-extensions/jars/commons-io-2.4.jar,$WD/app-with-extensions/jars/commons-lang3-3.1.jar,$WD/app-with-extensions/jars/entagged-audioformats-0.15.jar,$WD/app-with-extensions/jars/gson-2.2.4.jar --javaSrcDirs $WD/app-with-extensions/xwalk-extensions/java/ -a $androidSDKDir -x $xwalkAndroidDir -o $OUT_DIR --version 1.0.0 $*
$WD/../../bin/xwalk_apkgen --orientation portrait --app-root $WD/app-with-extensions/app --app-local-path index.html --name "X make apk with extensions test sh" --package "make.apk.with.extensions" --remoteDebugging --ext-config $WD/app-with-extensions/xwalk-extensions/config.json --jars $WD/app-with-extensions/jars/commons-io-2.4.jar,$WD/app-with-extensions/jars/commons-lang3-3.1.jar,$WD/app-with-extensions/jars/entagged-audioformats-0.15.jar,$WD/app-with-extensions/jars/gson-2.2.4.jar --javaSrcDirs $WD/app-with-extensions/xwalk-extensions/java/ -a $androidSDKDir -x $xwalkAndroidDir -o $OUT_DIR --version 1.0.0 $*
13 changes: 12 additions & 1 deletion test/functional/make-apk.test.sh
Expand Up @@ -21,4 +21,15 @@ WD=`dirname $0`
OUT_DIR=$WD/build/make_apk

# make the apk
$WD/../../bin/xwalk_apkgen -o $OUT_DIR --appRoot=$WD/demo-app --appLocalPath=index.html --name "X make apk test sh" --package "make.apk" --icon "$WD/demo-app/icon.png" --mode "embedded" --keystore $WD/custom-keystore/mycerts.jks --keystoreAlias my --keystorePassword demodemo --remoteDebugging --version 1.0.0 $*
$WD/../../bin/xwalk_apkgen \
-o $OUT_DIR \
--appRoot=$WD/demo-app \
--appLocalPath=index.html \
--name "X make apk test sh" \
--package "make.apk" \
--icon "$WD/demo-app/icon.png" \
--keystore $WD/custom-keystore/mycerts.jks \
--keystoreAlias my \
--keystorePassword demodemo \
--remoteDebugging --version 1.0.0 $*

3 changes: 1 addition & 2 deletions test/functional/simple-api-example.js
Expand Up @@ -52,8 +52,7 @@ var envConfig = {
// script (part of this project; see the README for details)
xwalkAndroidDir: xwalkAndroidDir,

arch: arch,
embedded: true
arch: arch
};

// application configuration
Expand Down
2 changes: 1 addition & 1 deletion test/unit/app-skeleton.test.js
Expand Up @@ -56,7 +56,7 @@ describe('AppSkeleton', function () {
};

// Locations object pointing at the output directory
var locations = Locations(app, {arch: 'x86', embedded: true}, outDir);
var locations = Locations(app, {arch: 'x86'}, outDir);

var appSkeleton = AppSkeleton();

Expand Down
3 changes: 1 addition & 2 deletions test/unit/env.test.js
Expand Up @@ -323,8 +323,7 @@ describe('Env.build()', function () {
androidJar: '/me/android-sdk/android.jar',
xwalkAndroidDir: '/me/xwalk_app_template',
xwalkRuntimeClientJar: '/me/xwalk_app_template/libs/runtime.jar',
androidAPILevel: 19,
embedded: false
androidAPILevel: 19
};

Env(envConfig, helpers)
Expand Down
10 changes: 1 addition & 9 deletions test/unit/locations.test.js
Expand Up @@ -19,8 +19,7 @@ var app = {
};

var env = {
arch: 'x86',
embedded: true
arch: 'x86'
};

var tmpdir = (os.tmpdir || os.tmpDir)();
Expand Down Expand Up @@ -50,13 +49,6 @@ describe('locations', function () {
};

expect(func2).to.throw(Error, /pkg/);

// missing embedded
var func3 = function () {
Locations({sanitisedName: 'boo', pkg: 'bar'}, {arch: 'x86'});
};

expect(func3).to.throw(Error, /embedded/);
});

it('should set destination paths when configured for an app', function () {
Expand Down

0 comments on commit ede415d

Please sign in to comment.