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 #18406 from cctuan/968661-4
Browse files Browse the repository at this point in the history
Bug 968661 - Extract new build module webapp-shared.js from webapp-zip.j...
  • Loading branch information
cctuan committed Apr 21, 2014
2 parents eb97461 + da94a3e commit 6b7a10e
Show file tree
Hide file tree
Showing 20 changed files with 1,162 additions and 338 deletions.
19 changes: 17 additions & 2 deletions Makefile
Expand Up @@ -497,7 +497,7 @@ $(STAGE_DIR):
# FIXME: we use |STAGE_APP_DIR="../../build_stage/$$APP"| here because we got
# some problem on Windows if use absolute path.
.PHONY: app-makefiles
app-makefiles: $(XULRUNNER_BASE_DIRECTORY) keyboard-layouts webapp-manifests svoperapps | $(STAGE_DIR)
app-makefiles: $(XULRUNNER_BASE_DIRECTORY) keyboard-layouts webapp-manifests svoperapps clear-stage-app webapp-shared | $(STAGE_DIR)
@for appdir in $(GAIA_APPDIRS); \
do \
APP="`basename $$appdir`"; \
Expand All @@ -507,7 +507,6 @@ app-makefiles: $(XULRUNNER_BASE_DIRECTORY) keyboard-layouts webapp-manifests svo
STAGE_APP_DIR="../../build_stage/$$APP" make -C "$$appdir" ; \
else \
echo "copy $$APP to build_stage/" ; \
rm -rf "$(STAGE_DIR)/$$APP" && \
cp -r "$$appdir" $(STAGE_DIR) && \
if [ -r "$$appdir/build/build.js" ]; then \
echo "execute $$APP/build/build.js"; \
Expand All @@ -519,6 +518,17 @@ app-makefiles: $(XULRUNNER_BASE_DIRECTORY) keyboard-layouts webapp-manifests svo
fi; \
done

.PHONY: clear-stage-app
clear-stage-app:
@for appdir in $(GAIA_APPDIRS); \
do \
if [[ ("$$appdir" =~ "${BUILD_APP_NAME}") || ("${BUILD_APP_NAME}" == "*") ]]; then \
APP="`basename $$appdir`"; \
echo "clear $$APP in build_stage" ; \
rm -rf "$(STAGE_DIR)/$$APP/*"; \
fi; \
done

svoperapps: $(XULRUNNER_BASE_DIRECTORY)
@$(call run-js-command,svoperapps)

Expand All @@ -545,6 +555,11 @@ ifneq ($(DEBUG),1)
@$(call run-js-command,webapp-zip)
endif

.PHONY: webapp-shared
# Copy shared files to stage folders
webapp-shared: $(XULRUNNER_BASE_DIRECTORY) keyboard-layouts $(STAGE_DIR) clear-stage-app
@$(call run-js-command, webapp-shared)

.PHONY: webapp-optimize
# Web app optimization steps (like precompling l10n, concatenating js files, etc..).
# You need xulrunner ($(XULRUNNER_BASE_DIRECTORY)) to do this, and you need the app
Expand Down
3 changes: 1 addition & 2 deletions apps/calendar/Makefile
Expand Up @@ -3,8 +3,7 @@
.PHONY: $(STAGE_APP_DIR)

$(STAGE_APP_DIR):
rm -rf $(STAGE_APP_DIR)
cp -r "$(CURDIR)" "$(STAGE_APP_DIR)"
cp -r "$(CURDIR)" "$(STAGE_DIR)"
@$(call run-js-command,app/build)

.PHONY: web_assets
Expand Down
3 changes: 0 additions & 3 deletions apps/camera/Makefile
Expand Up @@ -16,8 +16,5 @@ $(STAGE_APP_DIR):

$(STAGE_APP_DIR)/js/main.js: | $(STAGE_APP_DIR)
@$(call run-js-command,app/build)
rm -rf $(STAGE_APP_DIR)/shared
rm -rf $(STAGE_APP_DIR)/style
cp -rp ../../shared $(STAGE_APP_DIR)/
$(XULRUNNERSDK) $(XPCSHELLSDK) ../../build/r.js -o build/require_config.jslike

3 changes: 3 additions & 0 deletions apps/camera/index.html
Expand Up @@ -25,6 +25,9 @@
<!-- <script defer src="/shared/js/media/media_frame.js"></script> -->
<!-- <script defer src="/shared/js/gesture_detector.js"></script> -->
<!-- <script defer src="/shared/js/lazy_loader.js"></script> -->
<!-- <script defer src="/shared/js/blobview.js"></script> -->
<!-- <script defer src="/shared/js/custom_dialog.js"></script> -->
<!-- <script defer src="/shared/js/format.js"></script> -->

<link rel="stylesheet" type="text/css" href="style/main.css" />
</head>
Expand Down
6 changes: 4 additions & 2 deletions apps/clock/Makefile
Expand Up @@ -11,8 +11,10 @@ endif
all: $(STAGE_APP_DIR)/js/startup.js

