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

Side by Side Diff: native_client_sdk/src/libraries/gtest/build.scons

Issue 10824092: [NaCl SDK] Build gtest on buildbots, but don't include it in the SDK. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to HEAD Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # -*- python -*-
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import build_utils
7 import glob
8 import os
9 import shutil
10 import subprocess
11 import sys
12
13 from SCons import Script
14
15 # Directories used throughout this script.
16 script_dir = os.path.abspath(os.getcwd())
17 sdk_root_dir = os.getenv('NACL_SDK_ROOT')
18 build_tools_dir = os.path.join(sdk_root_dir, 'build_tools')
19 libraries_dir = os.path.join(sdk_root_dir, 'libraries')
20
21 # Add the path to build_tools to the shell's python path.
22 shell_env = os.environ.copy()
23 python_paths = [build_tools_dir]
24 python_paths += [shell_env.get('PYTHONPATH', '')]
25 shell_env['PYTHONPATH'] = os.pathsep.join(python_paths)
26
27 # Argv for the install-gtest python script.
28 script_argv = [
29 '--toolchain=%s' % (
30 build_utils.NormalizeToolchain(base_dir=sdk_root_dir,
31 arch='x86',
32 variant='glibc')),
33 '--toolchain=%s' % (
34 build_utils.NormalizeToolchain(base_dir=sdk_root_dir,
35 arch='x86',
36 variant='newlib')),
37 '--working_dir=%s' % script_dir
38 ]
39
40 # The scons build env.
41 build_env = Script.Environment().Clone()
42
43 # Where the src for gtest and gmock will be found after running the install
44 # script. We keep them around as a sentinel, to indicate they they have been
45 # installed. (See BuildGTestLibs below.)
46 gtest_src = os.path.join(script_dir, 'gtest-1.5.0')
47 gmock_src = os.path.join(script_dir, 'gmock-1.5.0')
48
49
50 def BuildGTestLibs(env, target, source):
51 '''Build and install the gtest/gmock libraries.
52
53 This invokes the gtest_install.py script in the build_tools directory. In turn
54 that scripts downloads, untar, patches and build the gtest/gmock libraries.
55 Finally, the libraries and related include files are copied to the toolchain.
56
57 Args:
58 env: The construction Environment() that is building the examples.
59 target: The target that triggered this build. Not used.
60 source: The sources used for this build. Not used.
61 '''
62 # If our sentinel, the gtest source is present, do not build.
63 if os.path.exists(gtest_src):
64 return
65 # Remove any old gmock source if still present.
66 shutil.rmtree(gmock_src, ignore_errors=True)
67 # Invoke the gtest install script.
68 script = os.path.join(build_tools_dir, 'install_gtest', 'install_gtest.py')
69 py_command = [sys.executable, script]
70 subprocess.check_call(py_command + script_argv, env=shell_env)
71
72 # Clean up: remove left-over tgz files.
73 for f in glob.iglob(os.path.join(script_dir, '*.tgz')):
74 os.remove(f)
75
76
77 def CleanGTestLibs(env, target, suite_name):
78 '''Clean the gtest/gmock libraries sources.
79
80 This does a partial clean up of the gtest/gmock projects. It removes the src
81 directories. However, the actual libraries and related includes in the
82 toolchains are not removed. It is however sufficient to trigger a full
83 rebuild of gtest/gmock.
84
85 Args:
86 env: The construction Environment() that is building the examples.
87 target: The target that triggered this build.
88 suite_name: A suite name that should cause this target to be cleaned.
89 '''
90 # Only do this in 'clean' mode.
91 if not build_env.GetOption('clean'):
92 return
93 # Only clean target if it's on the cmd line or it's a clean all.
94 clean_this = True
95 if len(COMMAND_LINE_TARGETS) > 0:
96 clean_this = False
97 for cl_target in COMMAND_LINE_TARGETS:
98 if cl_target == suite_name or cl_target == target:
99 clean_this = True
100 break
101 # Delete the src trees for gtest and gmock.
102 if clean_this:
103 shutil.rmtree(gmock_src, ignore_errors=True)
104 shutil.rmtree(gtest_src, ignore_errors=True)
105
106
107 gtest_libs_builder = build_env.Alias('gtest_libs', [], BuildGTestLibs)
108 build_env.AlwaysBuild(gtest_libs_builder)
109 CleanGTestLibs(build_env, 'gtest_libs', 'bot')
110
111 # ----------------------------------------------------------------------------
112 build_env.Default('gtest_libs')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698