Permalink
Browse files

Bring gyp into the tools directory; handwritten makefile

  • Loading branch information...
1 parent 466cbfe commit bef9f56cacffe3a55d9154e304a57ad8de607c5a @ry ry committed Aug 5, 2011
Showing with 18,555 additions and 34 deletions.
  1. +5 −6 .gitignore
  2. +3 −0 LICENSE
  3. +12 −0 Makefile
  4. +0 −28 gyp/gyp_node
  5. 0 {gyp → tools}/all.gyp
  6. +6 −0 tools/gyp/AUTHORS
  7. +8 −0 tools/gyp/DEPS
  8. +27 −0 tools/gyp/LICENSE
  9. +10 −0 tools/gyp/codereview.settings
  10. +7 −0 tools/gyp/gyp_dummy.c
  11. +256 −0 tools/gyp/gyptest.py
  12. +341 −0 tools/gyp/pylib/gyp/MSVSNew.py
  13. +245 −0 tools/gyp/pylib/gyp/MSVSProject.py
  14. +1,033 −0 tools/gyp/pylib/gyp/MSVSSettings.py
  15. +1,480 −0 tools/gyp/pylib/gyp/MSVSSettings_test.py
  16. +81 −0 tools/gyp/pylib/gyp/MSVSToolFile.py
  17. +182 −0 tools/gyp/pylib/gyp/MSVSUserFile.py
  18. +262 −0 tools/gyp/pylib/gyp/MSVSVersion.py
  19. +200 −0 tools/gyp/pylib/gyp/SCons.py
  20. +479 −0 tools/gyp/pylib/gyp/__init__.py
  21. +362 −0 tools/gyp/pylib/gyp/common.py
  22. +121 −0 tools/gyp/pylib/gyp/easy_xml.py
  23. +92 −0 tools/gyp/pylib/gyp/easy_xml_test.py
  24. 0 tools/gyp/pylib/gyp/generator/__init__.py
  25. +56 −0 tools/gyp/pylib/gyp/generator/dump_dependency_json.py
  26. +88 −0 tools/gyp/pylib/gyp/generator/gypd.py
  27. +57 −0 tools/gyp/pylib/gyp/generator/gypsh.py
  28. +2,454 −0 tools/gyp/pylib/gyp/generator/make.py
  29. +2,852 −0 tools/gyp/pylib/gyp/generator/msvs.py
  30. +1,045 −0 tools/gyp/pylib/gyp/generator/scons.py
  31. +1,204 −0 tools/gyp/pylib/gyp/generator/xcode.py
  32. +2,348 −0 tools/gyp/pylib/gyp/input.py
  33. +187 −0 tools/gyp/pylib/gyp/mac_tool.py
  34. +77 −0 tools/gyp/pylib/gyp/system_test.py
  35. +2,840 −0 tools/gyp/pylib/gyp/xcodeproj_file.py
  36. +70 −0 tools/gyp/pylib/gyp/xml_fix.py
  37. +26 −0 tools/gyp/setup.py
  38. +39 −0 tools/gyp_node
