From 7dafd4189fa4d8cef92f8f88fba73615b4f15a0e Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 27 Jan 2011 02:21:50 +0000 Subject: [PATCH] Move gclient integration to the gclient_hook.py script in order to support a platform-agnostic DEPS file (issue #174). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@171 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- DEPS | 2 +- cef_create_projects.bat | 12 +-------- cef_create_projects.sh | 6 +---- tools/gclient_hook.py | 60 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 tools/gclient_hook.py diff --git a/DEPS b/DEPS index 6d16a0cec..0a7dc22e3 100644 --- a/DEPS +++ b/DEPS @@ -2,6 +2,6 @@ hooks = [ { # A change to a .gyp, .gypi, or to GYP itself should run the generator. "pattern": ".", - "action": ["cd", "src\cef", "&", "call", "cef_create_projects.bat", "&", "cd", "..\.."], + "action": ["python", "src/cef/tools/gclient_hook.py"], }, ] diff --git a/cef_create_projects.bat b/cef_create_projects.bat index fc18cf092..9392c34f8 100644 --- a/cef_create_projects.bat +++ b/cef_create_projects.bat @@ -1,12 +1,2 @@ @echo off -ECHO Patching build configuration files... -CALL tools\patch_build.bat -ECHO Generating project files... -CALL :SET_ENV %CD% -:GEN_PROJ -CALL ..\tools\gyp\gyp.bat cef.gyp -I ..\build\common.gypi -I ..\build\features_override.gypi -I cef.gypi --no-circular-check -GOTO :END -:SET_ENV -SET CEF_DIRECTORY=%~n1 -GOTO :GEN_PROJ -:END \ No newline at end of file +..\third_party\python_26\python.exe tools\gclient_hook.py diff --git a/cef_create_projects.sh b/cef_create_projects.sh index 67a48c312..a9c94cd92 100755 --- a/cef_create_projects.sh +++ b/cef_create_projects.sh @@ -1,6 +1,2 @@ #!/bin/sh -echo Patching build configuration files... -tools/patch_build.sh -echo Generating project files... -export CEF_DIRECTORY=$(basename `pwd`) -../tools/gyp/gyp cef.gyp -I ../build/common.gypi -I ../build/features_override.gypi -I cef.gypi --no-circular-check +python tools/gclient_hook.py diff --git a/tools/gclient_hook.py b/tools/gclient_hook.py new file mode 100644 index 000000000..47fa06d6d --- /dev/null +++ b/tools/gclient_hook.py @@ -0,0 +1,60 @@ +# Copyright (c) 2011 The Chromium Embedded Framework Authors. +# Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os, sys + +# The CEF root directory is the parent directory of _this_ script. +cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) + +try: + # depot_tools may already be in the import path. + import gclient_utils +except ImportError, e: + # Search the PATH environment variable to find the depot_tools folder. + depot_tools = None; + paths = os.environ.get('PATH').split(os.pathsep) + for path in paths: + if os.path.exists(os.path.join(path, 'gclient_utils.py')): + depot_tools = path + break + + if depot_tools is None: + print >> sys.stderr, 'Error: could not find depot_tools in PATH.' + sys.exit(2) + + # Add depot_tools to import path. + sys.path.append(depot_tools) + import gclient_utils + +# Copied from gclient.py python code. +def RunAction(dir, command): + """Runs the action.""" + if command[0] == 'python': + # If the hook specified "python" as the first item, the action is a + # Python script. Run it by starting a new copy of the same + # interpreter. + command[0] = sys.executable + + try: + gclient_utils.CheckCallAndFilterAndHeader( + command, cwd=dir, always=True) + except gclient_utils.Error, e: + # Use a discrete exit status code of 2 to indicate that a hook action + # failed. Users of this script may wish to treat hook action failures + # differently from VC failures. + print >> sys.stderr, 'Error: %s' % str(e) + sys.exit(2) + +print "\nPatching build configuration files for CEF..." +patcher = [ 'python', 'tools/patcher.py', + '--patch-config', 'patch/patch_build.cfg' ]; +RunAction(cef_dir, patcher); + +print "\nGenerating CEF project files..." +os.environ['CEF_DIRECTORY'] = os.path.basename(cef_dir); +gyper = [ 'python', '../tools/gyp/gyp', 'cef.gyp', '-I', '../build/common.gypi', + '-I', '../build/features_override.gypi', '-I', 'cef.gypi', + '--no-circular-check' ] +RunAction(cef_dir, gyper);