Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Unified Diff: pylib/gyp/generator/ninja.py

Issue 10228016: ninja windows: fix expansion of some VS macros (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pylib/gyp/generator/ninja.py
diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py
index e3a5945f67e1f40e8438a1e1d2d911002be2fa8e..f6e06a7c1bd82e410fba7d257d8183beb9625596 100644
--- a/pylib/gyp/generator/ninja.py
+++ b/pylib/gyp/generator/ninja.py
@@ -200,6 +200,11 @@ class NinjaWriter:
# Relative path from base dir to build dir.
self.base_to_build = os.path.join(InvertRelativePath(base_dir), build_dir)
+ def _WinCase(self, path):
Nico 2012/04/25 23:18:23 Method name is improvable, also docstring
scottmg 2012/04/26 03:06:46 Turns out it already exists as os.path.normcase!
+ if self.flavor == 'win':
+ path = path.lower()
Nico 2012/04/25 23:18:23 Maybe kernel32.GetLongPathName(kernel32.GetShortPa
+ return path
+
def ExpandSpecial(self, path, product_dir=None):
"""Expand specials like $!PRODUCT_DIR in |path|.
@@ -250,10 +255,11 @@ class NinjaWriter:
if path.startswith('$!'):
expanded = self.ExpandSpecial(path)
if self.flavor == 'win':
- expanded = os.path.normpath(expanded)
+ expanded = self._WinCase(os.path.normpath(expanded))
return expanded
assert '$' not in path, path
- return os.path.normpath(os.path.join(self.build_to_base, path))
+ return self._WinCase(
+ os.path.normpath(os.path.join(self.build_to_base, path)))
def GypPathToUniqueOutput(self, path, qualified=True):
"""Translate a gyp path to a ninja path for writing output.
@@ -285,8 +291,9 @@ class NinjaWriter:
path_dir, path_basename = os.path.split(path)
if qualified:
path_basename = self.name + '.' + path_basename
- return os.path.normpath(os.path.join(obj, self.base_dir, path_dir,
- path_basename))
+ return self._WinCase(
+ os.path.normpath(os.path.join(obj, self.base_dir, path_dir,
+ path_basename)))
def WriteCollapsedDependencies(self, name, targets):
"""Given a list of targets, return a path for a single file
@@ -416,7 +423,7 @@ class NinjaWriter:
path, root, dirname, source, ext, basename)
if rel:
path = os.path.relpath(path, rel)
- return path
+ return self._WinCase(path)
vars = [(name, fix_path(value, outdir)) for name, value in vars]
output = [fix_path(p) for p in output]
vars.append(('outdir', outdir))
@@ -497,12 +504,17 @@ class NinjaWriter:
rule_name = self.WriteNewNinjaRule(name, action['action'], description,
is_cygwin, env=env)
- inputs = [self.GypPathToNinja(i, env) for i in action['inputs']]
+ def reldir(path):
+ qualified = os.path.join(self.build_dir, path)
+ return self._WinCase(
+ os.path.normpath(os.path.relpath(qualified, self.build_dir)))
Nico 2012/04/25 23:18:23 What does this do?
scottmg 2012/04/26 03:06:46 Makes one's head hurt. :/ It was trying to be a b
+
+ inputs = [reldir(self.GypPathToNinja(i, env)) for i in action['inputs']]
if int(action.get('process_outputs_as_sources', False)):
extra_sources += action['outputs']
if int(action.get('process_outputs_as_mac_bundle_resources', False)):
extra_mac_bundle_resources += action['outputs']
- outputs = [self.GypPathToNinja(o, env) for o in action['outputs']]
+ outputs = [reldir(self.GypPathToNinja(o, env)) for o in action['outputs']]
# Then write out an edge using the rule.
self.ninja.build(outputs, rule_name, inputs,
@@ -666,7 +678,7 @@ class NinjaWriter:
cflags_c = self.msvs_settings.GetCflagsC(config_name)
cflags_cc = self.msvs_settings.GetCflagsCC(config_name)
extra_defines = self.msvs_settings.GetComputedDefines(config_name)
- self.WriteVariableList('pdbname', [self.name + '.pdb'])
+ self.WriteVariableList('pdbname', [self.name.lower() + '.pdb'])
else:
cflags = config.get('cflags', [])
cflags_c = config.get('cflags_c', [])
@@ -998,6 +1010,7 @@ class NinjaWriter:
if prefix == 'lib':
# Snip out an extra 'lib' from libs if appropriate.
target = StripPrefix(target, 'lib')
+ target = self._WinCase(target)
if type in ('static_library', 'loadable_module', 'shared_library',
'executable'):
@@ -1017,7 +1030,8 @@ class NinjaWriter:
if self.flavor == 'win':
overridden_name = self.msvs_settings.GetOutputName(spec, self.config_name)
if overridden_name:
- return self.ExpandSpecial(overridden_name, self.base_to_build)
+ return self._WinCase(
+ self.ExpandSpecial(overridden_name, self.base_to_build))
if self.flavor == 'mac' and type in (
'static_library', 'executable', 'shared_library', 'loadable_module'):
@@ -1198,12 +1212,17 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
flavor = gyp.common.GetFlavor(params)
generator_flags = params.get('generator_flags', {})
+ def wincase(path):
Nico 2012/04/25 23:18:23 Make the function at the top global, then you don'
+ if flavor == 'win':
+ path = path.lower()
+ return path
+
# build_dir: relative path from source root to our output files.
# e.g. "out/Debug"
build_dir = os.path.join(generator_flags.get('output_dir', 'out'),
config_name)
- toplevel_build = os.path.join(options.toplevel_dir, build_dir)
+ toplevel_build = wincase(os.path.join(options.toplevel_dir, build_dir))
master_ninja = ninja_syntax.Writer(
OpenOutput(os.path.join(toplevel_build, 'build.ninja')),
@@ -1277,7 +1296,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
command=('cmd /s /c "$cc /nologo /showIncludes '
'@$out.rsp '
'$cflags_pch_c /c $in /Fo$out /Fd$pdbname '
- '| ninja-deplist-helper -q -f cl -o $out.dl"'),
+ '| ninja-deplist-helper -r . -q -f cl -o $out.dl"'),
deplist='$out.dl',
rspfile='$out.rsp',
rspfile_content='$defines $includes $cflags $cflags_c')
@@ -1287,7 +1306,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
command=('cmd /s /c "$cxx /nologo /showIncludes '
'@$out.rsp '
'$cflags_pch_cc /c $in /Fo$out /Fd$pdbname '
- '| ninja-deplist-helper -q -f cl -o $out.dl"'),
+ '| ninja-deplist-helper -r . -q -f cl -o $out.dl"'),
deplist='$out.dl',
rspfile='$out.rsp',
rspfile_content='$defines $includes $cflags $cflags_cc')
@@ -1447,7 +1466,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params,
obj = 'obj'
if toolset != 'target':
obj += '.' + toolset
- output_file = os.path.join(obj, base_path, name + '.ninja')
+ output_file = wincase(os.path.join(obj, base_path, name + '.ninja'))
abs_build_dir = os.path.abspath(toplevel_build)
writer = NinjaWriter(target_outputs, base_path, build_dir,
« no previous file with comments | « no previous file | pylib/gyp/msvs_emulation.py » ('j') | test/ninja/normalize-paths-win/gyptest-normalize-paths.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698