From 16bc7f10c165160632ad2e5c300eb773edbabdfa Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 29 May 2014 19:08:59 +0800 Subject: [PATCH] Generate .pak for each locale. --- atom.gyp | 32 ++++++++++++++++++++++++++++++-- script/create-dist.py | 2 ++ tools/posix/make_locale_paks.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100755 tools/posix/make_locale_paks.sh diff --git a/atom.gyp b/atom.gyp index 211e0347f2..3c95bf0904 100644 --- a/atom.gyp +++ b/atom.gyp @@ -344,7 +344,11 @@ ], }, ] - }], # OS=="mac" + }, { # OS=="mac" + 'dependencies': [ + 'make_locale_paks', + ], + }], # OS!="mac" ['OS=="win"', { 'copies': [ { @@ -700,7 +704,31 @@ }, }, # target helper ], - }], # OS==Mac + }, { # OS=="mac" + 'targets': [ + { + 'target_name': 'make_locale_paks', + 'type': 'none', + 'actions': [ + { + 'action_name': 'Make Empty Paks', + 'inputs': [ + 'tools/posix/make_locale_paks.sh', + ], + 'outputs': [ + '<(PRODUCT_DIR)/locales' + ], + 'action': [ + 'tools/posix/make_locale_paks.sh', + '<(PRODUCT_DIR)', + '<@(locales)', + ], + 'msvs_cygwin_shell': 0, + }, + ], + }, + ], + }], # OS!="mac" ['OS=="win"', { 'targets': [ { diff --git a/script/create-dist.py b/script/create-dist.py index 3354b65cc2..ba9b0f5264 100755 --- a/script/create-dist.py +++ b/script/create-dist.py @@ -62,9 +62,11 @@ TARGET_DIRECTORIES = { ], 'win32': [ 'resources', + 'locales', ], 'linux': [ 'resources', + 'locales', ], } diff --git a/tools/posix/make_locale_paks.sh b/tools/posix/make_locale_paks.sh new file mode 100755 index 0000000000..6f66a04e86 --- /dev/null +++ b/tools/posix/make_locale_paks.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# usage: make_locale_paks locale_dir [...] +# +# This script creates the .pak files under locales directory, it is used to fool +# the ResourcesBundle that the locale is available. + +set -eu + +if [[ ${#} -eq 0 ]]; then + echo "usage: ${0} build_dir [locale_pak...]" >& 2 + exit 1 +fi + +PRODUCT_DIR="$1" +shift + +LOCALES_DIR="${PRODUCT_DIR}/locales" +if [[ ! -d "${LOCALES_DIR}" ]]; then + mkdir "${LOCALES_DIR}" +fi + +cd "${LOCALES_DIR}" + +for pak in "${@}"; do + if [[ ! -f "${pak}.pak" ]]; then + touch "${pak}.pak" + fi +done