blob: dc32ec3eb26792c7b8e88315c5e6bda5edffbabf [file] [log] [blame]
drewry@google.combd940e92009-12-07 19:13:27 +00001# -*- 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 Drewryb5518472009-12-10 12:31:47 -08007import glob
drewry@google.combd940e92009-12-07 19:13:27 +00008import os
9
10env = Environment()
11
12lib_sources = env.Split("""env.cc
13 interface.cc
14 minijail.cc
15 options.cc""")
16bin_sources = env.Split("""minijail_main.cc""")
17test_sources = env.Split("""minijail_unittest.cc
Will Drewry4dd0e662010-01-19 14:43:50 -080018 options_unittest.cc
drewry@google.combd940e92009-12-07 19:13:27 +000019 minijail_testrunner.cc""")
Will Drewryb5518472009-12-10 12:31:47 -080020benchmark_sources = glob.glob("*_microbenchmark.cc")
drewry@google.combd940e92009-12-07 19:13:27 +000021
22env.Append(
23 CPPPATH=['..', '../../third_party/chrome/files', '../../common'],
Chris Masone6b588962010-02-10 18:14:00 -080024 CCFLAGS=['-g'],
drewry@google.combd940e92009-12-07 19:13:27 +000025 LIBPATH=['../../third_party/chrome'],
26 LIBS=['cap', 'base', 'pthread', 'rt'],
27)
Colin Watson3daf6022010-01-07 17:38:39 +000028for key in Split('CC CXX AR RANLIB LD NM CFLAGS CCFLAGS'):
29 value = os.environ.get(key)
30 if value != None:
Chris Masone6b588962010-02-10 18:14:00 -080031 env[key] = Split(value)
32env['CCFLAGS'] += ['-fno-exceptions', '-Wall', '-Werror']
33
34# Fix issue with scons not passing some vars through the environment.
35for 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.combd940e92009-12-07 19:13:27 +000038
39env_lib = env.Clone()
40env_lib.SharedLibrary('minijail', lib_sources)
41
42env_bin = env.Clone()
43env_bin.Program('minijail', lib_sources + bin_sources)
44
45env_test = env.Clone()
Will Drewry4dd0e662010-01-19 14:43:50 -080046env_test.Append(LIBS=['gtest', 'gmock'])
drewry@google.combd940e92009-12-07 19:13:27 +000047env_test.Program('minijail_unittests', lib_sources + test_sources)
Will Drewryb5518472009-12-10 12:31:47 -080048
49env_benchmarks = env.Clone()
50# Note, LIBS needs to have: 'gtest', 'base', 'rt', 'pthread'
51env_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 Drewry4dd0e662010-01-19 14:43:50 -080054 File('/usr/lib/libgtest.a')])
Will Drewryb5518472009-12-10 12:31:47 -080055env_benchmarks.Program('minijail_benchmarks', benchmark_sources)