blob: d0f2d6d7fa2f4a8e619a2ab10f5b9a273abbbe0f [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'],
Chris Masone7b634ba2010-08-12 10:41:16 -070026 LIBS=['cap', 'glib-2.0', 'base', 'pthread', 'rt'],
drewry@google.combd940e92009-12-07 19:13:27 +000027)
Chris Masone7b634ba2010-08-12 10:41:16 -070028# glib-2.0 is only required by libbase
29
Colin Watson3daf6022010-01-07 17:38:39 +000030for key in Split('CC CXX AR RANLIB LD NM CFLAGS CCFLAGS'):
31 value = os.environ.get(key)
32 if value != None:
Chris Masone6b588962010-02-10 18:14:00 -080033 env[key] = Split(value)
34env['CCFLAGS'] += ['-fno-exceptions', '-Wall', '-Werror']
35
36# Fix issue with scons not passing some vars through the environment.
Chris Masone7b634ba2010-08-12 10:41:16 -070037for key in Split('PKG_CONFIG SYSROOT'):
Chris Masone6b588962010-02-10 18:14:00 -080038 if os.environ.has_key(key):
39 env['ENV'][key] = os.environ[key]
drewry@google.combd940e92009-12-07 19:13:27 +000040
Chris Masone7b634ba2010-08-12 10:41:16 -070041env.ParseConfig('%s --cflags --libs glib-2.0' % env['ENV']['PKG_CONFIG'])
42
drewry@google.combd940e92009-12-07 19:13:27 +000043env_lib = env.Clone()
44env_lib.SharedLibrary('minijail', lib_sources)
45
46env_bin = env.Clone()
47env_bin.Program('minijail', lib_sources + bin_sources)
48
49env_test = env.Clone()
Will Drewry4dd0e662010-01-19 14:43:50 -080050env_test.Append(LIBS=['gtest', 'gmock'])
drewry@google.combd940e92009-12-07 19:13:27 +000051env_test.Program('minijail_unittests', lib_sources + test_sources)
Will Drewryb5518472009-12-10 12:31:47 -080052
53env_benchmarks = env.Clone()
54# Note, LIBS needs to have: 'gtest', 'base', 'rt', 'pthread'
55env_benchmarks.Append(LIBS=['microbenchmark_main.a',
56 # Since we want to run this on a prod image,
57 # we just statically pull in gtest.a.
Will Drewry4dd0e662010-01-19 14:43:50 -080058 File('/usr/lib/libgtest.a')])
Will Drewryb5518472009-12-10 12:31:47 -080059env_benchmarks.Program('minijail_benchmarks', benchmark_sources)