mozc: simplify gyp.patch

NOTE: these changes require updating gyp submodule in mozc github repo.

See https://github.com/dextero/mozc/actions for results of a test CI run.

* Set GYP_MSVS_DISABLE_PATH_NORMALIZATION environment variable in
  build_mozc.py. Removing path normalization that was breaking Windows build
  was a breaking change that didn't get accepted in upstream. Instead, setting
  that environment variable makes gyp skip the normalization.

* Remove instructions to apply gyp.patch from Windows build instructions.

PiperOrigin-RevId: 440133963
This commit is contained in:
Marcin Radomski
2022-04-08 02:00:13 +09:00
committed by Hiroyuki Komatsu
parent 18c04be4a5
commit ec41969589
7 changed files with 27 additions and 228 deletions

View File

@ -26,6 +26,7 @@ jobs:
run: |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
echo "$PWD/depot_tools" >> $GITHUB_PATH
python3 -m pip install six
cd gyp
git apply ../../gyp/gyp.patch

View File

@ -31,10 +31,9 @@ jobs:
working-directory: .\src\third_party
run: |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
cd gyp
git apply ..\..\gyp\gyp.patch
cd ..\abseil-cpp
git apply ..\..\base\absl.patch
python3 -m pip install six
- name: build
shell: cmd

View File

@ -34,7 +34,7 @@ ENV DEBIAN_FRONTEND noninteractive
# Package installation
RUN apt-get update
## Common packages for linux build environment
RUN apt-get install -y clang libc++-dev libc++abi-dev python pkg-config git curl bzip2 unzip make ninja-build
RUN apt-get install -y clang libc++-dev libc++abi-dev python python-six python3-six pkg-config git curl bzip2 unzip make ninja-build
## Packages for linux desktop version
RUN apt-get install -y libibus-1.0-dev libglib2.0-dev qtbase5-dev libgtk2.0-dev libxcb-xfixes0-dev
## Packages for misc tools

View File

@ -11,6 +11,16 @@ cd ~/work
git clone https://github.com/google/mozc.git -b master --single-branch --recursive
```
### Apply a patch to GYP
The upstream GYP may or may not work on macOS for Mozc.
You probably need to apply the following patch to GYP.
```
cd src\third_party\gyp
git apply ..\..\gyp\gyp.patch
```
## System Requirements
Only 64-bit macOS 10.9 and later versions are supported.
@ -36,6 +46,12 @@ Make sure the path to python3.
/usr/bin/python3
```
# Install python3 dependencies
```
python3 -m pip install six
```
### Build Qt
Qt is required for GUI tools. The following is an example of build configuration.
@ -52,16 +68,6 @@ make
## Build with GYP (stable)
### Apply a patch to GYP
The upstream GYP may or may not work on macOS for Mozc.
You probably need to apply the following patch to GYP.
```
cd src\third_party\gyp
git apply ..\..\gyp\gyp.patch
```
### Build main converter and composition UI.
First, you'll need to generate Xcode project using a tool called [GYP](https://chromium.googlesource.com/external/gyp).

View File

@ -29,6 +29,12 @@ gclient
gclient
```
# Install python3 dependencies
```
python3 -m pip install six
```
# Get the Code
You can download Mozc source code as follows:
@ -39,16 +45,6 @@ cd c:\work
git clone -c core.autocrlf=false https://github.com/google/mozc.git -b master --single-branch --recursive
```
# Apply a patch to GYP
The upstream GYP does not work on Windows for Mozc.
You need to apply the following patch to GYP.
```
cd src\third_party\gyp
git apply ..\..\gyp\gyp.patch
```
# Compilation
First, you'll need to generate Visual C++ project files using a tool called [GYP](https://chromium.googlesource.com/external/gyp).

View File

@ -410,6 +410,8 @@ def GypMain(options, unused_args):
# Set the generator name.
os.environ['GYP_GENERATORS'] = 'ninja'
# Disable path normalization that breaks arguments like --name=../../path
os.environ['GYP_MSVS_DISABLE_PATH_NORMALIZATION'] = '1'
# Get and show the list of .gyp file names.
gyp_file_names = GetGypFileNames(options)

View File

@ -1,88 +1,3 @@
diff --git a/pylib/gyp/MSVSVersion.py b/pylib/gyp/MSVSVersion.py
index 71582ccd..2d8a2cfe 100644
--- a/pylib/gyp/MSVSVersion.py
+++ b/pylib/gyp/MSVSVersion.py
@@ -263,7 +263,7 @@ def _CreateVersion(name, path, sdk_based=False):
'2019': VisualStudioVersion('2019',
'Visual Studio 2019',
solution_version='12.00',
- project_version='15.0',
+ project_version='16.0',
flat_sln=False,
uses_vcxproj=True,
path=path,
@@ -400,6 +400,7 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
2013(e) - Visual Studio 2013 (12)
2015 - Visual Studio 2015 (14)
2017 - Visual Studio 2017 (15)
+ 2019 - Visual Studio 2019 (16)
Where (e) is e for express editions of MSVS and blank otherwise.
"""
version_to_year = {
@@ -409,7 +410,8 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
'11.0': '2012',
'12.0': '2013',
'14.0': '2015',
- '15.0': '2017'
+ '15.0': '2017',
+ '16.0': '2019'
}
versions = []
for version in versions_to_check:
@@ -448,13 +450,22 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
if not path:
continue
path = _ConvertToCygpath(path)
- if version == '15.0':
+ if version == '16.0':
+ if os.path.exists(path):
+ versions.append(_CreateVersion('2019', path))
+ elif version == '15.0':
if os.path.exists(path):
versions.append(_CreateVersion('2017', path))
elif version != '14.0': # There is no Express edition for 2015.
versions.append(_CreateVersion(version_to_year[version] + 'e',
os.path.join(path, '..'), sdk_based=True))
+ if (not versions) and ('16.0' in versions_to_check):
+ # This is the path for GitHub Actions.
+ path = r'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise'
+ path = _ConvertToCygpath(path)
+ versions.append(_CreateVersion('2019', path))
+
return versions
@@ -470,7 +481,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
if version == 'auto':
version = os.environ.get('GYP_MSVS_VERSION', 'auto')
version_map = {
- 'auto': ('15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
+ 'auto': ('16.0', '15.0', '14.0', '12.0', '10.0', '9.0', '8.0', '11.0'),
'2005': ('8.0',),
'2005e': ('8.0',),
'2008': ('9.0',),
@@ -483,6 +494,7 @@ def SelectVisualStudioVersion(version='auto', allow_fallback=True):
'2013e': ('12.0',),
'2015': ('14.0',),
'2017': ('15.0',),
+ '2019': ('16.0',),
}
override_path = os.environ.get('GYP_MSVS_OVERRIDE_PATH')
if override_path:
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index bf04e567..462af711 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -751,7 +751,7 @@ class NinjaWriter(object):
if self.flavor == 'win':
# WriteNewNinjaRule uses unique_name for creating an rsp file on win.
extra_bindings.append(('unique_name',
- hashlib.md5(outputs[0]).hexdigest()))
+ hashlib.md5(outputs[0].encode('utf-8')).hexdigest()))
self.ninja.build(outputs, rule_name, self.GypPathToNinja(source),
implicit=inputs,
diff --git a/pylib/gyp/mac_tool.py b/pylib/gyp/mac_tool.py
index 64d21063..8483c8f2 100755
--- a/pylib/gyp/mac_tool.py
@ -105,123 +20,3 @@ index 64d21063..8483c8f2 100755
fp = open(dest, 'wb')
fp.write(s.decode(input_code).encode('UTF-16'))
diff --git a/pylib/gyp/msvs_emulation.py b/pylib/gyp/msvs_emulation.py
index 63d40e63..935af325 100644
--- a/pylib/gyp/msvs_emulation.py
+++ b/pylib/gyp/msvs_emulation.py
@@ -38,8 +38,8 @@ def QuoteForRspFile(arg):
# use that function to handle command line arguments.
# Use a heuristic to try to find args that are paths, and normalize them
- if arg.find('/') > 0 or arg.count('/') > 1:
- arg = os.path.normpath(arg)
+ # if arg.find('/') > 0 or arg.count('/') > 1:
+ # arg = os.path.normpath(arg)
# For a literal quote, CommandLineToArgvW requires 2n+1 backslashes
# preceding it, and results in n backslashes + the quote. So we substitute
@@ -138,7 +138,8 @@ def _FindDirectXInstallation():
if not dxsdk_dir:
# Setup params to pass to and attempt to launch reg.exe.
cmd = ['reg.exe', 'query', r'HKLM\Software\Microsoft\DirectX', '/s']
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ universal_newlines=True)
for line in p.communicate()[0].splitlines():
if 'InstallPath' in line:
dxsdk_dir = line.split(' ')[3] + "\\"
@@ -321,7 +322,7 @@ class MsvsSettings(object):
# first level is globally for the configuration (this is what we consider
# "the" config at the gyp level, which will be something like 'Debug' or
# 'Release'), VS2015 and later only use this level
- if self.vs_version.short_name >= 2015:
+ if self.vs_version.short_name >= '2015':
return config
# and a second target-specific configuration, which is an
# override for the global one. |config| is remapped here to take into
@@ -485,7 +486,7 @@ class MsvsSettings(object):
prefix='/arch:')
cflags.extend(['/FI' + f for f in self._Setting(
('VCCLCompilerTool', 'ForcedIncludeFiles'), config, default=[])])
- if self.vs_version.project_version >= 12.0:
+ if self.vs_version.project_version >= '12.0':
# New flag introduced in VS2013 (project version 12.0) Forces writes to
# the program database (PDB) to be serialized through MSPDBSRV.EXE.
# https://msdn.microsoft.com/en-us/library/dn502518.aspx
@@ -1050,7 +1051,8 @@ def GenerateEnvironmentFiles(toplevel_build_dir, generator_flags,
args = vs.SetupScript(arch)
args.extend(('&&', 'set'))
popen = subprocess.Popen(
- args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ universal_newlines=True)
variables, _ = popen.communicate()
if popen.returncode != 0:
raise Exception('"%s" failed with error %d' % (args, popen.returncode))
@@ -1071,7 +1073,8 @@ def GenerateEnvironmentFiles(toplevel_build_dir, generator_flags,
args = vs.SetupScript(arch)
args.extend(('&&',
'for', '%i', 'in', '(cl.exe)', 'do', '@echo', 'LOC:%~$PATH:i'))
- popen = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)
+ popen = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE,
+ universal_newlines=True)
output, _ = popen.communicate()
cl_paths[arch] = _ExtractCLPath(output)
return cl_paths
diff --git a/pylib/gyp/win_tool.py b/pylib/gyp/win_tool.py
index 89734846..6fea9a42 100755
--- a/pylib/gyp/win_tool.py
+++ b/pylib/gyp/win_tool.py
@@ -133,6 +133,7 @@ class WinTool(object):
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = link.communicate()
for line in out.splitlines():
+ line = line.decode('utf-8')
if (not line.startswith(' Creating library ') and
not line.startswith('Generating code') and
not line.startswith('Finished generating code')):
@@ -197,8 +198,10 @@ class WinTool(object):
# and sometimes doesn't unfortunately.
with open(our_manifest, 'r') as our_f:
with open(assert_manifest, 'r') as assert_f:
- our_data = our_f.read().translate(None, string.whitespace)
- assert_data = assert_f.read().translate(None, string.whitespace)
+ our_data = re.sub(r'\s+', '', our_f.read())
+ assert_data = re.sub(r'\s+', '', assert_f.read())
+ #our_data = our_f.read().translate(None, string.whitespace)
+ #assert_data = assert_f.read().translate(None, string.whitespace)
if our_data != assert_data:
os.unlink(out)
def dump(filename):
@@ -226,6 +229,7 @@ class WinTool(object):
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = popen.communicate()
for line in out.splitlines():
+ line = line.decode('utf-8')
if line and 'manifest authoring warning 81010002' not in line:
print(line)
return popen.returncode
@@ -257,6 +261,7 @@ class WinTool(object):
popen = subprocess.Popen(args, shell=True, env=env,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = popen.communicate()
+ out = out.decode('utf-8')
# Filter junk out of stdout, and write filtered versions. Output we want
# to filter is pairs of lines that look like this:
# Processing C:\Program Files (x86)\Microsoft SDKs\...\include\objidl.idl
@@ -277,6 +282,7 @@ class WinTool(object):
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = popen.communicate()
for line in out.splitlines():
+ line = line.decode('utf-8')
if (not line.startswith('Copyright (C) Microsoft Corporation') and
not line.startswith('Microsoft (R) Macro Assembler') and
not line.startswith(' Assembling: ') and
@@ -292,6 +298,7 @@ class WinTool(object):
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
out, _ = popen.communicate()
for line in out.splitlines():
+ line = line.decode('utf-8')
if (not line.startswith('Microsoft (R) Windows (R) Resource Compiler') and
not line.startswith('Copyright (C) Microsoft Corporation') and
line):