Permalink
Browse files

gyp: candor_gyp

  • Loading branch information...
1 parent 4d9d23e commit 7a7a5dca92edc11c7695cb1676f32b6c8e808183 @indutny committed Nov 2, 2012
Showing 987 changed files with 499 additions and 32,938 deletions.
View
@@ -3,4 +3,5 @@
*.dSYM
/can
/build
+/out
/test-runner
View
@@ -1,24 +1,23 @@
BUILDTYPE ?= Debug
JOBS ?= 1
-ARCH ?=
+ARCH ?= x64
all: libcandor.a can
build:
- tools/gyp/gyp -Dosx_arch=$(ARCH) --generator-output=build --format=make \
- --depth=. candor.gyp test/test.gyp
+ ./candor_gyp -f make -Dosx_arch=$(ARCH)
libcandor.a: build
- $(MAKE) -j $(JOBS) -C build candor
- ln -sf build/out/$(BUILDTYPE)/libcandor.a libcandor.a
+ $(MAKE) -j $(JOBS) -C out candor
+ ln -sf out/$(BUILDTYPE)/libcandor.a libcandor.a
can: build
- $(MAKE) -j $(JOBS) -C build can
- ln -sf build/out/$(BUILDTYPE)/can can
+ $(MAKE) -j $(JOBS) -C out can
+ ln -sf out/$(BUILDTYPE)/can can
test-runner: build
- $(MAKE) -j $(JOBS) -C build test
- ln -sf build/out/$(BUILDTYPE)/test test-runner
+ $(MAKE) -j $(JOBS) -C out test
+ ln -sf out/$(BUILDTYPE)/test test-runner
test: test-runner can
@./test-runner parser
@@ -44,7 +43,7 @@ test: test-runner can
@./can test/functional/regressions/regr-3.can
clean:
- -rm -rf build
+ -rm -rf out
-rm libcandor.a can test-runner
.PHONY: clean all build test libcandor.a can test-runner
View
@@ -1,16 +1,11 @@
{
- 'includes': [ 'common.gyp' ],
-
'targets': [{
'target_name': 'candor',
'type': 'static_library',
'include_dirs': [
'include',
'src'
],
- 'cflags': ['-Wall', '-Wextra', '-Wno-unused-parameter',
- '-fPIC', '-fno-strict-aliasing', '-fno-exceptions',
- '-pedantic'],
'sources': [
'src/zone.cc',
'src/api.cc',
@@ -61,9 +56,6 @@
'include',
'src'
],
- 'cflags': ['-Wall', '-Wextra', '-Wno-unused-parameter',
- '-fPIC', '-fno-strict-aliasing', '-fno-exceptions',
- '-pedantic'],
'sources': [
'src/can.cc'
]
View
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+import glob
+import os
+import shlex
+import sys
+
+can_root = os.path.dirname(__file__)
+
+sys.path.insert(0, os.path.join(can_root, 'tools', 'gyp', 'pylib'))
+import gyp
+
+# Directory within which we want all generated files (including Makefiles)
+# to be written.
+output_dir = os.path.join(os.path.abspath(can_root), 'out')
+
+def run_gyp(args):
+ rc = gyp.main(args)
+ if rc != 0:
+ print 'Error running GYP'
+ sys.exit(rc)
+
+if __name__ == '__main__':
+ args = sys.argv[1:]
+
+ args.append(os.path.join(os.path.abspath(can_root), 'candor.gyp'))
+ args.append(os.path.join(os.path.abspath(can_root), 'test/test.gyp'))
+ common_fn = os.path.join(os.path.abspath(can_root), 'common.gypi')
+ options_fn = os.path.join(os.path.abspath(can_root), 'config.gypi')
+
+ if os.path.exists(common_fn):
+ args.extend(['-I', common_fn])
+
+ if os.path.exists(options_fn):
+ args.extend(['-I', options_fn])
+
+ args.append('--depth=' + can_root)
+
+ if 'ninja' not in args:
+ # Tell gyp to write the Makefiles into output_dir
+ args.extend(['--generator-output', output_dir])
+
+ # Tell make to write its output into the same dir
+ args.extend(['-Goutput_dir=' + output_dir])
+
+ args.append('-Dcomponent=static_library')
+ args.append('-Dlibrary=static_library')
+ gyp_args = list(args)
+ run_gyp(gyp_args)
File renamed without changes.
View
@@ -1,6 +1,4 @@
{
- 'includes': [ '../common.gyp' ],
-
'variables': {
'variables': {
'host_arch%':
@@ -171,9 +171,7 @@ def main(argv=None):
os.chdir(opts.chdir)
if 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
+ os.environ['PATH'] += ':' + ':'.join(opts.path)
if not args:
if not opts.all:
@@ -59,13 +59,7 @@ def MakeGuid(name, seed='msvs_new'):
#------------------------------------------------------------------------------
-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):
+class MSVSFolder(object):
"""Folder in a Visual Studio project or solution."""
def __init__(self, path, name = None, entries = None,
@@ -91,7 +85,7 @@ def __init__(self, path, name = None, entries = None,
self.guid = guid
# Copy passed lists (or set to empty lists)
- self.entries = sorted(list(entries or []))
+ self.entries = list(entries or [])
self.items = list(items or [])
self.entry_type_guid = ENTRY_TYPE_GUIDS['folder']
@@ -106,7 +100,7 @@ def get_guid(self):
#------------------------------------------------------------------------------
-class MSVSProject(MSVSSolutionEntry):
+class MSVSProject(object):
"""Visual Studio project."""
def __init__(self, path, name = None, dependencies = None, guid = None,
@@ -235,7 +229,15 @@ def Write(self, writer=gyp.common.WriteOnDiff):
if isinstance(e, MSVSFolder):
entries_to_check += e.entries
- all_entries = sorted(all_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)
# Open file and print header
f = writer(self.path)
@@ -9,7 +9,6 @@
import re
import subprocess
import sys
-import gyp
class VisualStudioVersion(object):
@@ -194,8 +193,6 @@ def _CreateVersion(name, path, sdk_based=False):
autodetected if GYP_MSVS_VERSION is not explicitly specified. If a version is
passed in that doesn't match a value in versions python will throw a error.
"""
- if path:
- path = os.path.normpath(path)
versions = {
'2012': VisualStudioVersion('2012',
'Visual Studio 2012',
@@ -267,14 +264,6 @@ def _CreateVersion(name, path, sdk_based=False):
return versions[str(name)]
-def _ConvertToCygpath(path):
- """Convert to cygwin path if we are using cygwin."""
- if sys.platform == 'cygwin':
- p = subprocess.Popen(['cygpath', path], stdout=subprocess.PIPE)
- path = p.communicate()[0].strip()
- return path
-
-
def _DetectVisualStudioVersions(versions_to_check, force_express):
"""Collect the list of installed visual studio versions.
@@ -305,7 +294,6 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
path = _RegistryGetValue(keys[index], 'InstallDir')
if not path:
continue
- path = _ConvertToCygpath(path)
# Check for full.
full_path = os.path.join(path, 'devenv.exe')
express_path = os.path.join(path, 'vcexpress.exe')
@@ -326,7 +314,6 @@ def _DetectVisualStudioVersions(versions_to_check, force_express):
path = _RegistryGetValue(keys[index], version)
if not path:
continue
- path = _ConvertToCygpath(path)
versions.append(_CreateVersion(version_to_year[version] + 'e',
os.path.join(path, '..'), sdk_based=True))
@@ -12,7 +12,6 @@
import shlex
import sys
import traceback
-from gyp.common import GypError
# Default debug modes for GYP
debug = {}
@@ -45,9 +44,15 @@ def FindBuildFiles():
return build_files
+class GypError(Exception):
+ """Error class representing an error, which is to be presented
+ to the user. The main entry point will catch and display this.
+ """
+ pass
+
+
def Load(build_files, format, default_variables={},
- includes=[], depth='.', params=None, check=False,
- circular_check=True):
+ includes=[], depth='.', params=None, check=False, circular_check=True):
"""
Loads one or more specified build files.
default_variables and includes will be copied before use.
@@ -125,8 +130,7 @@ def Load(build_files, format, default_variables={},
# Process the input specific to this generator.
result = gyp.input.Load(build_files, default_variables, includes[:],
- depth, generator_input_info, check, circular_check,
- params['parallel'])
+ depth, generator_input_info, check, circular_check)
return [generator] + result
def NameValueListToDict(name_value_list):
@@ -313,14 +317,9 @@ def gyp_main(args):
help='do not read options from environment variables')
parser.add_option('--check', dest='check', action='store_true',
help='check format of gyp files')
- parser.add_option('--parallel', action='store_true',
- env_name='GYP_PARALLEL',
- help='Use multiprocessing for speed (experimental)')
parser.add_option('--toplevel-dir', dest='toplevel_dir', action='store',
default=None, metavar='DIR', type='path',
help='directory to use as the root of the source tree')
- parser.add_option('--build', dest='configs', action='append',
- help='configuration for build after project generation')
# --no-circular-check disables the check for circular relationships between
# .gyp files. These relationships should not exist, but they've only been
# observed to be harmful with the Xcode generator. Chromium's .gyp files
@@ -375,9 +374,6 @@ def gyp_main(args):
if g_o:
options.generator_output = g_o
- if not options.parallel and options.use_environment:
- options.parallel = bool(os.environ.get('GYP_PARALLEL'))
-
for mode in options.debug:
gyp.debug[mode] = 1
@@ -488,8 +484,7 @@ def gyp_main(args):
'cwd': os.getcwd(),
'build_files_arg': build_files_arg,
'gyp_binary': sys.argv[0],
- 'home_dot_gyp': home_dot_gyp,
- 'parallel': options.parallel}
+ 'home_dot_gyp': home_dot_gyp}
# Start with the default variables from the command line.
[generator, flat_list, targets, data] = Load(build_files, format,
@@ -507,13 +502,6 @@ def gyp_main(args):
# generate targets in the order specified in flat_list.
generator.GenerateOutput(flat_list, targets, data, params)
- if options.configs:
- valid_configs = targets[flat_list[0]]['configurations'].keys()
- for conf in options.configs:
- if conf not in valid_configs:
- raise GypError('Invalid config specified via --build: %s' % conf)
- generator.PerformBuild(data, options.configs, params)
-
# Done
return 0
@@ -27,13 +27,6 @@ def __call__(self, *args):
return result
-class GypError(Exception):
- """Error class representing an error, which is to be presented
- to the user. The main entry point will catch and display this.
- """
- pass
-
-
def ExceptionAppend(e, msg):
"""Append a message to the given exception's message."""
if not e.args:
@@ -368,18 +361,13 @@ def GetFlavor(params):
'cygwin': 'win',
'win32': 'win',
'darwin': 'mac',
+ 'sunos5': 'solaris',
+ 'freebsd7': 'freebsd',
+ 'freebsd8': 'freebsd',
+ 'freebsd9': 'freebsd',
}
-
- if 'flavor' in params:
- return params['flavor']
- if sys.platform in flavors:
- return flavors[sys.platform]
- if sys.platform.startswith('sunos'):
- return 'solaris'
- if sys.platform.startswith('freebsd'):
- return 'freebsd'
-
- return 'linux'
+ flavor = flavors.get(sys.platform, 'linux')
+ return params.get('flavor', flavor)
def CopyTool(flavor, out_path):
Oops, something went wrong.

0 comments on commit 7a7a5dc

Please sign in to comment.