blob: 5bfbec77f5bc12d75ae24f578f82bfbfcb160a14 [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'
Andrew de los Reyes80061062010-02-04 14:25:00 -080083 env['LIBS'] += ['bz2', 'gcov']
rspangler@google.com49fdf182009-10-10 00:57:34 +000084
adlr@google.comc98a7ed2009-12-04 18:54:03 +000085
86
rspangler@google.com49fdf182009-10-10 00:57:34 +000087sources = Split("""action_processor.cc
Andrew de los Reyes80061062010-02-04 14:25:00 -080088 bzip_extent_writer.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +000089 decompressing_file_writer.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +000090 delta_diff_parser.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +000091 download_action.cc
Andrew de los Reyesb4025e62010-02-23 17:47:03 -080092 extent_mapper.cc
Andrew de los Reyes80061062010-02-04 14:25:00 -080093 extent_writer.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +000094 filesystem_copier_action.cc
95 filesystem_iterator.cc
96 file_writer.cc
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -080097 graph_utils.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +000098 gzip.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +000099 libcurl_http_fetcher.cc
100 omaha_hash_calculator.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000101 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
Andrew de los Reyes81ebcd82010-03-09 15:56:18 -0800106 tarjan.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000107 update_check_action.cc
108 update_metadata.pb.cc
109 utils.cc""")
rspangler@google.com49fdf182009-10-10 00:57:34 +0000110main = ['main.cc']
111
112unittest_sources = Split("""action_unittest.cc
113 action_pipe_unittest.cc
114 action_processor_unittest.cc
Andrew de los Reyes80061062010-02-04 14:25:00 -0800115 bzip_extent_writer_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000116 decompressing_file_writer_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000117 delta_diff_generator_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000118 download_action_unittest.cc
Andrew de los Reyesb4025e62010-02-23 17:47:03 -0800119 extent_mapper_unittest.cc
Andrew de los Reyes80061062010-02-04 14:25:00 -0800120 extent_writer_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000121 file_writer_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000122 filesystem_copier_action_unittest.cc
123 filesystem_iterator_unittest.cc
Andrew de los Reyes0ce161b2010-02-22 15:27:01 -0800124 graph_utils_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000125 gzip_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000126 http_fetcher_unittest.cc
127 mock_http_fetcher.cc
128 omaha_hash_calculator_unittest.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000129 omaha_request_prep_action_unittest.cc
130 omaha_response_handler_action_unittest.cc
131 postinstall_runner_action_unittest.cc
132 set_bootable_flag_action_unittest.cc
133 subprocess_unittest.cc
Andrew de los Reyes81ebcd82010-03-09 15:56:18 -0800134 tarjan_unittest.cc
rspangler@google.com49fdf182009-10-10 00:57:34 +0000135 test_utils.cc
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000136 update_check_action_unittest.cc
137 utils_unittest.cc""")
rspangler@google.com49fdf182009-10-10 00:57:34 +0000138unittest_main = ['testrunner.cc']
139
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000140delta_generator_sources = Split("""delta_diff_generator.cc""")
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -0800141delta_generator_main = ['generate_delta_main.cc']
142
143test_installer_main = ['test_installer_main.cc']
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000144
rspangler@google.com49fdf182009-10-10 00:57:34 +0000145env.Program('update_engine', sources + main)
146unittest_cmd = env.Program('update_engine_unittests',
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000147 sources + delta_generator_sources +
148 unittest_sources + unittest_main)
rspangler@google.com49fdf182009-10-10 00:57:34 +0000149
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -0800150test_installer_cmd = env.Program('test_installer',
151 sources + delta_generator_sources +
152 unittest_sources + test_installer_main)
153
rspangler@google.com49fdf182009-10-10 00:57:34 +0000154Clean(unittest_cmd, Glob('*.gcda') + Glob('*.gcno') + Glob('*.gcov') +
155 Split('html app.info'))
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000156
157delta_generator_cmd = env.Program('delta_generator',
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -0800158 sources + delta_generator_sources +
159 delta_generator_main)
adlr@google.comc98a7ed2009-12-04 18:54:03 +0000160
161http_server_cmd = env.Program('test_http_server', 'test_http_server.cc')