rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 1 | # 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 Reyes | 1e338b8 | 2010-01-22 14:57:27 -0800 | [diff] [blame] | 5 | import os |
| 6 | |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 7 | # 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""" |
| 15 | def 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.""" |
| 31 | def ProtocolBufferGenerator(source, target, env, for_signature): |
| 32 | commands = [ |
| 33 | '/usr/bin/protoc ' |
| 34 | ' --proto_path . ${SOURCES} --cpp_out .'] |
| 35 | return commands |
| 36 | |
| 37 | proto_builder = Builder(generator = ProtocolBufferGenerator, |
| 38 | emitter = ProtocolBufferEmitter, |
| 39 | single_source = 1, |
| 40 | suffix = '.pb.cc') |
| 41 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 42 | """ Inputs: |
| 43 | target: unused |
| 44 | source: list containing the source .xml file |
| 45 | env: the scons environment in which we are compiling |
| 46 | Outputs: |
| 47 | target: the list of targets we'll emit |
| 48 | source: the list of sources we'll process""" |
| 49 | def DbusBindingsEmitter(target, source, env): |
| 50 | output = str(source[0]) |
| 51 | output = output[0:output.rfind('.xml')] |
| 52 | target = [ |
| 53 | output + '.dbusserver.h', |
| 54 | output + '.dbusclient.h' |
| 55 | ] |
| 56 | return target, source |
| 57 | |
| 58 | """ Inputs: |
| 59 | source: list of sources to process |
| 60 | target: list of targets to generate |
| 61 | env: scons environment in which we are working |
| 62 | for_signature: unused |
| 63 | Outputs: a list of commands to execute to generate the targets from |
| 64 | the sources.""" |
| 65 | def DbusBindingsGenerator(source, target, env, for_signature): |
| 66 | commands = [] |
| 67 | for target_file in target: |
| 68 | if str(target_file).endswith('.dbusserver.h'): |
| 69 | mode_flag = '--mode=glib-server ' |
| 70 | else: |
| 71 | mode_flag = '--mode=glib-client ' |
| 72 | cmd = '/usr/bin/dbus-binding-tool %s --prefix=update_engine_service ' \ |
| 73 | '%s > %s' % (mode_flag, str(source[0]), str(target_file)) |
| 74 | commands.append(cmd) |
| 75 | return commands |
| 76 | |
| 77 | dbus_bindings_builder = Builder(generator = DbusBindingsGenerator, |
| 78 | emitter = DbusBindingsEmitter, |
| 79 | single_source = 1, |
| 80 | suffix = 'dbusclient.h') |
| 81 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 82 | env = Environment() |
Andrew de los Reyes | 08c4e27 | 2010-04-15 14:02:17 -0700 | [diff] [blame] | 83 | for key in Split('CC CXX AR RANLIB LD NM'): |
| 84 | value = os.environ.get(key) |
| 85 | if value != None: |
| 86 | env[key] = value |
| 87 | for key in Split('CFLAGS CCFLAGS CPPPATH LIBPATH'): |
| 88 | value = os.environ.get(key) |
| 89 | if value != None: |
| 90 | env[key] = Split(value) |
| 91 | |
| 92 | for key in Split('PKG_CONFIG_LIBDIR PKG_CONFIG_PATH SYSROOT'): |
| 93 | if os.environ.has_key(key): |
| 94 | env['ENV'][key] = os.environ[key] |
| 95 | |
| 96 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 97 | # -Wclobbered |
| 98 | # -Wempty-body |
| 99 | # -Wignored-qualifiers |
| 100 | # -Wtype-limits |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 101 | env['CCFLAGS'] = ' '.join("""-g |
| 102 | -fno-exceptions |
Andrew de los Reyes | 08c4e27 | 2010-04-15 14:02:17 -0700 | [diff] [blame] | 103 | -fno-strict-aliasing |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 104 | -Wall |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 105 | -Wclobbered |
| 106 | -Wempty-body |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 107 | -Werror |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 108 | -Wignored-qualifiers |
| 109 | -Wmissing-field-initializers |
| 110 | -Wsign-compare |
| 111 | -Wtype-limits |
| 112 | -Wuninitialized |
Andrew de los Reyes | 08c4e27 | 2010-04-15 14:02:17 -0700 | [diff] [blame] | 113 | -D__STDC_FORMAT_MACROS=1 |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 114 | -D_FILE_OFFSET_BITS=64 |
| 115 | -I/usr/include/libxml2""".split()); |
Andrew de los Reyes | 08c4e27 | 2010-04-15 14:02:17 -0700 | [diff] [blame] | 116 | env['CCFLAGS'] += (' ' + ' '.join(env['CFLAGS'])) |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 117 | |
| 118 | env['LIBS'] = Split("""base |
Andrew de los Reyes | 08c4e27 | 2010-04-15 14:02:17 -0700 | [diff] [blame] | 119 | bz2 |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 120 | curl |
| 121 | gflags |
| 122 | glib-2.0 |
| 123 | gtest |
| 124 | gthread-2.0 |
| 125 | libpcrecpp |
| 126 | protobuf |
| 127 | pthread |
| 128 | ssl |
| 129 | xml2 |
| 130 | z""") |
| 131 | env['CPPPATH'] = ['..', '../../third_party/chrome/files', '../../common'] |
| 132 | env['LIBPATH'] = ['../../third_party/chrome'] |
| 133 | env['BUILDERS']['ProtocolBuffer'] = proto_builder |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 134 | env['BUILDERS']['DbusBindings'] = dbus_bindings_builder |
Colin Watson | f2c29ec | 2010-01-08 18:50:56 +0000 | [diff] [blame] | 135 | |
| 136 | # Fix issue with scons not passing pkg-config vars through the environment. |
| 137 | for key in Split('PKG_CONFIG_LIBDIR PKG_CONFIG_PATH'): |
| 138 | if os.environ.has_key(key): |
| 139 | env['ENV'][key] = os.environ[key] |
| 140 | |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 141 | env.ParseConfig('pkg-config --cflags --libs ' |
| 142 | 'dbus-1 dbus-glib-1 gio-2.0 gio-unix-2.0 glib-2.0') |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 143 | env.ProtocolBuffer('update_metadata.pb.cc', 'update_metadata.proto') |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 144 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 145 | env.DbusBindings('update_engine.dbusclient.h', 'update_engine.xml') |
| 146 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 147 | if ARGUMENTS.get('debug', 0): |
| 148 | env['CCFLAGS'] += ' -fprofile-arcs -ftest-coverage' |
Andrew de los Reyes | 8006106 | 2010-02-04 14:25:00 -0800 | [diff] [blame] | 149 | env['LIBS'] += ['bz2', 'gcov'] |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 150 | |
| 151 | sources = Split("""action_processor.cc |
Andrew de los Reyes | d2135f3 | 2010-03-11 16:00:28 -0800 | [diff] [blame] | 152 | bzip.cc |
Andrew de los Reyes | 8006106 | 2010-02-04 14:25:00 -0800 | [diff] [blame] | 153 | bzip_extent_writer.cc |
Andrew de los Reyes | 35a7af1 | 2010-03-10 16:33:26 -0800 | [diff] [blame] | 154 | cycle_breaker.cc |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 155 | dbus_service.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 156 | decompressing_file_writer.cc |
Andrew de los Reyes | 09e56d6 | 2010-04-23 13:45:53 -0700 | [diff] [blame] | 157 | delta_diff_generator.cc |
| 158 | delta_performer.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 159 | download_action.cc |
Andrew de los Reyes | b4025e6 | 2010-02-23 17:47:03 -0800 | [diff] [blame] | 160 | extent_mapper.cc |
Andrew de los Reyes | 8006106 | 2010-02-04 14:25:00 -0800 | [diff] [blame] | 161 | extent_writer.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 162 | filesystem_copier_action.cc |
| 163 | filesystem_iterator.cc |
| 164 | file_writer.cc |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 165 | graph_utils.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 166 | gzip.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 167 | libcurl_http_fetcher.cc |
| 168 | omaha_hash_calculator.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 169 | omaha_request_prep_action.cc |
| 170 | omaha_response_handler_action.cc |
| 171 | postinstall_runner_action.cc |
| 172 | set_bootable_flag_action.cc |
Andrew de los Reyes | 0cca421 | 2010-04-29 14:00:58 -0700 | [diff] [blame^] | 173 | split_file_writer.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 174 | subprocess.cc |
Andrew de los Reyes | 81ebcd8 | 2010-03-09 15:56:18 -0800 | [diff] [blame] | 175 | tarjan.cc |
Andrew de los Reyes | 5815155 | 2010-03-10 20:07:08 -0800 | [diff] [blame] | 176 | topological_sort.cc |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 177 | update_attempter.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 178 | update_check_action.cc |
| 179 | update_metadata.pb.cc |
| 180 | utils.cc""") |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 181 | main = ['main.cc'] |
| 182 | |
| 183 | unittest_sources = Split("""action_unittest.cc |
| 184 | action_pipe_unittest.cc |
| 185 | action_processor_unittest.cc |
Andrew de los Reyes | 8006106 | 2010-02-04 14:25:00 -0800 | [diff] [blame] | 186 | bzip_extent_writer_unittest.cc |
Andrew de los Reyes | 35a7af1 | 2010-03-10 16:33:26 -0800 | [diff] [blame] | 187 | cycle_breaker_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 188 | decompressing_file_writer_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 189 | delta_diff_generator_unittest.cc |
Andrew de los Reyes | 09e56d6 | 2010-04-23 13:45:53 -0700 | [diff] [blame] | 190 | delta_performer_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 191 | download_action_unittest.cc |
Andrew de los Reyes | b4025e6 | 2010-02-23 17:47:03 -0800 | [diff] [blame] | 192 | extent_mapper_unittest.cc |
Andrew de los Reyes | 8006106 | 2010-02-04 14:25:00 -0800 | [diff] [blame] | 193 | extent_writer_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 194 | file_writer_unittest.cc |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 195 | filesystem_copier_action_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 196 | filesystem_iterator_unittest.cc |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 197 | graph_utils_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 198 | http_fetcher_unittest.cc |
| 199 | mock_http_fetcher.cc |
| 200 | omaha_hash_calculator_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 201 | omaha_request_prep_action_unittest.cc |
| 202 | omaha_response_handler_action_unittest.cc |
| 203 | postinstall_runner_action_unittest.cc |
| 204 | set_bootable_flag_action_unittest.cc |
Andrew de los Reyes | 0cca421 | 2010-04-29 14:00:58 -0700 | [diff] [blame^] | 205 | split_file_writer_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 206 | subprocess_unittest.cc |
Andrew de los Reyes | 81ebcd8 | 2010-03-09 15:56:18 -0800 | [diff] [blame] | 207 | tarjan_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 208 | test_utils.cc |
Andrew de los Reyes | 5815155 | 2010-03-10 20:07:08 -0800 | [diff] [blame] | 209 | topological_sort_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 210 | update_check_action_unittest.cc |
Andrew de los Reyes | d2135f3 | 2010-03-11 16:00:28 -0800 | [diff] [blame] | 211 | utils_unittest.cc |
| 212 | zip_unittest.cc""") |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 213 | unittest_main = ['testrunner.cc'] |
| 214 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 215 | client_main = ['update_engine_client.cc'] |
| 216 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 217 | delta_generator_main = ['generate_delta_main.cc'] |
| 218 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 219 | env.Program('update_engine', sources + main) |
| 220 | unittest_cmd = env.Program('update_engine_unittests', |
Andrew de los Reyes | 09e56d6 | 2010-04-23 13:45:53 -0700 | [diff] [blame] | 221 | sources + unittest_sources + unittest_main) |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 222 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 223 | client_cmd = env.Program('update_engine_client', sources + client_main); |
| 224 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 225 | Clean(unittest_cmd, Glob('*.gcda') + Glob('*.gcno') + Glob('*.gcov') + |
| 226 | Split('html app.info')) |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 227 | |
| 228 | delta_generator_cmd = env.Program('delta_generator', |
Andrew de los Reyes | 09e56d6 | 2010-04-23 13:45:53 -0700 | [diff] [blame] | 229 | sources + delta_generator_main) |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 230 | |
| 231 | http_server_cmd = env.Program('test_http_server', 'test_http_server.cc') |