blob: d408cb747ab5646d625c7146635e1c3a9a82bfd0 [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
Andrew de los Reyes1e338b82010-01-22 14:57:27 -08005import os
6
adlr@google.comc98a7ed2009-12-04 18:54:03 +00007# Protobuffer compilation
8""" Inputs:
9 target: list of targets to compile to
10 source: list of sources to compile
11 env: the scons environment in which we are compiling
12 Outputs:
13 target: the list of targets we'll emit
14 source: the list of sources we'll compile"""
15def ProtocolBufferEmitter(target, source, env):
16 output = str(source[0])
17 output = output[0:output.rfind('.proto')]
18 target = [
19 output + '.pb.cc',
20 output + '.pb.h',
21 ]
22 return target, source
23
24""" Inputs:
25 source: list of sources to process
26 target: list of targets to generate
27 env: scons environment in which we are working
28 for_signature: unused
29 Outputs: a list of commands to execute to generate the targets from
30 the sources."""
31def ProtocolBufferGenerator(source, target, env, for_signature):
32 commands = [
33 '/usr/bin/protoc '
34 ' --proto_path . ${SOURCES} --cpp_out .']
35 return commands
36
37proto_builder = Builder(generator = ProtocolBufferGenerator,
38 emitter = ProtocolBufferEmitter,
39 single_source = 1,
40 suffix = '.pb.cc')
41
rspangler@google.com49fdf182009-10-10 00:57:34 +000042env = Environment()
adlr@google.comc98a7ed2009-12-04 18:54:03 +000043env['CCFLAGS'] = ' '.join("""-g
44 -fno-exceptions
45 -Wall
46 -Werror
47 -Wclobbered
48 -Wempty-body
49 -Wignored-qualifiers
50 -Wmissing-field-initializers
51 -Wsign-compare
52 -Wtype-limits
53 -Wuninitialized
54 -D_FILE_OFFSET_BITS=64
55 -I/usr/include/libxml2""".split());
56
57env['LIBS'] = Split("""base
58 curl
59 gflags
60 glib-2.0
61 gtest
62 gthread-2.0
63 libpcrecpp
64 protobuf
65 pthread
66 ssl
67 xml2
68 z""")
69env['CPPPATH'] = ['..', '../../third_party/chrome/files', '../../common']
70env['LIBPATH'] = ['../../third_party/chrome']
71env['BUILDERS']['ProtocolBuffer'] = proto_builder
Colin Watsonf2c29ec2010-01-08 18:50:56 +000072
73# Fix issue with scons not passing pkg-config vars through the environment.
74for key in Split('PKG_CONFIG_LIBDIR PKG_CONFIG_PATH'):
75 if os.environ.has_key(key):
76 env['ENV'][key] = os.environ[key]
77
rspangler@google.com49fdf182009-10-10 00:57:34 +000078env.ParseConfig('pkg-config --cflags --libs glib-2.0')
adlr@google.comc98a7ed2009-12-04 18:54:03 +000079env.ProtocolBuffer('update_metadata.pb.cc', 'update_metadata.proto')
rspangler@google.com49fdf182009-10-10 00:57:34 +000080
81if ARGUMENTS.get('debug', 0):
82 env['CCFLAGS'] += ' -fprofile-arcs -ftest-coverage'
83 env['LIBS'] += ['gcov']
84
adlr@google.comc98a7ed2009-12-04 18:54:03 +000085
86
rspangler@google.com49fdf182009-10-10 00:57:34 +000087sources = Split("""action_processor.cc
88 decompressing_file_writer.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +000089 delta_diff_parser.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +000090 download_action.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +000091 filesystem_copier_action.cc
92 filesystem_iterator.cc
93 file_writer.cc
94 gzip.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +000095 libcurl_http_fetcher.cc
96 omaha_hash_calculator.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +000097 omaha_request_prep_action.cc
98 omaha_response_handler_action.cc
99 postinstall_runner_action.cc
100 set_bootable_flag_action.cc
101 subprocess.cc
102 update_check_action.cc
103 update_metadata.pb.cc
104 utils.cc""")
rspangler@google.com49fdf182009-10-10 00:57:34 +0000105main = ['main.cc']
106
107unittest_sources = Split("""action_unittest.cc
108 action_pipe_unittest.cc
109 action_processor_unittest.cc
110 decompressing_file_writer_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000111 delta_diff_generator_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000112 download_action_unittest.cc
113 file_writer_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000114 filesystem_copier_action_unittest.cc
115 filesystem_iterator_unittest.cc
116 gzip_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000117 http_fetcher_unittest.cc
118 mock_http_fetcher.cc
119 omaha_hash_calculator_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000120 omaha_request_prep_action_unittest.cc
121 omaha_response_handler_action_unittest.cc
122 postinstall_runner_action_unittest.cc
123 set_bootable_flag_action_unittest.cc
124 subprocess_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000125 test_utils.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000126 update_check_action_unittest.cc
127 utils_unittest.cc""")
rspangler@google.com49fdf182009-10-10 00:57:34 +0000128unittest_main = ['testrunner.cc']
129
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000130delta_generator_sources = Split("""delta_diff_generator.cc""")
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -0800131delta_generator_main = ['generate_delta_main.cc']
132
133test_installer_main = ['test_installer_main.cc']
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000134
rspangler@google.com49fdf182009-10-10 00:57:34 +0000135env.Program('update_engine', sources + main)
136unittest_cmd = env.Program('update_engine_unittests',
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000137 sources + delta_generator_sources +
138 unittest_sources + unittest_main)
rspangler@google.com49fdf182009-10-10 00:57:34 +0000139
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -0800140test_installer_cmd = env.Program('test_installer',
141 sources + delta_generator_sources +
142 unittest_sources + test_installer_main)
143
rspangler@google.com49fdf182009-10-10 00:57:34 +0000144Clean(unittest_cmd, Glob('*.gcda') + Glob('*.gcno') + Glob('*.gcov') +
145 Split('html app.info'))
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000146
147delta_generator_cmd = env.Program('delta_generator',
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -0800148 sources + delta_generator_sources +
149 delta_generator_main)
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000150
151http_server_cmd = env.Program('test_http_server', 'test_http_server.cc')