View
@@ -13,10 +13,9 @@ node_g
/.cproject
gyp-mac-tool
-gyp/gyp
-gyp/all.Makefile
-gyp/all.target.mk
-gyp/node_js2c.host.mk
-gyp/node_js2c.target.mk
+tools/gyp
+tools/all.Makefile
+tools/all.target.mk
+tools/node_js2c.host.mk
+tools/node_js2c.target.mk
out/
-Makefile
View
@@ -79,3 +79,6 @@ The externally maintained libraries used by Node are:
http://sourceware.org/pthreads-win32/ It is Copyright 1998 John E.
Bossom and 1999,2006 Pthreads-win32 contributors and licensed under the
LGPL. See deps/pthread-win32/COPYING.LIB for more details.
+
+ - tools/gyp GYP is a meta-build system copyright 2009 Google Inc and
+ licensed under the three clause BSD license. See tools/gyp/LICENSE.
View
@@ -0,0 +1,12 @@
+BUILDTYPE ?= Debug
+
+all: out/Makefile
+ $(MAKE) -C out BUILDTYPE=$(BUILDTYPE)
+
+out/Makefile:
+ tools/gyp_node -f make
+
+distclean:
+ rm -rf out
+
+.PHONY: all distclean
View
@@ -1,28 +0,0 @@
-#!/usr/bin/python
-import glob
-import os
-import shlex
-import sys
-
-script_dir = os.path.dirname(__file__)
-node_root = os.path.normpath(os.path.join(script_dir, os.pardir))
-
-sys.path.insert(0, os.path.join(node_root, 'gyp', 'gyp', 'pylib'))
-import gyp
-
-
-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(script_dir, 'all.gyp'))
- args.append('--depth=' + node_root)
- args.append('-Dtarget_arch=x64')
- args.append('-Dcomponent=static_library')
- args.append('-Dlibrary=static_library')
- gyp_args = list(args)
- run_gyp(gyp_args)
File renamed without changes.
View
@@ -0,0 +1,6 @@
+# Names should be added to this file like so:
+# Name or Organization <email address>
+
+Google Inc.
+Steven Knight <knight@baldmt.com>
+Ryan Norton <rnorton10@gmail.com>
View
@@ -0,0 +1,8 @@
+# DEPS file for gclient use in buildbot execution of gyp tests.
+#
+# (You don't need to use gclient for normal GYP development work.)
+
+deps = {
+ "scons":
+ "http://src.chromium.org/svn/trunk/src/third_party/scons@44099",
+}
View
@@ -0,0 +1,27 @@
+Copyright (c) 2009 Google Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,10 @@
+# This file is used by gcl to get repository specific information.
+CODE_REVIEW_SERVER: codereview.chromium.org
+CC_LIST: gyp-developer@googlegroups.com
+VIEW_VC: http://code.google.com/p/gyp/source/detail?r=
+TRY_ON_UPLOAD: True
+TRYSERVER_PROJECT: gyp
+TRYSERVER_PATCHLEVEL: 0
+TRYSERVER_ROOT: trunk
+TRYSERVER_SVN_URL: svn://svn.chromium.org/chrome-try/try-nacl
+
View
@@ -0,0 +1,7 @@
+/* Copyright (c) 2009 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. */
+
+int main() {
+ return 0;
+}
View
@@ -0,0 +1,256 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2011 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.
+
+__doc__ = """
+gyptest.py -- test runner for GYP tests.
+"""
+
+import os
+import optparse
+import subprocess
+import sys
+
+class CommandRunner:
+ """
+ Executor class for commands, including "commands" implemented by
+ Python functions.
+ """
+ verbose = True
+ active = True
+
+ def __init__(self, dictionary={}):
+ self.subst_dictionary(dictionary)
+
+ def subst_dictionary(self, dictionary):
+ self._subst_dictionary = dictionary
+
+ def subst(self, string, dictionary=None):
+ """
+ Substitutes (via the format operator) the values in the specified
+ dictionary into the specified command.
+
+ The command can be an (action, string) tuple. In all cases, we
+ perform substitution on strings and don't worry if something isn't
+ a string. (It's probably a Python function to be executed.)
+ """
+ if dictionary is None:
+ dictionary = self._subst_dictionary
+ if dictionary:
+ try:
+ string = string % dictionary
+ except TypeError:
+ pass
+ return string
+
+ def display(self, command, stdout=None, stderr=None):
+ if not self.verbose:
+ return
+ if type(command) == type(()):
+ func = command[0]
+ args = command[1:]
+ s = '%s(%s)' % (func.__name__, ', '.join(map(repr, args)))
+ if type(command) == type([]):
+ # TODO: quote arguments containing spaces
+ # TODO: handle meta characters?
+ s = ' '.join(command)
+ else:
+ s = self.subst(command)
+ if not s.endswith('\n'):
+ s += '\n'
+ sys.stdout.write(s)
+ sys.stdout.flush()
+
+ def execute(self, command, stdout=None, stderr=None):
+ """
+ Executes a single command.
+ """
+ if not self.active:
+ return 0
+ if type(command) == type(''):
+ command = self.subst(command)
+ cmdargs = shlex.split(command)
+ if cmdargs[0] == 'cd':
+ command = (os.chdir,) + tuple(cmdargs[1:])
+ if type(command) == type(()):
+ func = command[0]
+ args = command[1:]
+ return func(*args)
+ else:
+ if stdout is sys.stdout:
+ # Same as passing sys.stdout, except python2.4 doesn't fail on it.
+ subout = None
+ else:
+ # Open pipe for anything else so Popen works on python2.4.
+ subout = subprocess.PIPE
+ if stderr is sys.stderr:
+ # Same as passing sys.stderr, except python2.4 doesn't fail on it.
+ suberr = None
+ elif stderr is None:
+ # Merge with stdout if stderr isn't specified.
+ suberr = subprocess.STDOUT
+ else:
+ # Open pipe for anything else so Popen works on python2.4.
+ suberr = subprocess.PIPE
+ p = subprocess.Popen(command,
+ shell=(sys.platform == 'win32'),
+ stdout=subout,
+ stderr=suberr)
+ p.wait()
+ if stdout is None:
+ self.stdout = p.stdout.read()
+ elif stdout is not sys.stdout:
+ stdout.write(p.stdout.read())
+ if stderr not in (None, sys.stderr):
+ stderr.write(p.stderr.read())
+ return p.returncode
+
+ def run(self, command, display=None, stdout=None, stderr=None):
+ """
+ Runs a single command, displaying it first.
+ """
+ if display is None:
+ display = command
+ self.display(display)
+ return self.execute(command, stdout, stderr)
+
+
+class Unbuffered:
+ def __init__(self, fp):
+ self.fp = fp
+ def write(self, arg):
+ self.fp.write(arg)
+ self.fp.flush()
+ def __getattr__(self, attr):
+ return getattr(self.fp, attr)
+
+sys.stdout = Unbuffered(sys.stdout)
+sys.stderr = Unbuffered(sys.stderr)
+
+
+def find_all_gyptest_files(directory):
+ result = []
+ for root, dirs, files in os.walk(directory):
+ if '.svn' in dirs:
+ dirs.remove('.svn')
+ result.extend([ os.path.join(root, f) for f in files
+ if f.startswith('gyptest') and f.endswith('.py') ])
+ result.sort()
+ return result
+
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+
+ usage = "gyptest.py [-ahlnq] [-f formats] [test ...]"
+ parser = optparse.OptionParser(usage=usage)
+ parser.add_option("-a", "--all", action="store_true",
+ help="run all tests")
+ parser.add_option("-C", "--chdir", action="store", default=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("-l", "--list", action="store_true",
+ help="list available tests and exit")
+ parser.add_option("-n", "--no-exec", action="store_true",
+ help="no execute, just print the command line")
+ parser.add_option("--passed", action="store_true",
+ help="report passed tests")
+ parser.add_option("--path", action="append", default=[],
+ help="additional $PATH directory")
+ parser.add_option("-q", "--quiet", action="store_true",
+ help="quiet, don't print test command lines")
+ opts, args = parser.parse_args(argv[1:])
+
+ if opts.chdir:
+ os.chdir(opts.chdir)
+
+ if opts.path:
+ os.environ['PATH'] += ':' + ':'.join(opts.path)
+
+ if not args:
+ if not opts.all:
+ sys.stderr.write('Specify -a to get all tests.\n')
+ return 1
+ args = ['test']
+
+ tests = []
+ for arg in args:
+ if os.path.isdir(arg):
+ tests.extend(find_all_gyptest_files(os.path.normpath(arg)))
+ else:
+ tests.append(arg)
+
+ if opts.list:
+ for test in tests:
+ print test
+ sys.exit(0)
+
+ CommandRunner.verbose = not opts.quiet
+ CommandRunner.active = not opts.no_exec
+ cr = CommandRunner()
+
+ os.environ['PYTHONPATH'] = os.path.abspath('test/lib')
+ if not opts.quiet:
+ sys.stdout.write('PYTHONPATH=%s\n' % os.environ['PYTHONPATH'])
+
+ passed = []
+ failed = []
+ no_result = []
+
+ if opts.format:
+ format_list = opts.format.split(',')
+ else:
+ # TODO: not duplicate this mapping from pylib/gyp/__init__.py
+ format_list = {
+ 'freebsd7': ['make'],
+ 'freebsd8': ['make'],
+ 'cygwin': ['msvs'],
+ 'win32': ['msvs'],
+ 'linux2': ['make'],
+ 'linux3': ['make'],
+ 'darwin': ['make', 'xcode'],
+ }[sys.platform]
+
+ for format in format_list:
+ os.environ['TESTGYP_FORMAT'] = format
+ if not opts.quiet:
+ sys.stdout.write('TESTGYP_FORMAT=%s\n' % format)
+
+ for test in tests:
+ status = cr.run([sys.executable, test],
+ stdout=sys.stdout,
+ stderr=sys.stderr)
+ if status == 2:
+ no_result.append(test)
+ elif status:
+ failed.append(test)
+ else:
+ passed.append(test)
+
+ if not opts.quiet:
+ def report(description, tests):
+ if tests:
+ if len(tests) == 1:
+ sys.stdout.write("\n%s the following test:\n" % description)
+ else:
+ fmt = "\n%s the following %d tests:\n"
+ sys.stdout.write(fmt % (description, len(tests)))
+ sys.stdout.write("\t" + "\n\t".join(tests) + "\n")
+
+ if opts.passed:
+ report("Passed", passed)
+ report("Failed", failed)
+ report("No result from", no_result)
+
+ if failed:
+ return 1
+ else:
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
Oops, something went wrong.

0 comments on commit bef9f56

Please sign in to comment.