fix: restore missing .lproj directories (#15721)

the empty lproj directories help macOS to understand what locales the app supports
This commit is contained in:
Jeremy Apthorp 2018-11-15 09:30:45 -08:00 committed by GitHub
parent b53a858400
commit c8860d006b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 244 deletions

View file

@ -665,9 +665,40 @@ if (is_mac) {
]
}
action("electron_app_lproj_dirs") {
outputs = []
foreach(locale, locales_as_mac_outputs) {
outputs += [ "$target_gen_dir/app_infoplist_strings/$locale.lproj" ]
}
script = "build/mac/make_locale_dirs.py"
args = rebase_path(outputs)
}
foreach(locale, locales_as_mac_outputs) {
bundle_data("electron_app_strings_${locale}_bundle_data") {
sources = [
"$target_gen_dir/app_infoplist_strings/$locale.lproj",
]
outputs = [
"{{bundle_resources_dir}}/$locale.lproj",
]
public_deps = [
":electron_app_lproj_dirs",
]
}
}
group("electron_app_strings_bundle_data") {
public_deps = []
foreach(locale, locales_as_mac_outputs) {
public_deps += [ ":electron_app_strings_${locale}_bundle_data" ]
}
}
bundle_data("electron_app_resources") {
public_deps = [
":app2asar",
":electron_app_strings_bundle_data",
":js2asar",
]
sources = [

View file

@ -0,0 +1,20 @@
# usage: make_locale_dirs.py locale_dir [...]
#
# This script is intended to create empty locale directories (.lproj) in a
# Cocoa .app bundle. The presence of these empty directories is sufficient to
# convince Cocoa that the application supports the named localization, even if
# an InfoPlist.strings file is not provided. Chrome uses these empty locale
# directoires for its helper executable bundles, which do not otherwise
# require any direct Cocoa locale support.
import os
import sys
def main(args):
for dirname in args:
os.makedirs(dirname)
if __name__ == '__main__':
main(sys.argv[1:])

View file

@ -1,45 +0,0 @@
#!/usr/bin/env python
# Copyright (c) 2009 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.
# TODO: remove this script when GYP has for loops
import sys
import optparse
def main(argv):
parser = optparse.OptionParser()
usage = 'usage: %s [options ...] format_string locale_list'
parser.set_usage(usage.replace('%s', '%prog'))
parser.add_option('-d', dest='dash_to_underscore', action="store_true",
default=False,
help='map "en-US" to "en" and "-" to "_" in locales')
(options, arglist) = parser.parse_args(argv)
if len(arglist) < 3:
print 'ERROR: need string and list of locales'
return 1
str_template = arglist[1]
locales = arglist[2:]
results = []
for locale in locales:
# For Cocoa to find the locale at runtime, it needs to use '_' instead
# of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
# simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
if options.dash_to_underscore:
if locale == 'en-US':
locale = 'en'
locale = locale.replace('-', '_')
results.append(str_template.replace('ZZLOCALE', locale))
# Quote each element so filename spaces don't mess up GYP's attempt to parse
# it into a list.
print ' '.join(["'%s'" % x for x in results])
if __name__ == '__main__':
sys.exit(main(sys.argv))

View file

@ -1,56 +0,0 @@
#!/usr/bin/env python
# Copyright (c) 2013 GitHub, Inc.
# Use of this source code is governed by the MIT license that can be
# found in the LICENSE file.
import errno
import optparse
import os
import shutil
import sys
def main(argv):
parser = optparse.OptionParser()
usage = 'usage: %s [options ...] src dest locale_list'
parser.set_usage(usage.replace('%s', '%prog'))
parser.add_option('-d', dest='dash_to_underscore', action="store_true",
default=False,
help='map "en-US" to "en" and "-" to "_" in locales')
(options, arglist) = parser.parse_args(argv)
if len(arglist) < 4:
print 'ERROR: need src, dest and list of locales'
return 1
src = arglist[1]
dest = arglist[2]
locales = arglist[3:]
for locale in locales:
# For Cocoa to find the locale at runtime, it needs to use '_' instead
# of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
# simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
dirname = locale
if options.dash_to_underscore:
if locale == 'en-US':
dirname = 'en'
else:
dirname = locale.replace('-', '_')
dirname = os.path.join(dest, dirname + '.lproj')
safe_mkdir(dirname)
shutil.copy2(os.path.join(src, locale + '.pak'),
os.path.join(dirname, 'locale.pak'))
def safe_mkdir(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
raise
if __name__ == '__main__':
sys.exit(main(sys.argv))

View file

@ -1,11 +0,0 @@
#!/bin/sh
set -e
cd "${BUILT_PRODUCTS_DIR}/${1}.framework"
shift
while [ ! -z "${1}" ]; do
ln -sf Versions/Current/"${1}" "${1}"
shift
done

View file

@ -1,93 +0,0 @@
#!/usr/bin/env python
# Copyright (c) 2012 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.
"""Prints the lowest locally available SDK version greater than or equal to a
given minimum sdk version to standard output.
Usage:
python find_sdk.py 10.6 # Ignores SDKs < 10.6
"""
import os
import re
import subprocess
import sys
from optparse import OptionParser
def parse_version(version_str):
"""'10.6' => [10, 6]"""
return map(int, re.findall(r'(\d+)', version_str))
def main():
parser = OptionParser()
parser.add_option("--verify",
action="store_true", dest="verify", default=False,
help="return the sdk argument and warn if it doesn't exist")
parser.add_option("--sdk_path",
action="store", type="string", dest="sdk_path", default="",
help="user-specified SDK path; bypasses verification")
parser.add_option("--print_sdk_path",
action="store_true", dest="print_sdk_path", default=False,
help="Additionaly print the path the SDK (appears first).")
options, args = parser.parse_args()
if len(args) != 1:
parser.error('Please specify a minimum SDK version')
min_sdk_version = args[0]
job = subprocess.Popen(['xcode-select', '-print-path'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
out, err = job.communicate()
if job.returncode != 0:
print >> sys.stderr, out
print >> sys.stderr, err
raise Exception(('Error %d running xcode-select, you might have to run '
'|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
'if you are using Xcode 4.') % job.returncode)
# The Developer folder moved in Xcode 4.3.
xcode43_sdk_path = os.path.join(
out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs')
if os.path.isdir(xcode43_sdk_path):
sdk_dir = xcode43_sdk_path
else:
sdk_dir = os.path.join(out.rstrip(), 'SDKs')
sdks = [re.findall('^MacOSX(10\.\d+)\.sdk$', s) for s in os.listdir(sdk_dir)]
sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6']
sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6']
if parse_version(s) >= parse_version(min_sdk_version)]
if not sdks:
raise Exception('No %s+ SDK found' % min_sdk_version)
best_sdk = sorted(sdks, key=parse_version)[0]
if options.verify and best_sdk != min_sdk_version and not options.sdk_path:
print >> sys.stderr, ''
print >> sys.stderr, ' vvvvvvv'
print >> sys.stderr, ''
print >> sys.stderr, \
'This build requires the %s SDK, but it was not found on your system.' \
% min_sdk_version
print >> sys.stderr, \
'Either install it, or explicitly set mac_sdk in your GYP_DEFINES.'
print >> sys.stderr, ''
print >> sys.stderr, ' ^^^^^^^'
print >> sys.stderr, ''
return min_sdk_version
if options.print_sdk_path:
print subprocess.check_output(['xcodebuild', '-version', '-sdk',
'macosx' + best_sdk, 'Path']).strip()
return best_sdk
if __name__ == '__main__':
if sys.platform != 'darwin':
raise Exception("This script only runs on Mac")
print main()
sys.exit(0)

View file

@ -1,39 +0,0 @@
#!/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_dirs.sh locale_dir [...]
#
# This script creates the Resources directory for the bundle being built by
# the Xcode target that calls it if the directory does not yet exist. It then
# changes to that directory and creates subdirectories for each locale_dir
# passed on the command line.
#
# This script is intended to create empty locale directories (.lproj) in a
# Cocoa .app bundle. The presence of these empty directories is sufficient to
# convince Cocoa that the application supports the named localization, even if
# an InfoPlist.strings file is not provided. Chrome uses these empty locale
# directoires for its helper executable bundles, which do not otherwise
# require any direct Cocoa locale support.
set -eu
if [[ ${#} -eq 0 ]]; then
echo "usage: ${0} locale_dir [...]" >& 2
exit 1
fi
RESOURCES_DIR="${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
if [[ ! -d "${RESOURCES_DIR}" ]]; then
mkdir "${RESOURCES_DIR}"
fi
cd "${RESOURCES_DIR}"
for dir in "${@}"; do
if [[ ! -d "${dir}" ]]; then
mkdir "${dir}"
fi
done