| 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 | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 70 | env.ParseConfig('pkg-config --cflags --libs glib-2.0') | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 71 | env.ProtocolBuffer('update_metadata.pb.cc', 'update_metadata.proto') | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 72 |  | 
|  | 73 | if ARGUMENTS.get('debug', 0): | 
|  | 74 | env['CCFLAGS'] += ' -fprofile-arcs -ftest-coverage' | 
|  | 75 | env['LIBS'] += ['gcov'] | 
|  | 76 |  | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 77 |  | 
|  | 78 |  | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 79 | sources = Split("""action_processor.cc | 
|  | 80 | decompressing_file_writer.cc | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 81 | delta_diff_parser.cc | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 82 | download_action.cc | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 83 | filesystem_copier_action.cc | 
|  | 84 | filesystem_iterator.cc | 
|  | 85 | file_writer.cc | 
|  | 86 | gzip.cc | 
|  | 87 | install_action.cc | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 88 | libcurl_http_fetcher.cc | 
|  | 89 | omaha_hash_calculator.cc | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 90 | omaha_request_prep_action.cc | 
|  | 91 | omaha_response_handler_action.cc | 
|  | 92 | postinstall_runner_action.cc | 
|  | 93 | set_bootable_flag_action.cc | 
|  | 94 | subprocess.cc | 
|  | 95 | update_check_action.cc | 
|  | 96 | update_metadata.pb.cc | 
|  | 97 | utils.cc""") | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 98 | main = ['main.cc'] | 
|  | 99 |  | 
|  | 100 | unittest_sources = Split("""action_unittest.cc | 
|  | 101 | action_pipe_unittest.cc | 
|  | 102 | action_processor_unittest.cc | 
|  | 103 | decompressing_file_writer_unittest.cc | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 104 | delta_diff_generator_unittest.cc | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 105 | download_action_unittest.cc | 
|  | 106 | file_writer_unittest.cc | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 107 | filesystem_copier_action_unittest.cc | 
|  | 108 | filesystem_iterator_unittest.cc | 
|  | 109 | gzip_unittest.cc | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 110 | http_fetcher_unittest.cc | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 111 | install_action_unittest.cc | 
|  | 112 | integration_unittest.cc | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 113 | mock_http_fetcher.cc | 
|  | 114 | omaha_hash_calculator_unittest.cc | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 115 | omaha_request_prep_action_unittest.cc | 
|  | 116 | omaha_response_handler_action_unittest.cc | 
|  | 117 | postinstall_runner_action_unittest.cc | 
|  | 118 | set_bootable_flag_action_unittest.cc | 
|  | 119 | subprocess_unittest.cc | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 120 | test_utils.cc | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 121 | update_check_action_unittest.cc | 
|  | 122 | utils_unittest.cc""") | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 123 | unittest_main = ['testrunner.cc'] | 
|  | 124 |  | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 125 | delta_generator_sources = Split("""delta_diff_generator.cc""") | 
|  | 126 |  | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 127 | env.Program('update_engine', sources + main) | 
|  | 128 | unittest_cmd = env.Program('update_engine_unittests', | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 129 | sources + delta_generator_sources + | 
|  | 130 | unittest_sources + unittest_main) | 
| rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 131 |  | 
|  | 132 | Clean(unittest_cmd, Glob('*.gcda') + Glob('*.gcno') + Glob('*.gcov') + | 
|  | 133 | Split('html app.info')) | 
| adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame^] | 134 |  | 
|  | 135 | delta_generator_cmd = env.Program('delta_generator', | 
|  | 136 | sources + delta_generator_sources + main) | 
|  | 137 |  | 
|  | 138 | http_server_cmd = env.Program('test_http_server', 'test_http_server.cc') |