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

Commit

Permalink
Merge pull request #11693 from yurenju/build-module
Browse files Browse the repository at this point in the history
bug 905096 - Build script modularization r=@timdream
  • Loading branch information
yurenju committed Aug 27, 2013
2 parents 81580eb + 103f5cd commit 4abecf9
Show file tree
Hide file tree
Showing 10 changed files with 1,000 additions and 809 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -68,3 +68,5 @@ manifest.appcache
/test_external_apps/*/test/unit/_sandbox.html
/test_external_apps/*/test/unit/_proxy.html
apps/*, external-apps/* & GAIA_DISTRIBUTION_DIR

/build/config.js
72 changes: 45 additions & 27 deletions Makefile
Expand Up @@ -160,8 +160,11 @@ ifneq (,$(findstring MINGW32_,$(SYS)))
CURDIR:=$(shell pwd -W | sed -e 's|/|\\\\|g')
SEP=\\
SEP_FOR_SED=\\\\
BUILDDIR := file:///$(shell pwd -W)/build/
# Mingw mangle path and append c:\mozilla-build\msys\data in front of paths
MSYS_FIX=/
else
BUILDDIR := file:///$(CURDIR)/build/
endif

ifndef GAIA_APP_CONFIG
Expand Down Expand Up @@ -276,6 +279,39 @@ MARIONETTE_HOST ?= localhost
MARIONETTE_PORT ?= 2828
TEST_DIRS ?= $(CURDIR)/tests


define BUILD_CONFIG
exports.config = {
"GAIA_DIR" : "$(CURDIR)",
"PROFILE_DIR" : "$(CURDIR)$(SEP)$(PROFILE_FOLDER)",
"PROFILE_FOLDER" : "$(PROFILE_FOLDER)",
"GAIA_SCHEME" : "$(SCHEME)",
"GAIA_DOMAIN" : "$(GAIA_DOMAIN)",
"DEBUG" : $(DEBUG),
"LOCAL_DOMAINS" : $(LOCAL_DOMAINS),
"DESKTOP" : $(DESKTOP),
"DEVICE_DEBUG" : $(DEVICE_DEBUG),
"HOMESCREEN" : "$(HOMESCREEN)",
"GAIA_PORT" : "$(GAIA_PORT)",
"GAIA_LOCALES_PATH" : "$(GAIA_LOCALES_PATH)",
"LOCALES_FILE" : "$(subst \,\\,$(LOCALES_FILE))",
"BUILD_APP_NAME" : "$(BUILD_APP_NAME)",
"PRODUCTION" : "$(PRODUCTION)",
"GAIA_OPTIMIZE" : "$(GAIA_OPTIMIZE)",
"GAIA_DEV_PIXELS_PER_PX" : "$(GAIA_DEV_PIXELS_PER_PX)",
"DOGFOOD" : "$(DOGFOOD)",
"OFFICIAL" : "$(MOZILLA_OFFICIAL)",
"GAIA_DEFAULT_LOCALE" : "$(GAIA_DEFAULT_LOCALE)",
"GAIA_INLINE_LOCALES" : "$(GAIA_INLINE_LOCALES)",
"GAIA_CONCAT_LOCALES" : "$(GAIA_CONCAT_LOCALES)",
"GAIA_ENGINE" : "xpcshell",
"GAIA_DISTRIBUTION_DIR" : "$(GAIA_DISTRIBUTION_DIR)",
"GAIA_APPDIRS" : "$(GAIA_APPDIRS)"
}

endef
export BUILD_CONFIG

# Generate profile/

$(PROFILE_FOLDER): multilocale applications-data preferences app-makefiles test-agent-config offline contacts extensions install-xulrunner-sdk install-git-hook $(PROFILE_FOLDER)/settings.json create-default-data $(PROFILE_FOLDER)/installed-extensions.json
Expand Down Expand Up @@ -441,8 +477,12 @@ XULRUNNERSDK=./$(XULRUNNER_DIRECTORY)/bin/run-mozilla.sh
XPCSHELLSDK=./$(XULRUNNER_DIRECTORY)/bin/xpcshell
endif

.PHONY: build-config-js
build-config-js:
echo "$$BUILD_CONFIG" > $(CURDIR)$(SEP)build$(SEP)config.js

.PHONY: install-xulrunner-sdk
install-xulrunner-sdk:
install-xulrunner-sdk: build-config-js
@echo "XULrunner directory: $(XULRUNNER_DIRECTORY)"
ifndef USE_LOCAL_XULRUNNER_SDK
ifneq ($(XULRUNNER_SDK_DOWNLOAD),$(shell cat $(XULRUNNER_URL_FILE) 2> /dev/null))
Expand All @@ -466,32 +506,10 @@ endif # XULRUNNER_SDK_DOWNLOAD
endif # USE_LOCAL_XULRUNNER_SDK

define run-js-command
echo "run-js-command $1"; \
JS_CONSTS=' \
const GAIA_DIR = "$(CURDIR)"; \
const PROFILE_DIR = "$(CURDIR)$(SEP)$(PROFILE_FOLDER)"; \
const PROFILE_FOLDER = "$(PROFILE_FOLDER)"; \
const GAIA_SCHEME = "$(SCHEME)"; const GAIA_DOMAIN = "$(GAIA_DOMAIN)"; \
const DEBUG = $(DEBUG); const LOCAL_DOMAINS = $(LOCAL_DOMAINS); \
const DESKTOP = $(DESKTOP); \
const DEVICE_DEBUG = $(DEVICE_DEBUG); \
const HOMESCREEN = "$(HOMESCREEN)"; const GAIA_PORT = "$(GAIA_PORT)"; \
const GAIA_LOCALES_PATH = "$(GAIA_LOCALES_PATH)"; \
const LOCALES_FILE = "$(subst \,\\,$(LOCALES_FILE))"; \
const BUILD_APP_NAME = "$(BUILD_APP_NAME)"; \
const PRODUCTION = "$(PRODUCTION)"; \
const GAIA_OPTIMIZE = "$(GAIA_OPTIMIZE)"; \
const GAIA_DEV_PIXELS_PER_PX = "$(GAIA_DEV_PIXELS_PER_PX)"; \
const DOGFOOD = "$(DOGFOOD)"; \
const OFFICIAL = "$(MOZILLA_OFFICIAL)"; \
const GAIA_DEFAULT_LOCALE = "$(GAIA_DEFAULT_LOCALE)"; \
const GAIA_INLINE_LOCALES = "$(GAIA_INLINE_LOCALES)"; \
const GAIA_CONCAT_LOCALES = "$(GAIA_CONCAT_LOCALES)"; \
const GAIA_ENGINE = "xpcshell"; \
const GAIA_DISTRIBUTION_DIR = "$(GAIA_DISTRIBUTION_DIR)"; \
const GAIA_APPDIRS = "$(GAIA_APPDIRS)"; \
'; \
$(XULRUNNERSDK) $(XPCSHELLSDK) -e "$$JS_CONSTS" -f build/utils.js "build/$(strip $1).js"
echo "run-js-command $1";
$(XULRUNNERSDK) $(XPCSHELLSDK) \
-e "const GAIA_BUILD_DIR='$(BUILDDIR)'" \
-f build/xpcshell-commonjs.js -e "require('$(strip $1)').execute()"
endef

# Optional files that may be provided to extend the set of default
Expand Down
596 changes: 320 additions & 276 deletions build/applications-data.js

Large diffs are not rendered by default.

41 changes: 24 additions & 17 deletions build/optimize-clean.js
@@ -1,28 +1,35 @@
var utils = require('./utils');
var config = require('./config').config;

function debug(str) {
//dump(' -*- l10n-clean.js: ' + str + '\n');
}

debug('Begin');
function execute() {
debug('Begin');

Gaia.webapps.forEach(function(webapp) {
// if BUILD_APP_NAME isn't `*`, we only accept one webapp
if (BUILD_APP_NAME != '*' && webapp.sourceDirectoryName != BUILD_APP_NAME)
return;
utils.Gaia.webapps.forEach(function(webapp) {
// if BUILD_APP_NAME isn't `*`, we only accept one webapp
if (config.BUILD_APP_NAME != '*' &&
webapp.sourceDirectoryName != config.BUILD_APP_NAME) {
return;
}

debug(webapp.sourceDirectoryName);
debug(webapp.sourceDirectoryName);

let re = new RegExp('\\.html\\.' + GAIA_DEFAULT_LOCALE + '$');
let files = ls(webapp.buildDirectoryFile, true);
files.forEach(function(file) {
if (
re.test(file.leafName) ||
file.leafName.indexOf(Gaia.aggregatePrefix) === 0
) {
file.remove(false);
}
let re = new RegExp('\\.html\\.' + config.GAIA_DEFAULT_LOCALE + '$');
let files = utils.ls(webapp.buildDirectoryFile, true);
files.forEach(function(file) {
if (
re.test(file.leafName) ||
file.leafName.indexOf(utils.Gaia.aggregatePrefix) === 0
) {
file.remove(false);
}
});
});
});

debug('End');
debug('End');
}

exports.execute = execute;

0 comments on commit 4abecf9

Please sign in to comment.