$(STAGE_APP_DIR)/js/startup.js:
@rm -rf $(STAGE_APP_DIR)
@mkdir -p $(STAGE_APP_DIR)
cp -rp ../../shared $(STAGE_APP_DIR)/shared
$(XULRUNNERSDK) $(XPCSHELLSDK) ../../build/r.js -o build/require_config.jslike
$(XULRUNNERSDK) $(XPCSHELLSDK) build/make_gaia_shared.js
@rm -rf $(BUILD_DIR)/shared

clean:
@rm -rf $(STAGE_APP_DIR)
12 changes: 12 additions & 0 deletions apps/clock/index.html
Expand Up @@ -24,6 +24,18 @@
<link rel="stylesheet" type="text/css" href="shared/style/switches.css" >
-->

<!--
The following scripts are lazy loaded but left here to ensure
they get copied over from shared during the build
-->
<!-- <script defer src="/shared/js/performance_testing_helper.js"></script> -->
<!-- <script defer src="/shared/js/l10n.js"></script> -->
<!-- <script defer src="/shared/js/l10n_date.js"></script> -->
<!-- <script defer src="/shared/js/async_storage.js"></script> -->
<!-- <script defer src="/shared/js/gesture_detector.js"></script> -->
<!-- <script defer src="/shared/js/accessibility_helper.js"></script> -->
<!-- <script defer src="/shared/js/template.js"></script> -->

<!-- Shared sounds -->
<link rel="resources" type="directory" href="shared/resources/media/alarms/">

Expand Down
7 changes: 2 additions & 5 deletions apps/email/Makefile
Expand Up @@ -14,19 +14,15 @@ else
GAIA_EMAIL_MINIFY?=none
endif

.PHONY: all clean $(STAGE_APP_DIR)/js/mail_app.js
.PHONY: all $(STAGE_APP_DIR)/js/mail_app.js

all: $(STAGE_APP_DIR)/js/mail_app.js
clean:
rm -rf $(STAGE_APP_DIR)

$(STAGE_APP_DIR)/js/mail_app.js:
@rm -rf $(STAGE_APP_DIR)
mkdir -p $(STAGE_APP_DIR)/shared

cp -rp ../../shared/js $(STAGE_APP_DIR)/shared
cp -rp ../../shared/style $(STAGE_APP_DIR)/shared

$(XULRUNNERSDK) $(XPCSHELLSDK) ../../build/r.js -o build/email.build.js optimize=$(GAIA_EMAIL_MINIFY)
@rm -rf $(STAGE_APP_DIR)/build
@rm $(STAGE_APP_DIR)/build.txt
Expand All @@ -35,3 +31,4 @@ $(STAGE_APP_DIR)/js/mail_app.js:
@rm $(STAGE_APP_DIR)/README.md
@rm -rf $(STAGE_APP_DIR)/test
$(XULRUNNERSDK) $(XPCSHELLSDK) build/make_gaia_shared.js
@rm -rf $(BUILD_DIR)/shared
24 changes: 24 additions & 0 deletions apps/email/index.html
Expand Up @@ -8,6 +8,30 @@
<!-- Localization -->
<link rel="resource" type="application/l10n" href="locales/locales.ini">
<link rel="resource" type="application/l10n" href="shared/locales/date.ini">


<!-- These are lazy loaded. Need to be included here so the build picks them up
<link rel="stylesheet" type="text/css" href="shared/style/input_areas.css" >
<link rel="stylesheet" type="text/css" href="shared/style/headers.css" >
<link rel="stylesheet" type="text/css" href="shared/style/switches.css" >
<link rel="stylesheet" type="text/css" href="shared/style/buttons.css" >
<link rel="stylesheet" type="text/css" href="shared/style/status.css" >
<link rel="stylesheet" type="text/css" href="shared/style/confirm.css" >
<link rel="stylesheet" type="text/css" href="shared/style/action_menu.css" >
<link rel="stylesheet" type="text/css" href="shared/style/progress_activity.css" >
<link rel="stylesheet" type="text/css" href="shared/style/tabs.css" >
-->

<!--
The following scripts are lazy loaded but left here to ensure
they get copied over from shared during the build
-->
<!-- <script defer src="/shared/js/l10n.js"></script> -->
<!-- <script defer src="/shared/js/l10n_date.js"></script> -->
<!-- <script defer src="/shared/js/mime_mapper.js"></script> -->
<!-- <script defer src="/shared/js/gesture_detector.js"></script> -->
<!-- <script defer src="/shared/js/notification_helper.js"></script> -->
<!-- <script defer src="/shared/js/accessibility_helper.js"></script> -->
</head>

<body role="application">
Expand Down
4 changes: 2 additions & 2 deletions apps/findmydevice/Makefile
@@ -1,7 +1,7 @@
include $(PWD)/build/common.mk

.PHONY: all clean
all: clean
.PHONY: all
all:
@echo Building findmydevice app to build_stage...
@mkdir -p $(STAGE_APP_DIR)
@cp -r * $(STAGE_APP_DIR)
Expand Down
4 changes: 2 additions & 2 deletions apps/keyboard/Makefile
@@ -1,8 +1,8 @@
-include $(PWD)/build/common.mk


