blob: 570578cc881a999a7cd1e1257f287aa9575182b7 [file] [log] [blame]
# Copyright (c) 2011 The Chromium OS 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
import re
import sys
def GlibMarshalEmitter(target, source, env):
""" Inputs:
target: unused
source: list containing the source .list file
env: the scons environment in which we are compiling
Outputs:
target: the list of targets we'll emit
source: the list of sources we'll process"""
output = str(source[0])
output = output[0:output.rfind('.list')]
target = [
output + '.glibmarshal.c',
output + '.glibmarshal.h'
]
return target, source
def GlibMarshalGenerator(source, target, env, for_signature):
""" Inputs:
source: list of sources to process
target: list of targets to generate
env: scons environment in which we are working
for_signature: unused
Outputs: a list of commands to execute to generate the targets from
the sources."""
commands = []
for target_file in target:
if str(target_file).endswith('.glibmarshal.h'):
mode_flag = '--header '
else:
mode_flag = '--body '
cmd = '/usr/bin/glib-genmarshal %s --prefix=marshal ' \
'%s > %s' % (mode_flag, str(source[0]), str(target_file))
commands.append(cmd)
return commands
glib_marshal_builder = Builder(generator = GlibMarshalGenerator,
emitter = GlibMarshalEmitter,
single_source = 1,
suffix = 'glibmarshal.c')
base_env = Environment()
base_env['BUILDERS']['GlibMarshal'] = glib_marshal_builder
for key in Split('CC CXX AR RANLIB LD NM CFLAGS CCFLAGS LINKFLAGS'):
value = os.environ.get(key)
if value != None:
base_env[key] = Split(value)
# Fix issue with scons not passing some vars through the environment.
for key in Split('PKG_CONFIG PKG_CONFIG_LIBDIR PKG_CONFIG_PATH SYSROOT'):
if os.environ.has_key(key):
base_env['ENV'][key] = os.environ[key]
# Append these after pulling in the stuff from the environment so they
# don't get overwritten.
base_env.Append(CPPPATH=Split('. ..'))
base_env.Append(CCFLAGS=Split('-ggdb -fPIC -fno-exceptions -Wall -Werror'))
base_env.Append(LINKFLAGS=Split('-fPIC'))
SOURCES = Split('''\
chromeos_brightness.cc
chromeos_cryptohome.cc
chromeos_imageburn.cc
chromeos_login.cc
chromeos_login_helpers.cc
chromeos_mount.cc
chromeos_network.cc
chromeos_network_deprecated.cc
chromeos_power.cc
chromeos_resume.cc
chromeos_screen_lock.cc
chromeos_speech_synthesis.cc
chromeos_update_engine.cc
marshal.glibmarshal.c
version_check.cc
''')
env = base_env.Clone()
env.Append(LIBS=['chromeos', 'base', 'rt'])
# glib and dbus environment
env.ParseConfig('%s --cflags --libs dbus-1 glib-2.0 dbus-glib-1 '
'libpcrecpp x11' % env['ENV']['PKG_CONFIG'])
env.GlibMarshal('marshal.glibmarshal.c', 'marshal.list')
# test_libbase_ndebug is built to catch NDEBUG mismatches between this
# library and libbase. It is not installed.
Default(env.SharedLibrary('cros', SOURCES),
env.Program('test_libbase_ndebug', 'test_libbase_ndebug.cc'))
env_test = base_env.Clone()
env_test.Append(LIBS=['base', 'dl', 'rt', 'nss3'])
env_test.ParseConfig('%s --cflags --libs gobject-2.0 dbus-glib-1 dbus-1 nss '
% (env_test['ENV']['PKG_CONFIG']))
env_test.Append(CCFLAGS=['-DOS_CHROMEOS'])
env_gtest = env_test.Clone()
env_gtest.Append(LIBS=['gtest'])
env_gtest_main = env_test.Clone()
env_gtest_main.Append(LIBS=['gtest', 'gtest_main', 'chromeos', 'base'])
env_gtest_main.ParseConfig('%s --cflags --libs libpcrecpp x11' % (
env_test['ENV']['PKG_CONFIG']))
env_network_monitor = env_test.Clone()
env_network_monitor.Append(LIBS=['dbus-glib-1'])
env_load = base_env.Clone()
env_load.ParseConfig('%s --cflags --libs dbus-glib-1' % env['ENV']['PKG_CONFIG'])
Load = env_load.Object('load.cc')
# Tests that do not require libcros.so. The ebuild script for libcros
# automatically builds and runs the tests (libcros_unittests) if FEATURES="test"
# is set.
unittests = [
env_gtest_main.Program('libcros_unittests',
['chromeos_login.cc',
'chromeos_login_helpers.cc']),
]
unittest_alias = Alias('unittest', unittests)
AlwaysBuild(unittest_alias)
# Tests that do require libcros.so.
tests = [
env_network_monitor.Program('monitor_sms', ['monitor_sms.cc', Load]),
env_test.Program('monitor_mount', ['monitor_mount.cc', Load]),
# The following manual testing tools don't compile as they use deprecated
# APIs. We should fix them if we want to keep them. Otherwise, we should
# remove them. crosbug.com/20648
#
# env_network_monitor.Program('monitor_network', ['monitor_network.cc', Load]),
# env_test.Program('cryptohome_drive', ['drive_cryptohome.cc', Load]),
# env_test.Program('monitor_power', ['monitor_power.cc', Load]),
# env_test.Program('monitor_update_engine', ['monitor_update_engine.cc', Load]),
# env_test.Program('network_property_test', ['network_property_test.cc', Load]),
# env_test.Program('simlock_test', ['simlock_test.cc', Load]),
]
test_alias = Alias('test', tests)
AlwaysBuild(test_alias)
Alias('crosapi', env_load.StaticLibrary('crosapi', Load), CCFLAGS='-ggdb')