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

Commit

Permalink
Bug 968697 - Add Makefile for system app
Browse files Browse the repository at this point in the history
  • Loading branch information
cctuan committed Feb 11, 2014
1 parent 717fdb3 commit 43c5a19
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 36 deletions.
14 changes: 12 additions & 2 deletions apps/system/Makefile
@@ -1,3 +1,13 @@
.PHONY: remove-old-camera
remove-old-camera:
-include $(PWD)/build/common.mk

BUILD_DIR=$(PWD)/build_stage/system

.PHONY: all clean
all: clean
@echo Building system app to build_stage...
@mkdir -p $(BUILD_DIR)
@cp -r * $(BUILD_DIR)
@$(call run-app-js-command, build)
clean:
@rm -rf ./camera
@rm -rf $(BUILD_DIR)
87 changes: 87 additions & 0 deletions apps/system/build/build.js
@@ -0,0 +1,87 @@
'use strict';

/* global require, exports */
var utils = require('utils');

var SystemAppBuilder = function() {
};

SystemAppBuilder.prototype.APP_DIR = 'apps/system';
SystemAppBuilder.prototype.STAGE_DIR = 'build_stage/system';
// set options
SystemAppBuilder.prototype.setOptions = function(options) {
var stageDirPath = [options.GAIA_DIR].concat(this.STAGE_DIR.split('/'));
this.stageDir = utils.getFile.apply(utils, stageDirPath);

var appDirPath = [options.GAIA_DIR].concat(this.STAGE_DIR.split('/'));
this.appDir = utils.getFile.apply(utils, appDirPath);

this.distDirPath = options.GAIA_DISTRIBUTION_DIR;
};

SystemAppBuilder.prototype.addCustomizeFiles = function() {
if (!utils.getFile(this.distDirPath, 'power').exists()) {
return;
}
var self = this;
var fileDir = utils.getFile(this.distDirPath, 'power');
var files = utils.ls(fileDir);
files.forEach(function(file) {
utils.copyFileTo(file.path,
utils.joinPath(self.stageDir.path, 'resources', 'power'),
file.leafName, true);
});
};

SystemAppBuilder.prototype.initConfigJsons = function() {
var iccDefault = {
'defaultURL': 'http://www.mozilla.org/en-US/firefoxos/'
};
var wapuaprofDefault = {
};
var iccFile = utils.getFile(this.stageDir.path, 'js', 'icc.json');
var wapFile = utils.getFile(this.stageDir.path, 'js', 'wapuaprof.json');

utils.writeContent(iccFile,
utils.getDistributionFileContent('icc', iccDefault, this.distDirPath));

utils.writeContent(wapFile,
utils.getDistributionFileContent('wapuaprof',
wapuaprofDefault, this.distDirPath));

};

SystemAppBuilder.prototype.generateManifest = function() {
var manifest =
utils.getJSON(utils.getFile(this.appDir.path, 'manifest.webapp'));
manifest.activities = manifest.activities || {};

manifest.activities.view = {
filters: {
type: 'url',
url: {
required: true,
pattern: 'https?:.{1,16384}',
patternFlags: 'i'
}
}
};
// Write content to build_stage
utils.writeContent(utils.getFile(this.stageDir.path, 'manifest.webapp'),
JSON.stringify(manifest));
};

SystemAppBuilder.prototype.execute = function(options) {
this.setOptions(options);
this.initConfigJsons();
if (options.ROCKETBAR !== 'none') {
this.generateManifest();
}
if (this.distDirPath) {
this.addCustomizeFiles();
}
};

