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 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 42 | env = Environment() |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 43 | env['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 | |
| 57 | env['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""") |
| 69 | env['CPPPATH'] = ['..', '../../third_party/chrome/files', '../../common'] |
| 70 | env['LIBPATH'] = ['../../third_party/chrome'] |
| 71 | env['BUILDERS']['ProtocolBuffer'] = proto_builder |
Colin Watson | f2c29ec | 2010-01-08 18:50:56 +0000 | [diff] [blame] | 72 | |
| 73 | # Fix issue with scons not passing pkg-config vars through the environment. |
| 74 | for 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.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 78 | env.ParseConfig('pkg-config --cflags --libs glib-2.0') |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 79 | env.ProtocolBuffer('update_metadata.pb.cc', 'update_metadata.proto') |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 80 | |
| 81 | if ARGUMENTS.get('debug', 0): |
| 82 | env['CCFLAGS'] += ' -fprofile-arcs -ftest-coverage' |
Andrew de los Reyes | 8006106 | 2010-02-04 14:25:00 -0800 | [diff] [blame] | 83 | env['LIBS'] += ['bz2', 'gcov'] |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 84 | |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 85 | |
| 86 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 87 | sources = Split("""action_processor.cc |
Andrew de los Reyes | 8006106 | 2010-02-04 14:25:00 -0800 | [diff] [blame] | 88 | bzip_extent_writer.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 89 | decompressing_file_writer.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 90 | delta_diff_parser.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 91 | download_action.cc |
Andrew de los Reyes | b4025e6 | 2010-02-23 17:47:03 -0800 | [diff] [blame^] | 92 | extent_mapper.cc |
Andrew de los Reyes | 8006106 | 2010-02-04 14:25:00 -0800 | [diff] [blame] | 93 | extent_writer.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 94 | filesystem_copier_action.cc |
| 95 | filesystem_iterator.cc |
| 96 | file_writer.cc |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 97 | graph_utils.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 98 | gzip.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 99 | libcurl_http_fetcher.cc |
| 100 | omaha_hash_calculator.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 101 | omaha_request_prep_action.cc |
| 102 | omaha_response_handler_action.cc |
| 103 | postinstall_runner_action.cc |
| 104 | set_bootable_flag_action.cc |
| 105 | subprocess.cc |
| 106 | update_check_action.cc |
| 107 | update_metadata.pb.cc |
| 108 | utils.cc""") |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 109 | main = ['main.cc'] |
| 110 | |
| 111 | unittest_sources = Split("""action_unittest.cc |
| 112 | action_pipe_unittest.cc |
| 113 | action_processor_unittest.cc |
Andrew de los Reyes | 8006106 | 2010-02-04 14:25:00 -0800 | [diff] [blame] | 114 | bzip_extent_writer_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 115 | decompressing_file_writer_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 116 | delta_diff_generator_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 117 | download_action_unittest.cc |
Andrew de los Reyes | b4025e6 | 2010-02-23 17:47:03 -0800 | [diff] [blame^] | 118 | extent_mapper_unittest.cc |
Andrew de los Reyes | 8006106 | 2010-02-04 14:25:00 -0800 | [diff] [blame] | 119 | extent_writer_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 120 | file_writer_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 121 | filesystem_copier_action_unittest.cc |
| 122 | filesystem_iterator_unittest.cc |
Andrew de los Reyes | 0ce161b | 2010-02-22 15:27:01 -0800 | [diff] [blame] | 123 | graph_utils_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 124 | gzip_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 125 | http_fetcher_unittest.cc |
| 126 | mock_http_fetcher.cc |
| 127 | omaha_hash_calculator_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 128 | omaha_request_prep_action_unittest.cc |
| 129 | omaha_response_handler_action_unittest.cc |
| 130 | postinstall_runner_action_unittest.cc |
| 131 | set_bootable_flag_action_unittest.cc |
| 132 | subprocess_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 133 | test_utils.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 134 | update_check_action_unittest.cc |
| 135 | utils_unittest.cc""") |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 136 | unittest_main = ['testrunner.cc'] |
| 137 | |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 138 | delta_generator_sources = Split("""delta_diff_generator.cc""") |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 139 | delta_generator_main = ['generate_delta_main.cc'] |
| 140 | |
| 141 | test_installer_main = ['test_installer_main.cc'] |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 142 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 143 | env.Program('update_engine', sources + main) |
| 144 | unittest_cmd = env.Program('update_engine_unittests', |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 145 | sources + delta_generator_sources + |
| 146 | unittest_sources + unittest_main) |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 147 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 148 | test_installer_cmd = env.Program('test_installer', |
| 149 | sources + delta_generator_sources + |
| 150 | unittest_sources + test_installer_main) |
| 151 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 152 | Clean(unittest_cmd, Glob('*.gcda') + Glob('*.gcno') + Glob('*.gcov') + |
| 153 | Split('html app.info')) |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 154 | |
| 155 | delta_generator_cmd = env.Program('delta_generator', |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 156 | sources + delta_generator_sources + |
| 157 | delta_generator_main) |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 158 | |
| 159 | http_server_cmd = env.Program('test_http_server', 'test_http_server.cc') |