Skip to content

Commit

Permalink
gyp: update
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Nov 2, 2012
1 parent e95f12c commit 4d9d23e
Show file tree
Hide file tree
Showing 421 changed files with 15,984 additions and 2,758 deletions.
62 changes: 60 additions & 2 deletions tools/gyp/PRESUBMIT.py
@@ -1,4 +1,4 @@
# Copyright (c) 2011 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand All @@ -10,6 +10,62 @@
"""


PYLINT_BLACKLIST = [
# TODO: fix me.
# From SCons, not done in google style.
'test/lib/TestCmd.py',
'test/lib/TestCommon.py',
'test/lib/TestGyp.py',
# Needs style fix.
'pylib/gyp/generator/scons.py',
'pylib/gyp/generator/xcode.py',
]


PYLINT_DISABLED_WARNINGS = [
# TODO: fix me.
# Many tests include modules they don't use.
'W0611',
# Include order doesn't properly include local files?
'F0401',
# Some use of built-in names.
'W0622',
# Some unused variables.
'W0612',
# Operator not preceded/followed by space.
'C0323',
'C0322',
# Unnecessary semicolon.
'W0301',
# Unused argument.
'W0613',
# String has no effect (docstring in wrong place).
'W0105',
# Comma not followed by space.
'C0324',
# Access to a protected member.
'W0212',
# Bad indent.
'W0311',
# Line too long.
'C0301',
# Undefined variable.
'E0602',
# Not exception type specified.
'W0702',
# No member of that name.
'E1101',
# Dangerous default {}.
'W0102',
# Others, too many to sort.
'W0201', 'W0232', 'E1103', 'W0621', 'W0108', 'W0223', 'W0231',
'R0201', 'E0101', 'C0321',
# ************* Module copy
# W0104:427,12:_test.odict.__setitem__: Statement seems to have no effect
'W0104',
]


def CheckChangeOnUpload(input_api, output_api):
report = []
report.extend(input_api.canned_checks.PanProjectChecks(
Expand Down Expand Up @@ -41,7 +97,9 @@ def CheckChangeOnCommit(input_api, output_api):
sys.path = ['pylib', 'test/lib'] + sys.path
report.extend(input_api.canned_checks.RunPylint(
input_api,
output_api))
output_api,
black_list=PYLINT_BLACKLIST,
disabled_warnings=PYLINT_DISABLED_WARNINGS))
finally:
sys.path = old_sys_path
return report
Expand Down
14 changes: 12 additions & 2 deletions tools/gyp/gyptest.py
Expand Up @@ -153,6 +153,8 @@ def main(argv=None):
help="chdir to the specified directory")
parser.add_option("-f", "--format", action="store", default='',
help="run tests with the specified formats")
parser.add_option("-G", '--gyp_option', action="append", default=[],
help="Add -G options to the gyp command line")
parser.add_option("-l", "--list", action="store_true",
help="list available tests and exit")
parser.add_option("-n", "--no-exec", action="store_true",
Expand All @@ -169,7 +171,9 @@ def main(argv=None):
os.chdir(opts.chdir)

if opts.path:
os.environ['PATH'] += ':' + ':'.join(opts.path)
extra_path = [os.path.abspath(p) for p in opts.path]
extra_path = os.pathsep.join(extra_path)
os.environ['PATH'] += os.pathsep + extra_path

if not args:
if not opts.all:
Expand Down Expand Up @@ -220,8 +224,14 @@ def main(argv=None):
if not opts.quiet:
sys.stdout.write('TESTGYP_FORMAT=%s\n' % format)

gyp_options = []
for option in opts.gyp_option:
gyp_options += ['-G', option]
if gyp_options and not opts.quiet:
sys.stdout.write('Extra Gyp options: %s\n' % gyp_options)

for test in tests:
status = cr.run([sys.executable, test],
status = cr.run([sys.executable, test] + gyp_options,
stdout=sys.stdout,
stderr=sys.stderr)
if status == 2:
Expand Down
27 changes: 12 additions & 15 deletions tools/gyp/pylib/gyp/MSVSNew.py
@@ -1,10 +1,9 @@
# Copyright (c) 2011 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""New implementation of Visual Studio project generation for SCons."""

import common
import os
import random

