|
129 | 129 |
|
130 | 130 | build_report = {}
|
131 | 131 | build_properties = {}
|
132 |
| - |
133 |
| - # Build sources |
134 |
| - lib_build_res = build_library(base_source_paths, options.build_dir, target, options.tool, |
135 |
| - options=options.options, |
136 |
| - jobs=options.jobs, |
137 |
| - clean=options.clean, |
138 |
| - report=build_report, |
139 |
| - properties=build_properties, |
140 |
| - name="mbed-os", |
141 |
| - macros=options.macros, |
142 |
| - archive=False) |
143 |
| - |
144 |
| - # Build all the tests |
145 |
| - test_build = build_tests(tests, [options.build_dir], options.build_dir, target, options.tool, |
146 |
| - options=options.options, |
147 |
| - clean=options.clean, |
148 |
| - report=build_report, |
149 |
| - properties=build_properties, |
150 |
| - macros=options.macros, |
151 |
| - jobs=options.jobs) |
152 |
| - |
153 |
| - # If a path to a test spec is provided, write it to a file |
154 |
| - if options.test_spec: |
155 |
| - test_spec_data = test_spec_from_test_build(test_build) |
| 132 | + |
| 133 | + library_build_success = True |
| 134 | + try: |
| 135 | + # Build sources |
| 136 | + build_library(base_source_paths, options.build_dir, target, options.tool, |
| 137 | + options=options.options, |
| 138 | + jobs=options.jobs, |
| 139 | + clean=options.clean, |
| 140 | + report=build_report, |
| 141 | + properties=build_properties, |
| 142 | + name="mbed-os", |
| 143 | + macros=options.macros, |
| 144 | + archive=False) |
| 145 | + except Exception, e: |
| 146 | + library_build_success = False |
| 147 | + print "Failed to build library" |
| 148 | + print e |
156 | 149 |
|
157 |
| - # Create the target dir for the test spec if necessary |
158 |
| - # mkdir will not create the dir if it already exists |
159 |
| - test_spec_dir = os.path.dirname(options.test_spec) |
160 |
| - if test_spec_dir: |
161 |
| - mkdir(test_spec_dir) |
| 150 | + if library_build_success: |
| 151 | + # Build all the tests |
| 152 | + test_build_success, test_build = build_tests(tests, [options.build_dir], options.build_dir, target, options.tool, |
| 153 | + options=options.options, |
| 154 | + clean=options.clean, |
| 155 | + report=build_report, |
| 156 | + properties=build_properties, |
| 157 | + macros=options.macros, |
| 158 | + jobs=options.jobs) |
| 159 | + |
| 160 | + if not test_build_success: |
| 161 | + print "Failed to build some tests, check build log for details" |
162 | 162 |
|
163 |
| - try: |
164 |
| - with open(options.test_spec, 'w') as f: |
165 |
| - f.write(json.dumps(test_spec_data, indent=2)) |
166 |
| - except IOError, e: |
167 |
| - print "[ERROR] Error writing test spec to file" |
168 |
| - print e |
| 163 | + # If a path to a test spec is provided, write it to a file |
| 164 | + if options.test_spec: |
| 165 | + test_spec_data = test_spec_from_test_build(test_build) |
| 166 | + |
| 167 | + # Create the target dir for the test spec if necessary |
| 168 | + # mkdir will not create the dir if it already exists |
| 169 | + test_spec_dir = os.path.dirname(options.test_spec) |
| 170 | + if test_spec_dir: |
| 171 | + mkdir(test_spec_dir) |
| 172 | + |
| 173 | + try: |
| 174 | + with open(options.test_spec, 'w') as f: |
| 175 | + f.write(json.dumps(test_spec_data, indent=2)) |
| 176 | + except IOError, e: |
| 177 | + print "[ERROR] Error writing test spec to file" |
| 178 | + print e |
169 | 179 |
|
170 | 180 | # If a path to a JUnit build report spec is provided, write it to a file
|
171 | 181 | if options.build_report_junit:
|
172 | 182 | report_exporter = ReportExporter(ResultExporterType.JUNIT)
|
173 | 183 | report_exporter.report_to_file(build_report, options.build_report_junit, test_suite_properties=build_properties)
|
174 |
| - sys.exit() |
| 184 | + |
| 185 | + if library_build_success and test_build_success: |
| 186 | + sys.exit(0) |
| 187 | + else: |
| 188 | + sys.exit(1) |
175 | 189 |
|
176 | 190 | except KeyboardInterrupt, e:
|
177 | 191 | print "\n[CTRL+c] exit"
|
|
0 commit comments