.PHONY: all clean
all: clean
.PHONY: all
all:
@echo Building keyboard app to build_stage...
@$(call run-js-command,app/build)
clean:
Expand Down
5 changes: 2 additions & 3 deletions apps/settings/Makefile
Expand Up @@ -14,7 +14,7 @@ else
GAIA_SETTINGS_MINIFY?=none
endif

.PHONY: all clean $(STAGE_APP_DIR)/resources/gaia_commit.txt $(STAGE_APP_DIR)/resources/support.json $(STAGE_APP_DIR)/resources/sensors.json $(STAGE_APP_DIR)/js/main.js
.PHONY: all $(STAGE_APP_DIR)/resources/gaia_commit.txt $(STAGE_APP_DIR)/resources/support.json $(STAGE_APP_DIR)/resources/sensors.json $(STAGE_APP_DIR)/js/main.js

all: $(STAGE_APP_DIR)/resources/gaia_commit.txt $(STAGE_APP_DIR)/resources/support.json $(STAGE_APP_DIR)/resources/sensors.json $(STAGE_APP_DIR)/js/main.js

Expand All @@ -33,11 +33,10 @@ else
date +%s >> $(STAGE_APP_DIR)/resources/gaia_commit.txt;
endif

$(STAGE_APP_DIR): clean
$(STAGE_APP_DIR):
mkdir -p $(STAGE_APP_DIR)

$(STAGE_APP_DIR)/js/main.js: | $(STAGE_APP_DIR)
cp -rp ../../shared $(STAGE_APP_DIR)/shared
$(XULRUNNERSDK) $(XPCSHELLSDK) ../../build/r.js -o build/settings.build.jslike optimize=$(GAIA_SETTINGS_MINIFY)

$(STAGE_APP_DIR)/resources/support.json $(STAGE_APP_DIR)/resources/sensors.json: build/build.js $(STAGE_APP_DIR)
Expand Down
36 changes: 33 additions & 3 deletions build/multilocale.js
Expand Up @@ -126,7 +126,7 @@ function L10nManager(gaiaDir, sharedDir, localesFilePath, localeBasedir) {
zip.removeEntry(IniPathInZip, false);
}

webappZip.addEntryStringWithTime(zip, IniPathInZip, iniContent,
utils.addEntryContentWithTime(zip, IniPathInZip, iniContent,
DEFAULT_TIME, compression);

localesClone.forEach(function(locale) {
Expand All @@ -141,12 +141,41 @@ function L10nManager(gaiaDir, sharedDir, localesFilePath, localeBasedir) {
if (zip.hasEntry(propsFilePathInZip)) {
zip.removeEntry(propsFilePathInZip, false);
}
webappZip.addEntryFileWithTime(zip, propsFilePathInZip, propFile,
utils.addEntryContentWithTime(zip, propsFilePathInZip, propFile,
DEFAULT_TIME, compression);
});
});
}

function localizeIniShared(target, iniFile, webapp, callback) {
var localesClone = JSON.parse(JSON.stringify(self.locales));
var enIndex = localesClone.indexOf('en-US');
if (enIndex !== -1) {
localesClone.splice(enIndex, 1);
}

var origin = utils.getFileContent(iniFile);
var ini = modifyLocaleIni(origin, localesClone);
var iniContent = serializeIni(ini);
var targetIni = utils.getFile(webapp.sourceDirectoryFile.path,
target);
utils.writeContent(targetIni, iniContent);

localesClone.forEach(function(locale) {
ini[locale].forEach(function(path) {
var origin = utils.getFile(iniFile.parent.path, path);
var propFile = getPropertiesFile(webapp, origin.path);
if (!propFile.exists()) {
utils.log(MODNAME, 'Properties file not found: ' + propFile.path);
return;
}
var propsFilePathInZip = getPropertiesPathInZip(origin.path, webapp);
log(propFile.path);
log(propsFilePathInZip);
callback(propFile, propsFilePathInZip);
});
});
}
/**
* For a given properties file from gaia repo, returns the matching properties
* file from multilocale repos being hosted in LOCALE_BASEDIR
Expand Down Expand Up @@ -236,7 +265,7 @@ function L10nManager(gaiaDir, sharedDir, localesFilePath, localeBasedir) {
if (zip.hasEntry('manifest.webapp')) {
zip.removeEntry('manifest.webapp', false);
}
webappZip.addEntryStringWithTime(zip, 'manifest.webapp',
utils.addEntryContentWithTime(zip, 'manifest.webapp',
JSON.stringify(manifest, undefined, 2));

// Ignore l10n files if they have been inlined or concatenated
Expand Down Expand Up @@ -410,6 +439,7 @@ function L10nManager(gaiaDir, sharedDir, localesFilePath, localeBasedir) {
this.localize = localize;
this.localizeManifest = localizeManifest;
this.serializeIni = serializeIni;
this.localizeIniShared = localizeIniShared;
}

exports.L10nManager = L10nManager;

0 comments on commit 6b7a10e

Please sign in to comment.