blob: 1f7ff0fe4999bd03604a296faed551fc42939f43 [file] [log] [blame]
rspangler@google.com49fdf182009-10-10 00:57:34 +00001# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
adlr@google.comc98a7ed2009-12-04 18:54:03 +00005# Protobuffer compilation
6""" Inputs:
7 target: list of targets to compile to
8 source: list of sources to compile
9 env: the scons environment in which we are compiling
10 Outputs:
11 target: the list of targets we'll emit
12 source: the list of sources we'll compile"""
13def ProtocolBufferEmitter(target, source, env):
14 output = str(source[0])
15 output = output[0:output.rfind('.proto')]
16 target = [
17 output + '.pb.cc',
18 output + '.pb.h',
19 ]
20 return target, source
21
22""" Inputs:
23 source: list of sources to process
24 target: list of targets to generate
25 env: scons environment in which we are working
26 for_signature: unused
27 Outputs: a list of commands to execute to generate the targets from
28 the sources."""
29def ProtocolBufferGenerator(source, target, env, for_signature):
30 commands = [
31 '/usr/bin/protoc '
32 ' --proto_path . ${SOURCES} --cpp_out .']
33 return commands
34
35proto_builder = Builder(generator = ProtocolBufferGenerator,
36 emitter = ProtocolBufferEmitter,
37 single_source = 1,
38 suffix = '.pb.cc')
39
rspangler@google.com49fdf182009-10-10 00:57:34 +000040env = Environment()
adlr@google.comc98a7ed2009-12-04 18:54:03 +000041env['CCFLAGS'] = ' '.join("""-g
42 -fno-exceptions
43 -Wall
44 -Werror
45 -Wclobbered
46 -Wempty-body
47 -Wignored-qualifiers
48 -Wmissing-field-initializers
49 -Wsign-compare
50 -Wtype-limits
51 -Wuninitialized
52 -D_FILE_OFFSET_BITS=64
53 -I/usr/include/libxml2""".split());
54
55env['LIBS'] = Split("""base
56 curl
57 gflags
58 glib-2.0
59 gtest
60 gthread-2.0
61 libpcrecpp
62 protobuf
63 pthread
64 ssl
65 xml2
66 z""")
67env['CPPPATH'] = ['..', '../../third_party/chrome/files', '../../common']
68env['LIBPATH'] = ['../../third_party/chrome']
69env['BUILDERS']['ProtocolBuffer'] = proto_builder
Colin Watsonf2c29ec2010-01-08 18:50:56 +000070
71# Fix issue with scons not passing pkg-config vars through the environment.
72for key in Split('PKG_CONFIG_LIBDIR PKG_CONFIG_PATH'):
73 if os.environ.has_key(key):
74 env['ENV'][key] = os.environ[key]
75
rspangler@google.com49fdf182009-10-10 00:57:34 +000076env.ParseConfig('pkg-config --cflags --libs glib-2.0')
adlr@google.comc98a7ed2009-12-04 18:54:03 +000077env.ProtocolBuffer('update_metadata.pb.cc', 'update_metadata.proto')
rspangler@google.com49fdf182009-10-10 00:57:34 +000078
79if ARGUMENTS.get('debug', 0):
80 env['CCFLAGS'] += ' -fprofile-arcs -ftest-coverage'
81 env['LIBS'] += ['gcov']
82
adlr@google.comc98a7ed2009-12-04 18:54:03 +000083
84
rspangler@google.com49fdf182009-10-10 00:57:34 +000085sources = Split("""action_processor.cc
86 decompressing_file_writer.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +000087 delta_diff_parser.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +000088 download_action.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +000089 filesystem_copier_action.cc
90 filesystem_iterator.cc
91 file_writer.cc
92 gzip.cc
93 install_action.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +000094 libcurl_http_fetcher.cc
95 omaha_hash_calculator.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +000096 omaha_request_prep_action.cc
97 omaha_response_handler_action.cc
98 postinstall_runner_action.cc
99 set_bootable_flag_action.cc
100 subprocess.cc
101 update_check_action.cc
102 update_metadata.pb.cc
103 utils.cc""")
rspangler@google.com49fdf182009-10-10 00:57:34 +0000104main = ['main.cc']
105
106unittest_sources = Split("""action_unittest.cc
107 action_pipe_unittest.cc
108 action_processor_unittest.cc
109 decompressing_file_writer_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000110 delta_diff_generator_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000111 download_action_unittest.cc
112 file_writer_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000113 filesystem_copier_action_unittest.cc
114 filesystem_iterator_unittest.cc
115 gzip_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000116 http_fetcher_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000117 install_action_unittest.cc
118 integration_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000119 mock_http_fetcher.cc
120 omaha_hash_calculator_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000121 omaha_request_prep_action_unittest.cc
122 omaha_response_handler_action_unittest.cc
123 postinstall_runner_action_unittest.cc
124 set_bootable_flag_action_unittest.cc
125 subprocess_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000126 test_utils.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000127 update_check_action_unittest.cc
128 utils_unittest.cc""")
rspangler@google.com49fdf182009-10-10 00:57:34 +0000129unittest_main = ['testrunner.cc']
130
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000131delta_generator_sources = Split("""delta_diff_generator.cc""")
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -0800132delta_generator_main = ['generate_delta_main.cc']
133
134test_installer_main = ['test_installer_main.cc']
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000135
rspangler@google.com49fdf182009-10-10 00:57:34 +0000136env.Program('update_engine', sources + main)
137unittest_cmd = env.Program('update_engine_unittests',
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000138 sources + delta_generator_sources +
139 unittest_sources + unittest_main)
rspangler@google.com49fdf182009-10-10 00:57:34 +0000140
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -0800141test_installer_cmd = env.Program('test_installer',
142 sources + delta_generator_sources +
143 unittest_sources + test_installer_main)
144
rspangler@google.com49fdf182009-10-10 00:57:34 +0000145Clean(unittest_cmd, Glob('*.gcda') + Glob('*.gcno') + Glob('*.gcov') +
146 Split('html app.info'))
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000147
148delta_generator_cmd = env.Program('delta_generator',
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -0800149 sources + delta_generator_sources +
150 delta_generator_main)
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000151
152http_server_cmd = env.Program('test_http_server', 'test_http_server.cc')