exports.execute = function(options) {
(new SystemAppBuilder()).execute(options);
};
3 changes: 3 additions & 0 deletions apps/system/gaia_build.json
@@ -0,0 +1,3 @@
{
"dir": "../../build_stage/system"
}
18 changes: 0 additions & 18 deletions build/applications-data.js
Expand Up @@ -329,24 +329,6 @@ function execute(options) {
utils.writeContent(init,
utils.getDistributionFileContent('support', content, distDir));

// ICC / STK
init = utils.getFile(config.GAIA_DIR,
'apps', 'system', 'resources', 'icc.json');
content = {
'defaultURL': 'http://www.mozilla.org/en-US/firefoxos/'
};

utils.writeContent(init,
utils.getDistributionFileContent('icc', content, distDir));

// WAP UA profile url
init = utils.getFile(config.GAIA_DIR,
'apps', 'system', 'resources', 'wapuaprof.json');
content = {};

utils.writeContent(init,
utils.getDistributionFileContent('wapuaprof.json', content, distDir));

// Communications config
init = utils.getFile(config.GAIA_DIR,
'apps', 'communications', 'contacts', 'config.json');
Expand Down
2 changes: 1 addition & 1 deletion build/multilocale.js
Expand Up @@ -3,7 +3,7 @@
const { Cc, Ci, Cr, Cu } = require('chrome');
Cu.import('resource://gre/modules/osfile.jsm');

const utils = require('./utils');
const utils = require('utils');
const webappZip = require('./webapp-zip');
const RE_SECTION_LINE = /\[(.*)\]/;
const RE_IMPORT_LINE = /@import url\((.*)\)/;
Expand Down
44 changes: 37 additions & 7 deletions build/test/integration/build.test.js
Expand Up @@ -338,19 +338,49 @@ suite('Build Integration tests', function() {
function(error, stdout, stderr) {
helper.checkError(error, stdout, stderr);

var hsZip = new AdmZip(path.join(process.cwd(), 'profile',
var hsBroZip = new AdmZip(path.join(process.cwd(), 'profile',
'webapps', 'browser.gaiamobile.org', 'application.zip'));
var hsSysZip = new AdmZip(path.join(process.cwd(), 'profile',
'webapps', 'system.gaiamobile.org', 'application.zip'));

var hsInit =
JSON.parse(hsZip.readAsText(hsZip.getEntry('js/init.json')));
var hsManifest =
JSON.parse(hsZip.readAsText(hsZip.getEntry('manifest.webapp')));
JSON.parse(hsBroZip.readAsText(hsBroZip.getEntry('js/init.json')));
var hsBroManifest =
JSON.parse(hsBroZip.readAsText(hsBroZip.getEntry('manifest.webapp')));
var defaultJSONPath =
path.join(process.cwd(), 'apps', 'browser', 'build', 'default.json');
var expectedInitJson = JSON.parse(fs.readFileSync(defaultJSONPath));
var hsIcc =
JSON.parse(hsSysZip.readAsText(hsSysZip.getEntry('js/icc.json')));
var hsWapuaprof =
JSON.parse(hsSysZip.readAsText(hsSysZip.getEntry('js/wapuaprof.json')));
var hsSysManifest =
JSON.parse(hsSysZip.readAsText(hsSysZip.getEntry('manifest.webapp')));

var expectedInitJson = JSON.parse(fs.readFileSync(defaultJSONPath));
var expectedIcc = {
'defaultURL': 'http://www.mozilla.org/en-US/firefoxos/'
};
var expectedWap = {};
var expectedManifest = {
activities: {
view: {
filters: {
type: 'url',
url: {
required: true,
pattern: 'https?:.{1,16384}',
patternFlags: 'i'
}
}
}
}
};
helper.checkSettings(hsInit, expectedInitJson);
assert.equal(hsManifest.role, 'system');
assert.equal(hsManifest.activities, null);
assert.equal(hsBroManifest.role, 'system');
assert.equal(hsBroManifest.activities, null);
helper.checkSettings(hsIcc, expectedIcc);
helper.checkSettings(hsWapuaprof, expectedWap);
helper.checkSettings(hsSysManifest, expectedManifest);
done();
}
);
Expand Down
23 changes: 23 additions & 0 deletions build/test/integration/distribution.test.js
Expand Up @@ -111,7 +111,29 @@ suite('Distribution mechanism', function() {
var presetsContent = broZip.readAsText(broZip.getEntry('js/init.json'));
assert.isNotNull(presetsContent, 'js/init.json should exist');
assert.deepEqual(JSON.parse(presetsContent), appConfig);
}

function validateSystem() {
var icc = path.join(distDir, 'icc.json');
var iccConfig = JSON.parse(fs.readFileSync(icc));
var wapuaprof = path.join(distDir, 'wapuaprof.json');
var wapuaprofConfig = JSON.parse(fs.readFileSync(wapuaprof));
var power = path.join(distDir, 'power', 'fakePowerFile.json');
var powerFile = JSON.parse(fs.readFileSync(power));
var sysZip = new AdmZip(path.join(process.cwd(), 'profile',
'webapps', 'system.gaiamobile.org', 'application.zip'));

var realIcc = sysZip.readAsText(sysZip.getEntry('js/icc.json'));
var realWap = sysZip.readAsText(sysZip.getEntry('js/wapuaprof.json'));
var realPower = sysZip.readAsText(sysZip.getEntry(
'resources/power/fakePowerFile.json'));

assert.isNotNull(realIcc, 'js/icc.json should exist');
assert.deepEqual(JSON.parse(realIcc), iccConfig);
assert.isNotNull(realWap, 'js/wapuaprof.json should exist');
assert.deepEqual(JSON.parse(realWap), wapuaprofConfig);
assert.isNotNull(realPower, 'resources/power/ should exist');
assert.deepEqual(JSON.parse(realPower), powerFile);
}

test('build with GAIA_DISTRIBUTION_DIR', function(done) {
Expand All @@ -125,6 +147,7 @@ suite('Distribution mechanism', function() {
validateCalendar();
validateWappush();
validateBrowser();
validateSystem();
done();
});
});
Expand Down
3 changes: 3 additions & 0 deletions build/test/resources/distribution_test/icc.json
@@ -0,0 +1,3 @@
{
"defaultURL": "testICClink"
}
@@ -0,0 +1,3 @@
{
"test": "test"
}
3 changes: 3 additions & 0 deletions build/test/resources/distribution_test/wapuaprof.json
@@ -0,0 +1,3 @@
{
"wapprof": "testprof"
}
2 changes: 0 additions & 2 deletions build/webapp-manifests.js
Expand Up @@ -200,8 +200,6 @@ function fillAppManifest(webapp) {

if (webapp.url.indexOf('communications.' + config.GAIA_DOMAIN) !== -1) {
fillCommsAppManifest(webapp, webappTargetDir);
} else if (config.ROCKETBAR !== 'none' && webapp.url.indexOf('system.' + config.GAIA_DOMAIN) !== -1) {
modifySystemForRocketbar(webapp, webappTargetDir);
}

manifestInterAppHostnames(webapp, webappTargetDir);
Expand Down
6 changes: 0 additions & 6 deletions build/webapp-zip.js
Expand Up @@ -366,12 +366,6 @@ function execute(options) {
}
});

if (webapp.sourceDirectoryName === 'system' && gaia.distributionDir) {
if (utils.getFile(gaia.distributionDir, 'power').exists()) {
customizeFiles(zip, 'power', 'resources/power/', webapp);
}
}

if (webapp.sourceDirectoryName === 'homescreen' && gaia.distributionDir) {
let customization = utils.getFile(gaia.distributionDir,
'temp', 'apps', 'conf', 'singlevariantconf.json');
Expand Down

0 comments on commit 43c5a19

Please sign in to comment.