Expand Down Expand Up @@ -60,7 +59,13 @@ def MakeGuid(name, seed='msvs_new'):
#------------------------------------------------------------------------------


class MSVSFolder(object):
class MSVSSolutionEntry(object):
def __cmp__(self, other):
# Sort by name then guid (so things are in order on vs2008).
return cmp((self.name, self.get_guid()), (other.name, other.get_guid()))


class MSVSFolder(MSVSSolutionEntry):
"""Folder in a Visual Studio project or solution."""

def __init__(self, path, name = None, entries = None,
Expand All @@ -86,7 +91,7 @@ def __init__(self, path, name = None, entries = None,
self.guid = guid

# Copy passed lists (or set to empty lists)
self.entries = list(entries or [])
self.entries = sorted(list(entries or []))
self.items = list(items or [])

self.entry_type_guid = ENTRY_TYPE_GUIDS['folder']
Expand All @@ -101,7 +106,7 @@ def get_guid(self):
#------------------------------------------------------------------------------


class MSVSProject(object):
class MSVSProject(MSVSSolutionEntry):
"""Visual Studio project."""

def __init__(self, path, name = None, dependencies = None, guid = None,
Expand Down Expand Up @@ -208,7 +213,7 @@ def __init__(self, path, version, entries=None, variants=None,
self.Write()


def Write(self, writer=common.WriteOnDiff):
def Write(self, writer=gyp.common.WriteOnDiff):
"""Writes the solution file to disk.
Raises:
Expand All @@ -230,15 +235,7 @@ def Write(self, writer=common.WriteOnDiff):
if isinstance(e, MSVSFolder):
entries_to_check += e.entries

# Sort by name then guid (so things are in order on vs2008).
def NameThenGuid(a, b):
if a.name < b.name: return -1
if a.name > b.name: return 1
if a.get_guid() < b.get_guid(): return -1
if a.get_guid() > b.get_guid(): return 1
return 0

all_entries = sorted(all_entries, NameThenGuid)
all_entries = sorted(all_entries)

# Open file and print header
f = writer(self.path)
Expand Down
4 changes: 2 additions & 2 deletions tools/gyp/pylib/gyp/MSVSProject.py
@@ -1,10 +1,10 @@
# Copyright (c) 2011 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Visual Studio project reader/writer."""

import common
import gyp.common
import gyp.easy_xml as easy_xml

#------------------------------------------------------------------------------
Expand Down
30 changes: 22 additions & 8 deletions tools/gyp/pylib/gyp/MSVSSettings.py
@@ -1,4 +1,4 @@
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand All @@ -15,7 +15,7 @@
"""

import sys

import re

# Dictionaries of settings validators. The key is the tool name, the value is
# a dictionary mapping setting names to validation functions.
Expand Down Expand Up @@ -362,6 +362,24 @@ def _Translate(value, msbuild_settings):
_msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate


fix_vc_macro_slashes_regex_list = ('IntDir', 'OutDir')
fix_vc_macro_slashes_regex = re.compile(
r'(\$\((?:%s)\))(?:[\\/]+)' % "|".join(fix_vc_macro_slashes_regex_list)
)

def FixVCMacroSlashes(s):
"""Replace macros which have excessive following slashes.
These macros are known to have a built-in trailing slash. Furthermore, many
scripts hiccup on processing paths with extra slashes in the middle.
This list is probably not exhaustive. Add as needed.
"""
if '$' in s:
s = fix_vc_macro_slashes_regex.sub(r'\1', s)
return s


def ConvertVCMacrosToMSBuild(s):
"""Convert the the MSVS macros found in the string to the MSBuild equivalent.
Expand All @@ -378,14 +396,10 @@ def ConvertVCMacrosToMSBuild(s):
'$(ParentName)': '$(ProjectFileName)',
'$(PlatformName)': '$(Platform)',
'$(SafeInputName)': '%(Filename)',

'$(IntDir)\\': '$(IntDir)',
'$(OutDir)\\': '$(OutDir)',
'$(IntDir)/': '$(IntDir)',
'$(OutDir)/': '$(OutDir)',
}
for old, new in replace_map.iteritems():
s = s.replace(old, new)
s = FixVCMacroSlashes(s)
return s


Expand Down Expand Up @@ -481,7 +495,7 @@ def _ValidateSettings(validators, settings, stderr):
_midl = _Tool('VCMIDLTool', 'Midl')
_rc = _Tool('VCResourceCompilerTool', 'ResourceCompile')
_lib = _Tool('VCLibrarianTool', 'Lib')
_manifest = _Tool('VCManifestTool', 'Mt')
_manifest = _Tool('VCManifestTool', 'Manifest')


_AddTool(_compile)
Expand Down
17 changes: 9 additions & 8 deletions tools/gyp/pylib/gyp/MSVSSettings_test.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python

# Copyright (c) 2011 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand Down Expand Up @@ -514,7 +514,7 @@ def testValidateMSBuildSettings_settings(self):
'TreatLibWarningAsErrors': 'true',
'UseUnicodeResponseFiles': 'true',
'Verbose': 'true'},
'Mt': {
'Manifest': {
'AdditionalManifestFiles': 'file1;file2',
'AdditionalOptions': 'a string1',
'AssemblyIdentity': 'a string1',
Expand Down Expand Up @@ -550,11 +550,12 @@ def testValidateMSBuildSettings_settings(self):
self._ExpectedWarnings([
'Warning: unrecognized setting ClCompile/Enableprefast',
'Warning: unrecognized setting ClCompile/ZZXYZ',
'Warning: unrecognized setting Mt/notgood3',
"Warning: for Mt/GenerateCatalogFiles, expected bool; got 'truel'",
'Warning: unrecognized setting Manifest/notgood3',
'Warning: for Manifest/GenerateCatalogFiles, '
"expected bool; got 'truel'",
'Warning: for Lib/TargetMachine, unrecognized enumerated value '
'MachineX86i',
"Warning: for Mt/EnableDPIAwareness, expected bool; got 'fal'"])
"Warning: for Manifest/EnableDPIAwareness, expected bool; got 'fal'"])

def testConvertToMSBuildSettings_empty(self):
"""Tests an empty conversion."""
Expand Down Expand Up @@ -1054,7 +1055,7 @@ def testConvertToMSBuildSettings_full_synthetic(self):
'OutputFile': 'a_file_name',
'SuppressStartupBanner': 'true',
'UseUnicodeResponseFiles': 'true'},
'Mt': {
'Manifest': {
'AdditionalManifestFiles': 'file1;file2;file3',
'AdditionalOptions': 'a_string',
'AssemblyIdentity': 'a_string',
Expand Down Expand Up @@ -1124,7 +1125,7 @@ def testConvertToMSBuildSettings_actual(self):
AdditionalIncludeDirectories: ';%(AdditionalIncludeDirectories)',
AdditionalOptions: ' %(AdditionalOptions)',
PreprocessorDefinitions: ';%(PreprocessorDefinitions)',
Mt:
Manifest:
AdditionalManifestFiles: ';%(AdditionalManifestFiles)',
AdditionalOptions: ' %(AdditionalOptions)',
InputResourceManifests: ';%(InputResourceManifests)',
Expand Down Expand Up @@ -1442,7 +1443,7 @@ def testConvertToMSBuildSettings_actual(self):
'PreprocessorDefinitions': '_UNICODE;UNICODE2',
'ResourceOutputFileName': '$(IntDir)%(Filename)3.res',
'ShowProgress': 'true'},
'Mt': {
'Manifest': {
'AdditionalManifestFiles': 'sfsdfsd',
'AdditionalOptions': 'afdsdafsd',
'AssemblyIdentity': 'sddfdsadfsa',
Expand Down
4 changes: 2 additions & 2 deletions tools/gyp/pylib/gyp/MSVSToolFile.py
@@ -1,10 +1,10 @@
# Copyright (c) 2009 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Visual Studio project reader/writer."""

import common
import gyp.common
import gyp.easy_xml as easy_xml


Expand Down
5 changes: 3 additions & 2 deletions tools/gyp/pylib/gyp/MSVSUserFile.py
@@ -1,13 +1,14 @@
# Copyright (c) 2009 Google Inc. All rights reserved.
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Visual Studio user preferences file writer."""

import common
import os
import re
import socket # for gethostname

import gyp.common
import gyp.easy_xml as easy_xml


Expand Down

0 comments on commit 4d9d23e

Please sign in to comment.