Commit adf34911 authored by rsesek's avatar rsesek Committed by Commit bot

Rework build/mac/tweak_info_plist.py to not rely on environment variables.

Instead, pass the --plist to tweak on the command line. This way the
script can be used in both GYP and GN builds.

There is one behavior change: previously passing --keystone=1 would only
insert the Keystone keys if env['CONFIGURATION']=='Release' and after this
change, the keys will be added regardless of the build configuration if the
flag is passed.

BUG=297668

Review URL: https://codereview.chromium.org/1881053002

Cr-Commit-Position: refs/heads/master@{#386854}
parent 605a240f
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
import optparse import optparse
import os import os
from os import environ as env
import plistlib import plistlib
import re import re
import subprocess import subprocess
...@@ -202,6 +201,8 @@ def _RemoveKeystoneKeys(plist): ...@@ -202,6 +201,8 @@ def _RemoveKeystoneKeys(plist):
def Main(argv): def Main(argv):
parser = optparse.OptionParser('%prog [options]') parser = optparse.OptionParser('%prog [options]')
parser.add_option('--plist', dest='plist_path', action='store',
type='string', default=None, help='The path of the plist to tweak.')
parser.add_option('--breakpad', dest='use_breakpad', action='store', parser.add_option('--breakpad', dest='use_breakpad', action='store',
type='int', default=False, help='Enable Breakpad [1 or 0]') type='int', default=False, help='Enable Breakpad [1 or 0]')
parser.add_option('--breakpad_uploads', dest='breakpad_uploads', parser.add_option('--breakpad_uploads', dest='breakpad_uploads',
...@@ -224,9 +225,12 @@ def Main(argv): ...@@ -224,9 +225,12 @@ def Main(argv):
print >>sys.stderr, parser.get_usage() print >>sys.stderr, parser.get_usage()
return 1 return 1
if not options.plist_path:
print >>sys.stderr, 'No --plist specified.'
return 1
# Read the plist into its parsed format. # Read the plist into its parsed format.
DEST_INFO_PLIST = os.path.join(env['TARGET_BUILD_DIR'], env['INFOPLIST_PATH']) plist = plistlib.readPlist(options.plist_path)
plist = plistlib.readPlist(DEST_INFO_PLIST)
# Insert the product version. # Insert the product version.
if not _AddVersionKeys(plist, version=options.version): if not _AddVersionKeys(plist, version=options.version):
...@@ -251,8 +255,8 @@ def Main(argv): ...@@ -251,8 +255,8 @@ def Main(argv):
else: else:
_RemoveBreakpadKeys(plist) _RemoveBreakpadKeys(plist)
# Only add Keystone in Release builds. # Add Keystone if configured to do so.
if options.use_keystone and env['CONFIGURATION'] == 'Release': if options.use_keystone:
if options.bundle_identifier is None: if options.bundle_identifier is None:
print >>sys.stderr, 'Use of Keystone requires the bundle id.' print >>sys.stderr, 'Use of Keystone requires the bundle id.'
return 1 return 1
...@@ -270,7 +274,8 @@ def Main(argv): ...@@ -270,7 +274,8 @@ def Main(argv):
# Info.plist will work perfectly well in any plist format, but traditionally # Info.plist will work perfectly well in any plist format, but traditionally
# applications use xml1 for this, so convert it to ensure that it's valid. # applications use xml1 for this, so convert it to ensure that it's valid.
proc = subprocess.Popen(['plutil', '-convert', 'xml1', '-o', DEST_INFO_PLIST, proc = subprocess.Popen(['plutil', '-convert', 'xml1',
'-o', options.plist_path,
temp_info_plist.name]) temp_info_plist.name])
proc.wait() proc.wait()
return proc.returncode return proc.returncode
......
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
# never placed into the app mode loader. # never placed into the app mode loader.
'postbuild_name': 'Tweak Info.plist', 'postbuild_name': 'Tweak Info.plist',
'action': ['<(tweak_info_plist_path)', 'action': ['<(tweak_info_plist_path)',
'--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--breakpad=0', '--breakpad=0',
'--keystone=0', '--keystone=0',
'--scm=0'], '--scm=0'],
......
...@@ -228,6 +228,7 @@ ...@@ -228,6 +228,7 @@
# never placed into the helper. # never placed into the helper.
'postbuild_name': 'Tweak Info.plist', 'postbuild_name': 'Tweak Info.plist',
'action': ['<(tweak_info_plist_path)', 'action': ['<(tweak_info_plist_path)',
'--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--breakpad=0', '--breakpad=0',
'--keystone=0', '--keystone=0',
'--scm=0'], '--scm=0'],
......
...@@ -114,6 +114,7 @@ ...@@ -114,6 +114,7 @@
# but this seems like a really good place to store them. # but this seems like a really good place to store them.
'postbuild_name': 'Tweak Info.plist', 'postbuild_name': 'Tweak Info.plist',
'action': ['<(tweak_info_plist_path)', 'action': ['<(tweak_info_plist_path)',
'--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--breakpad=<(mac_breakpad_compiled_in)', '--breakpad=<(mac_breakpad_compiled_in)',
'--breakpad_uploads=<(mac_breakpad_uploads)', '--breakpad_uploads=<(mac_breakpad_uploads)',
'--keystone=0', '--keystone=0',
......
...@@ -341,6 +341,7 @@ ...@@ -341,6 +341,7 @@
# include SCM information. # include SCM information.
'postbuild_name': 'Tweak Info.plist', 'postbuild_name': 'Tweak Info.plist',
'action': ['<(tweak_info_plist_path)', 'action': ['<(tweak_info_plist_path)',
'--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--breakpad=0', '--breakpad=0',
'--keystone=<(mac_keystone)', '--keystone=<(mac_keystone)',
'--scm=1', '--scm=1',
......
...@@ -524,6 +524,7 @@ ...@@ -524,6 +524,7 @@
# Modify the Info.plist as needed. # Modify the Info.plist as needed.
'postbuild_name': 'Tweak Info.plist', 'postbuild_name': 'Tweak Info.plist',
'action': ['../build/mac/tweak_info_plist.py', 'action': ['../build/mac/tweak_info_plist.py',
'--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--scm=1', '--scm=1',
'--version=<(content_shell_version)'], '--version=<(content_shell_version)'],
}, },
...@@ -619,6 +620,7 @@ ...@@ -619,6 +620,7 @@
# but this seems like a really good place to store them. # but this seems like a really good place to store them.
'postbuild_name': 'Tweak Info.plist', 'postbuild_name': 'Tweak Info.plist',
'action': ['../build/mac/tweak_info_plist.py', 'action': ['../build/mac/tweak_info_plist.py',
'--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--breakpad=1', '--breakpad=1',
'--keystone=0', '--keystone=0',
'--scm=1', '--scm=1',
...@@ -709,6 +711,7 @@ ...@@ -709,6 +711,7 @@
# never placed into the helper. # never placed into the helper.
'postbuild_name': 'Tweak Info.plist', 'postbuild_name': 'Tweak Info.plist',
'action': ['../build/mac/tweak_info_plist.py', 'action': ['../build/mac/tweak_info_plist.py',
'--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--breakpad=0', '--breakpad=0',
'--keystone=0', '--keystone=0',
'--scm=0', '--scm=0',
......
...@@ -172,6 +172,7 @@ ...@@ -172,6 +172,7 @@
# Modify the Info.plist as needed. # Modify the Info.plist as needed.
'postbuild_name': 'Tweak Info.plist', 'postbuild_name': 'Tweak Info.plist',
'action': ['../../build/mac/tweak_info_plist.py', 'action': ['../../build/mac/tweak_info_plist.py',
'--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--scm=1', '--scm=1',
'--version=<(app_shell_version)'], '--version=<(app_shell_version)'],
}, },
...@@ -307,6 +308,7 @@ ...@@ -307,6 +308,7 @@
# but this seems like a really good place to store them. # but this seems like a really good place to store them.
'postbuild_name': 'Tweak Info.plist', 'postbuild_name': 'Tweak Info.plist',
'action': ['../../build/mac/tweak_info_plist.py', 'action': ['../../build/mac/tweak_info_plist.py',
'--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--breakpad=1', '--breakpad=1',
'--keystone=0', '--keystone=0',
'--scm=1', '--scm=1',
...@@ -379,6 +381,7 @@ ...@@ -379,6 +381,7 @@
# never placed into the helper. # never placed into the helper.
'postbuild_name': 'Tweak Info.plist', 'postbuild_name': 'Tweak Info.plist',
'action': ['../../build/mac/tweak_info_plist.py', 'action': ['../../build/mac/tweak_info_plist.py',
'--plist=${TARGET_BUILD_DIR}/${INFOPLIST_PATH}',
'--breakpad=0', '--breakpad=0',
'--keystone=0', '--keystone=0',
'--scm=0', '--scm=0',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment