mirror of
https://github.com/mii443/mozc.git
synced 2025-12-03 19:28:22 +00:00
Refactor build_mozc.py a bit
Before working on #708, this CL simplifies the code a bit. There must be no behavior change in this CL. #codehealth PiperOrigin-RevId: 522494316
This commit is contained in:
committed by
Hiroyuki Komatsu
parent
debb828e6a
commit
be61d41fc5
@@ -379,26 +379,25 @@ def ParseCleanOptions(args):
|
|||||||
return parser.parse_args(args)
|
return parser.parse_args(args)
|
||||||
|
|
||||||
|
|
||||||
def AddPythonPathToEnvironmentFilesForWindows(out_dir):
|
def UpdateEnvironmentFilesForWindows(out_dir):
|
||||||
"""Add PYTHONPATH to environment files for Ninja."""
|
"""Add required environment variables for Ninja build."""
|
||||||
python_path_root = MOZC_ROOT
|
python_path_root = MOZC_ROOT
|
||||||
python_path = os.path.abspath(python_path_root)
|
python_path = os.path.abspath(python_path_root)
|
||||||
original_python_paths = os.environ.get('PYTHONPATH', '')
|
original_python_paths = os.environ.get('PYTHONPATH', '')
|
||||||
if original_python_paths:
|
if original_python_paths:
|
||||||
python_path = os.pathsep.join([original_python_paths, python_path])
|
python_path = os.pathsep.join([original_python_paths, python_path])
|
||||||
nul = chr(0)
|
nul = chr(0)
|
||||||
|
additional_content = nul.join([
|
||||||
|
'PYTHONPATH=' + python_path,
|
||||||
|
nul]).encode('utf-8')
|
||||||
for d in os.listdir(out_dir):
|
for d in os.listdir(out_dir):
|
||||||
abs_dir = os.path.abspath(os.path.join(out_dir, d))
|
abs_dir = os.path.abspath(os.path.join(out_dir, d))
|
||||||
with open(os.path.join(abs_dir, 'environment.x86'), 'rb') as x86_file:
|
with open(os.path.join(abs_dir, 'environment.x86'), 'rb') as x86_file:
|
||||||
x86_content = (
|
x86_content = x86_file.read()[:-1] + additional_content
|
||||||
x86_file.read()[:-1] +
|
|
||||||
('PYTHONPATH=' + python_path + nul + nul).encode('utf-8'))
|
|
||||||
with open(os.path.join(abs_dir, 'environment.x86'), 'wb') as x86_file:
|
with open(os.path.join(abs_dir, 'environment.x86'), 'wb') as x86_file:
|
||||||
x86_file.write(x86_content)
|
x86_file.write(x86_content)
|
||||||
with open(os.path.join(abs_dir, 'environment.x64'), 'rb') as x64_file:
|
with open(os.path.join(abs_dir, 'environment.x64'), 'rb') as x64_file:
|
||||||
x64_content = (
|
x64_content = x64_file.read()[:-1] + additional_content
|
||||||
x64_file.read()[:-1] +
|
|
||||||
('PYTHONPATH=' + python_path + nul + nul).encode('utf-8'))
|
|
||||||
with open(os.path.join(abs_dir, 'environment.x64'), 'wb') as x64_file:
|
with open(os.path.join(abs_dir, 'environment.x64'), 'wb') as x64_file:
|
||||||
x64_file.write(x64_content)
|
x64_file.write(x64_content)
|
||||||
|
|
||||||
@@ -577,7 +576,7 @@ def GypMain(options, unused_args):
|
|||||||
# For internal Ninja build on Windows, set up environment files
|
# For internal Ninja build on Windows, set up environment files
|
||||||
if IsWindows():
|
if IsWindows():
|
||||||
out_dir = os.path.join(MOZC_ROOT, 'out_win')
|
out_dir = os.path.join(MOZC_ROOT, 'out_win')
|
||||||
AddPythonPathToEnvironmentFilesForWindows(out_dir)
|
UpdateEnvironmentFilesForWindows(out_dir)
|
||||||
|
|
||||||
if IsWindows() and (not options.noqt):
|
if IsWindows() and (not options.noqt):
|
||||||
# When Windows build is configured to use DLL version of Qt, copy Qt's DLLs
|
# When Windows build is configured to use DLL version of Qt, copy Qt's DLLs
|
||||||
|
|||||||
Reference in New Issue
Block a user