diff --git a/workspace_tools/build_api.py b/workspace_tools/build_api.py
index 843f775ecc..76875426f4 100644
--- a/workspace_tools/build_api.py
+++ b/workspace_tools/build_api.py
@@ -29,6 +29,8 @@ from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, M
from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
from workspace_tools.libraries import Library
from workspace_tools.toolchains import TOOLCHAIN_CLASSES
+from jinja2 import FileSystemLoader
+from jinja2.environment import Environment
def build_project(src_path, build_path, target, toolchain_name,
@@ -531,34 +533,67 @@ def print_build_results(result_list, build_name):
return result
def write_build_report(build_report, filename):
- with open(filename, 'w+') as f:
- f.write('\n')
- f.write('\t\n')
+ build_report_failing = []
+ build_report_passing = []
- f.write('\t\t\n')
- f.write('\t\t\t | \n')
- f.write('\t\t\t | \n')
- f.write('\t\t\t | \n')
- f.write('\t\t
\n')
+ for report in build_report:
+ if len(report["failing"]) > 0:
+ build_report_failing.append(report)
+ else:
+ build_report_passing.append(report)
+
+ '''build_report_failing = [{
+ "target": "K64F",
+ "passing": [
+ {
+ "toolchain": "GCC_ARM"
+ },
+ {
+ "toolchain": "ARM"
+ }
+ ],
+ "failing": [
+ {
+ "toolchain": "GCC_CS"
+ },
+ {
+ "toolchain": "IAR"
+ }
+ ]
+ },
+ {
+ "target": "KL46Z",
+ "passing": [
+ {
+ "toolchain": "GCC_ARM"
+ }
+ ],
+ "failing": [
+ {
+ "toolchain": "ARM"
+ },
+ {
+ "toolchain": "IAR"
+ }
+ ]
+ }]
- for report in build_report:
- f.write('\t\t\n')
+ build_report_passing = [{
+ "target": "LPC1768",
+ "passing": [
+ {
+ "toolchain": "GCC_ARM"
+ },
+ {
+ "toolchain": "ARM"
+ }
+ ],
+ "failing": []
+ }]'''
- color = "#009933"
+ env = Environment(extensions=['jinja2.ext.with_'])
+ env.loader = FileSystemLoader('ci_templates/library_build')
+ template = env.get_template('report.html')
- if len(report["failures"]) > 0:
- color = "#FF0000"
-
- target_cell = '\t\t\t | \n' % (report["target"], color)
- f.write(target_cell)
-
- successes_cell = '\t\t\t | \n' % ("\n".join(report["successes"]))
- f.write(successes_cell)
-
- failures_cell = '\t\t\t | \n' % ("\n".join(report["failures"]))
- f.write(failures_cell)
-
- f.write('\t\t
\n')
-
- f.write('\t
\n')
- f.write('\n')
+ with open(filename, 'w+') as f:
+ f.write(template.render(failing_builds=build_report_failing, passing_builds=build_report_passing))
diff --git a/workspace_tools/build_release.py b/workspace_tools/build_release.py
index 1e132f50d2..a74177e37e 100755
--- a/workspace_tools/build_release.py
+++ b/workspace_tools/build_release.py
@@ -101,7 +101,7 @@ if __name__ == '__main__':
default=False, help="Verbose diagnostic output")
parser.add_option("-t", "--toolchains", dest="toolchains", help="Use toolchains names separated by comma")
- parser.add_option("", "--report-jenkins", dest="report_jenkins_file", help="Output the build results to an xml file that is readable by Jenkins")
+ parser.add_option("", "--report-jenkins", dest="report_jenkins_file_name", help="Output the build results to an xml file that is readable by Jenkins")
options, args = parser.parse_args()
@@ -121,17 +121,17 @@ if __name__ == '__main__':
toolchains = toolchainSet and set((options.toolchains).split(','))
- cur_target_build_report = { "target": target_name, "successes": [], "failures": []}
+ cur_target_build_report = { "target": target_name, "passing": [], "failing": []}
for toolchain in toolchains:
id = "%s::%s" % (target_name, toolchain)
try:
build_mbed_libs(TARGET_MAP[target_name], toolchain, verbose=options.verbose, jobs=options.jobs)
successes.append(id)
- cur_target_build_report["successes"].append(toolchain)
+ cur_target_build_report["passing"].append({ "toolchain": toolchain })
except Exception, e:
failures.append(id)
- cur_target_build_report["failures"].append(toolchain)
+ cur_target_build_report["failing"].append({ "toolchain": toolchain })
print e
if len(toolchains) > 0:
@@ -140,7 +140,7 @@ if __name__ == '__main__':
# Write summary of the builds
if options.report_jenkins_file:
- write_build_report(build_report, options.report_jenkins_file)
+ write_build_report(build_report, options.report_jenkins_file_name)
print "\n\nCompleted in: (%.2f)s" % (time() - start)
diff --git a/workspace_tools/ci_templates/library_build/build_report.html b/workspace_tools/ci_templates/library_build/build_report.html
new file mode 100644
index 0000000000..b459478e42
--- /dev/null
+++ b/workspace_tools/ci_templates/library_build/build_report.html
@@ -0,0 +1,19 @@
+
+
+ {% if report.failing|length > 0 %}
+ [FAIL]
+ {% else %}
+ [OK]
+ {% endif %}
+
+ {{report.target}} - Passing: {{report.passing|length}}, Failing: {{report.failing|length}}
+ Failing
+ {% with build = report.failing %}
+ {% include 'build_report_table.html' %}
+ {% endwith %}
+
+ Passing
+ {% with build = report.passing %}
+ {% include 'build_report_table.html' %}
+ {% endwith %}
+
diff --git a/workspace_tools/ci_templates/library_build/build_report_table.html b/workspace_tools/ci_templates/library_build/build_report_table.html
new file mode 100644
index 0000000000..26d87dfb17
--- /dev/null
+++ b/workspace_tools/ci_templates/library_build/build_report_table.html
@@ -0,0 +1,10 @@
+
+
+ Toolchain |
+
+ {% for run in build %}
+
+ {{run.toolchain}} |
+
+ {% endfor %}
+
diff --git a/workspace_tools/ci_templates/library_build/report.html b/workspace_tools/ci_templates/library_build/report.html
new file mode 100644
index 0000000000..3fcfd73094
--- /dev/null
+++ b/workspace_tools/ci_templates/library_build/report.html
@@ -0,0 +1,9 @@
+Failing Builds
+{% for report in failing_builds %}
+{% include 'build_report.html' %}
+{% endfor %}
+
+Passing Builds
+{% for report in passing_builds %}
+{% include 'build_report.html' %}
+{% endfor %}