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 | |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 5 | # 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""" |
| 13 | def 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.""" |
| 29 | def ProtocolBufferGenerator(source, target, env, for_signature): |
| 30 | commands = [ |
| 31 | '/usr/bin/protoc ' |
| 32 | ' --proto_path . ${SOURCES} --cpp_out .'] |
| 33 | return commands |
| 34 | |
| 35 | proto_builder = Builder(generator = ProtocolBufferGenerator, |
| 36 | emitter = ProtocolBufferEmitter, |
| 37 | single_source = 1, |
| 38 | suffix = '.pb.cc') |
| 39 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 40 | env = Environment() |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 41 | env['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 | |
| 55 | env['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""") |
| 67 | env['CPPPATH'] = ['..', '../../third_party/chrome/files', '../../common'] |
| 68 | env['LIBPATH'] = ['../../third_party/chrome'] |
| 69 | env['BUILDERS']['ProtocolBuffer'] = proto_builder |
Colin Watson | f2c29ec | 2010-01-08 18:50:56 +0000 | [diff] [blame^] | 70 | |
| 71 | # Fix issue with scons not passing pkg-config vars through the environment. |
| 72 | for 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.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 76 | env.ParseConfig('pkg-config --cflags --libs glib-2.0') |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 77 | env.ProtocolBuffer('update_metadata.pb.cc', 'update_metadata.proto') |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 78 | |
| 79 | if ARGUMENTS.get('debug', 0): |
| 80 | env['CCFLAGS'] += ' -fprofile-arcs -ftest-coverage' |
| 81 | env['LIBS'] += ['gcov'] |
| 82 | |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 83 | |
| 84 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 85 | sources = Split("""action_processor.cc |
| 86 | decompressing_file_writer.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 87 | delta_diff_parser.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 88 | download_action.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 89 | filesystem_copier_action.cc |
| 90 | filesystem_iterator.cc |
| 91 | file_writer.cc |
| 92 | gzip.cc |
| 93 | install_action.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 94 | libcurl_http_fetcher.cc |
| 95 | omaha_hash_calculator.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 96 | 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.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 104 | main = ['main.cc'] |
| 105 | |
| 106 | unittest_sources = Split("""action_unittest.cc |
| 107 | action_pipe_unittest.cc |
| 108 | action_processor_unittest.cc |
| 109 | decompressing_file_writer_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 110 | delta_diff_generator_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 111 | download_action_unittest.cc |
| 112 | file_writer_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 113 | filesystem_copier_action_unittest.cc |
| 114 | filesystem_iterator_unittest.cc |
| 115 | gzip_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 116 | http_fetcher_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 117 | install_action_unittest.cc |
| 118 | integration_unittest.cc |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 119 | mock_http_fetcher.cc |
| 120 | omaha_hash_calculator_unittest.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 121 | 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.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 126 | test_utils.cc |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 127 | update_check_action_unittest.cc |
| 128 | utils_unittest.cc""") |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 129 | unittest_main = ['testrunner.cc'] |
| 130 | |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 131 | delta_generator_sources = Split("""delta_diff_generator.cc""") |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 132 | delta_generator_main = ['generate_delta_main.cc'] |
| 133 | |
| 134 | test_installer_main = ['test_installer_main.cc'] |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 135 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 136 | env.Program('update_engine', sources + main) |
| 137 | unittest_cmd = env.Program('update_engine_unittests', |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 138 | sources + delta_generator_sources + |
| 139 | unittest_sources + unittest_main) |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 140 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 141 | test_installer_cmd = env.Program('test_installer', |
| 142 | sources + delta_generator_sources + |
| 143 | unittest_sources + test_installer_main) |
| 144 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 145 | Clean(unittest_cmd, Glob('*.gcda') + Glob('*.gcno') + Glob('*.gcov') + |
| 146 | Split('html app.info')) |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 147 | |
| 148 | delta_generator_cmd = env.Program('delta_generator', |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 149 | sources + delta_generator_sources + |
| 150 | delta_generator_main) |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 151 | |
| 152 | http_server_cmd = env.Program('test_http_server', 'test_http_server.cc') |