Skip to content

Commit

Permalink
Support Visual C++ 2015 in post-build actions
Browse files Browse the repository at this point in the history
With this CL, we can run post build script by using non hermetic Visual
C++ 2015.

BUG=#315
TEST=
REF_BUG=24654559,25353935
REF_CL=108961837
  • Loading branch information
yukawa committed Nov 30, 2015
1 parent eb5cb7d commit 07c50e3
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mozc_version_template.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=17
BUILD=2394
BUILD=2395
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.
Expand Down
17 changes: 17 additions & 0 deletions src/win32/installer/postbuilds_win.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@
'actions': [
{
'action_name': 'postbuild',
'variables': {
'postbuild_additional_options': [],
},
'conditions': [
['compiler_target=="msvs" and compiler_target_version_int==1800', {
'variables': {
'postbuild_msvs_option': ['--msvs_version=2013'],
},
}],
['compiler_target=="msvs" and compiler_target_version_int==1900', {
'variables': {
'postbuild_msvs_option': ['--msvs_version=2015'],
},
}],
],
'inputs': [
'<(target_file)',
],
Expand All @@ -42,6 +57,8 @@
'python',
'postbuilds_win.py',
'--targetpath', '<@(_inputs)',
'<(postbuild_msvs_option)',
'<@(postbuild_additional_options)',
],
'message': 'postbuild for <@(_inputs)',
},
Expand Down
47 changes: 47 additions & 0 deletions src/win32/installer/postbuilds_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,59 @@ def ParseOption():
parser = optparse.OptionParser()
parser.add_option('--targetpath', dest='targetpath')
parser.add_option('--pdbpath', dest='pdbpath', default='')
parser.add_option('--msvs_version', dest='msvs_version', default='2013',
help='Specifies the target MSVS version.')

(opts, _) = parser.parse_args()

return opts


vcvarsall_template = (
r'C:\Program Files (x86)\Microsoft Visual Studio %d.0\VC\vcvarsall.bat')
if opts.msvs_version == '2013':
vcvarsall_path = vcvarsall_template % 12
elif opts.msvs_version == '2015':
vcvarsall_path = vcvarsall_template % 14
else:
PrintErrorAndExit('Unsupported msvs_version=%s' % opts.msvs_version)

args = [vcvarsall_path, 'amd64_x86', '&&', 'set']
popen = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)
vcvarsall_envs, _ = popen.communicate()
if popen.returncode != 0:
PrintErrorAndExit('vcvarsall.bat failed. error=%d' % popen.returncode)

prefix = 'PATH='
for line in vcvarsall_envs.splitlines():
if line.upper().startswith(prefix):
return line[len(prefix):]
PrintErrorAndExit('PATH not found')


def PostProcessOnWindows(opts):
"""Apply post-processes for Windows binaries.
Update the specified executable to be 'release quality' by
- bind import functions by bind.exe
- Set 'freeze' bit in the PE header.
- Code signing.
See the following issues for details.
http://b/1504561, http://b/1507272, http://b/2289857, http://b/1893852
Args:
opts: build options to be used to update the executable.
"""
abs_target_path = os.path.abspath(opts.targetpath)
abs_touch_file_path = abs_target_path + '.postbuild'

os.environ['PATH'] = GetPath(opts)

# If the target looks like a PE image, update it.
(_, extension) = os.path.splitext(opts.targetpath)
if extension.lower() in ['.exe', '.dll', '.ime']:
# Protect it against further binding, which invalidates code signing.
RunOrDie(['editbin.exe', '/ALLOWBIND:NO', '/RELEASE', abs_target_path])

# Touch the timestamp file.
if os.path.exists(abs_touch_file_path):
Expand Down

0 comments on commit 07c50e3

Please sign in to comment.