drewry@google.com | bd940e9 | 2009-12-07 19:13:27 +0000 | [diff] [blame] | 1 | # -*- python -*- |
| 2 | |
| 3 | # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
Will Drewry | b551847 | 2009-12-10 12:31:47 -0800 | [diff] [blame] | 7 | import glob |
drewry@google.com | bd940e9 | 2009-12-07 19:13:27 +0000 | [diff] [blame] | 8 | import os |
| 9 | |
| 10 | env = Environment() |
| 11 | |
| 12 | lib_sources = env.Split("""env.cc |
| 13 | interface.cc |
| 14 | minijail.cc |
| 15 | options.cc""") |
| 16 | bin_sources = env.Split("""minijail_main.cc""") |
| 17 | test_sources = env.Split("""minijail_unittest.cc |
Will Drewry | 4dd0e66 | 2010-01-19 14:43:50 -0800 | [diff] [blame] | 18 | options_unittest.cc |
drewry@google.com | bd940e9 | 2009-12-07 19:13:27 +0000 | [diff] [blame] | 19 | minijail_testrunner.cc""") |
Will Drewry | b551847 | 2009-12-10 12:31:47 -0800 | [diff] [blame] | 20 | benchmark_sources = glob.glob("*_microbenchmark.cc") |
drewry@google.com | bd940e9 | 2009-12-07 19:13:27 +0000 | [diff] [blame] | 21 | |
| 22 | env.Append( |
| 23 | CPPPATH=['..', '../../third_party/chrome/files', '../../common'], |
Chris Masone | 6b58896 | 2010-02-10 18:14:00 -0800 | [diff] [blame^] | 24 | CCFLAGS=['-g'], |
drewry@google.com | bd940e9 | 2009-12-07 19:13:27 +0000 | [diff] [blame] | 25 | LIBPATH=['../../third_party/chrome'], |
| 26 | LIBS=['cap', 'base', 'pthread', 'rt'], |
| 27 | ) |
Colin Watson | 3daf602 | 2010-01-07 17:38:39 +0000 | [diff] [blame] | 28 | for key in Split('CC CXX AR RANLIB LD NM CFLAGS CCFLAGS'): |
| 29 | value = os.environ.get(key) |
| 30 | if value != None: |
Chris Masone | 6b58896 | 2010-02-10 18:14:00 -0800 | [diff] [blame^] | 31 | env[key] = Split(value) |
| 32 | env['CCFLAGS'] += ['-fno-exceptions', '-Wall', '-Werror'] |
| 33 | |
| 34 | # Fix issue with scons not passing some vars through the environment. |
| 35 | for key in Split('PKG_CONFIG_LIBDIR PKG_CONFIG_PATH SYSROOT'): |
| 36 | if os.environ.has_key(key): |
| 37 | env['ENV'][key] = os.environ[key] |
drewry@google.com | bd940e9 | 2009-12-07 19:13:27 +0000 | [diff] [blame] | 38 | |
| 39 | env_lib = env.Clone() |
| 40 | env_lib.SharedLibrary('minijail', lib_sources) |
| 41 | |
| 42 | env_bin = env.Clone() |
| 43 | env_bin.Program('minijail', lib_sources + bin_sources) |
| 44 | |
| 45 | env_test = env.Clone() |
Will Drewry | 4dd0e66 | 2010-01-19 14:43:50 -0800 | [diff] [blame] | 46 | env_test.Append(LIBS=['gtest', 'gmock']) |
drewry@google.com | bd940e9 | 2009-12-07 19:13:27 +0000 | [diff] [blame] | 47 | env_test.Program('minijail_unittests', lib_sources + test_sources) |
Will Drewry | b551847 | 2009-12-10 12:31:47 -0800 | [diff] [blame] | 48 | |
| 49 | env_benchmarks = env.Clone() |
| 50 | # Note, LIBS needs to have: 'gtest', 'base', 'rt', 'pthread' |
| 51 | env_benchmarks.Append(LIBS=['microbenchmark_main.a', |
| 52 | # Since we want to run this on a prod image, |
| 53 | # we just statically pull in gtest.a. |
Will Drewry | 4dd0e66 | 2010-01-19 14:43:50 -0800 | [diff] [blame] | 54 | File('/usr/lib/libgtest.a')]) |
Will Drewry | b551847 | 2009-12-10 12:31:47 -0800 | [diff] [blame] | 55 | env_benchmarks.Program('minijail_benchmarks', benchmark_sources) |