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 #15035 from timdream/keyboard-remove-ime
Browse files Browse the repository at this point in the history
Bug 956659 - Only include IMEs for selected layouts in the build, r=yurenju, djf
  • Loading branch information
timdream committed Jan 9, 2014
2 parents 48797fe + 57bd13c commit 6c2dac3
Show file tree
Hide file tree
Showing 38 changed files with 34 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Expand Up @@ -72,6 +72,3 @@ manifest.appcache
/test_external_apps/*/test/unit/_sandbox.html
/test_external_apps/*/test/unit/_proxy.html
apps/*, external-apps/* & GAIA_DISTRIBUTION_DIR

/apps/keyboard/js/imes/latin/dictionaries/*.dict
/apps/keyboard/js/layouts/*.js
4 changes: 4 additions & 0 deletions apps/keyboard/.gitignore
@@ -0,0 +1,4 @@
/js/imes
/js/imes/\!latin
/js/imes/latin/dictionaries/*.dict
/js/layouts/*.js
2 changes: 1 addition & 1 deletion build/applications-data.js
Expand Up @@ -537,7 +537,7 @@ function execute(options) {

// Configure the system keyboard app by copying the keyboard layouts and
// autocorrect dictionary files we need into the app directory.
require('keyboard-config').copyLayoutsAndDictionaries(config);
require('keyboard-config').copyLayoutsAndResources(config);
}

exports.execute = execute;
Expand Down
36 changes: 29 additions & 7 deletions build/keyboard-config.js
Expand Up @@ -2,10 +2,10 @@ let utils = require('./utils');
const { Cc, Ci, Cr, Cu, CC } = require('chrome');
Cu.import('resource://gre/modules/Services.jsm');

exports.copyLayoutsAndDictionaries = copyLayoutsAndDictionaries;
exports.copyLayoutsAndResources = copyLayoutsAndResources;
exports.addEntryPointsToManifest = addEntryPointsToManifest;

function copyLayoutsAndDictionaries(config) {
function copyLayoutsAndResources(config) {
// This is the source dir for the keyboard app
let appDir = utils.getFile(config.GAIA_DIR, 'apps', 'keyboard');

Expand All @@ -14,12 +14,18 @@ function copyLayoutsAndDictionaries(config) {
let dictDest = utils.getFile(appDir.path,
'js', 'imes', 'latin', 'dictionaries');

let imeDest = utils.getFile(appDir.path, 'js', 'imes');

// First delete any layouts or dictionaries that are in the src dir
// from the last time.
utils.ensureFolderExists(layoutDest);
utils.ensureFolderExists(dictDest);
utils.ls(layoutDest, false).forEach(function(f) { f.remove(false); });
utils.ls(dictDest).forEach(function(f) { f.remove(false); });
utils.ls(imeDest).forEach(function(f) {
if (f.leafName !== 'latin')
f.remove(true);
});

// Now get the set of layouts for this build
let layouts = getLayouts(config);
Expand All @@ -30,11 +36,21 @@ function copyLayoutsAndDictionaries(config) {
layout.file.copyTo(layoutDest, layout.file.leafName);

try {
if (layout.dictfile)
layout.dictfile.copyTo(dictDest, layout.dictfile.leafName);
if (layout.imEngineDir)
layout.imEngineDir.copyTo(imeDest, layout.imEngineDir.leafName);
}
catch(e) {
throw new Error('Unknown ime directory ' + layout.imEngineDir.path +
' for keyboard layout ' + layout.name);

}

try {
if (layout.dictFile)
layout.dictFile.copyTo(dictDest, layout.dictFile.leafName);
}
catch(e) {
throw new Error('Unknown dictionary file ' + layout.dictfile.path +
throw new Error('Unknown dictionary file ' + layout.dictFile.path +
' for keyboard layout ' + layout.name);

}
Expand Down Expand Up @@ -70,6 +86,7 @@ function getLayouts(config) {
// Here is where the layouts and dictionaries come from
let layoutSrc = utils.getFile(config.GAIA_DIR, 'keyboard', 'layouts');
let dictSrc = utils.getFile(config.GAIA_DIR, 'keyboard', 'dictionaries');
let imeSrc = utils.getFile(config.GAIA_DIR, 'keyboard', 'imes');

// Read the layout files and find their names and dictionaries,
// and copy them into the app package
Expand All @@ -85,7 +102,7 @@ function getLayouts(config) {
}
catch(e) {
// keep the original Error with its stack, just annotate which
// keyboard failed.
// keyboard failed.
e.message = 'Problem with keyboard layout "' + layoutName +
'" in GAIA_KEYBOARD_LAYOUTS\n' + e.message;
throw e;
Expand All @@ -111,13 +128,18 @@ function getLayouts(config) {
let dictFile = dictName
? utils.getFile(dictSrc.path, dictName + '.dict')
: null;
let imEngineName = win.Keyboards[layoutName].imEngine;
let imEngineDir = (imEngineName && imEngineName !== 'latin')
? utils.getFile(imeSrc.path, imEngineName)
: null;

return {
name: layoutName,
label: win.Keyboards[layoutName].menuLabel,
file: layoutFile,
types: win.Keyboards[layoutName].types,
dictfile: dictFile
dictFile: dictFile,
imEngineDir: imEngineDir
};
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 6c2dac3

Please sign in to comment.