]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/tool/mbed/mbed-sdk/workspace_tools/build_release.py
Merge pull request #34 from jackhumbert/tmk-master
[qmk_firmware.git] / tmk_core / tool / mbed / mbed-sdk / workspace_tools / build_release.py
1 """
2 mbed SDK
3 Copyright (c) 2011-2013 ARM Limited
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 """
17 import sys
18 from time import time
19 from os.path import join, abspath, dirname
20 from optparse import OptionParser
21
22 # Be sure that the tools directory is in the search path
23 ROOT = abspath(join(dirname(__file__), ".."))
24 sys.path.insert(0, ROOT)
25
26 from workspace_tools.build_api import build_mbed_libs
27 from workspace_tools.build_api import write_build_report
28 from workspace_tools.targets import TARGET_MAP
29
30 OFFICIAL_MBED_LIBRARY_BUILD = (
31     ('LPC11U24',     ('ARM', 'uARM', 'GCC_ARM', 'IAR')),
32     ('LPC1768',      ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')),
33     ('UBLOX_C027',   ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')),
34     ('ARCH_PRO',     ('ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR')),
35     ('LPC2368',      ('ARM', 'GCC_ARM')),
36     ('LPC812',       ('uARM','IAR')),
37     ('LPC824',       ('uARM', 'GCC_ARM', 'IAR', 'GCC_CR')),
38     ('SSCI824',      ('uARM','GCC_ARM')),
39     ('LPC1347',      ('ARM','IAR')),
40     ('LPC4088',      ('ARM', 'GCC_ARM', 'GCC_CR', 'IAR')),
41     ('LPC4088_DM',   ('ARM', 'GCC_ARM', 'GCC_CR', 'IAR')),
42     ('LPC1114',      ('uARM','GCC_ARM', 'GCC_CR', 'IAR')),
43     ('LPC11U35_401', ('ARM', 'uARM','GCC_ARM','GCC_CR', 'IAR')),
44     ('LPC11U35_501', ('ARM', 'uARM','GCC_ARM','GCC_CR', 'IAR')),
45     ('LPC1549',      ('uARM','GCC_ARM','GCC_CR', 'IAR')),
46     ('XADOW_M0',     ('ARM', 'uARM','GCC_ARM','GCC_CR')),
47     ('ARCH_GPRS',    ('ARM', 'uARM', 'GCC_ARM', 'GCC_CR', 'IAR')),
48     ('LPC4337',      ('ARM',)),
49     ('LPC11U37H_401', ('ARM', 'uARM','GCC_ARM','GCC_CR', 'IAR')),
50
51     ('KL05Z',        ('ARM', 'uARM', 'GCC_ARM', 'IAR')),
52     ('KL25Z',        ('ARM', 'GCC_ARM', 'IAR')),
53     ('KL43Z',        ('ARM', 'GCC_ARM')),
54     ('KL46Z',        ('ARM', 'GCC_ARM', 'IAR')),
55     ('K64F',         ('ARM', 'GCC_ARM', 'IAR')),
56     ('K22F',         ('ARM', 'GCC_ARM', 'IAR')),
57     ('K20D50M',      ('ARM', 'GCC_ARM' , 'IAR')),
58     ('TEENSY3_1',      ('ARM', 'GCC_ARM')),
59
60     ('NUCLEO_F030R8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
61     ('NUCLEO_F070RB', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
62     ('NUCLEO_F072RB', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
63     ('NUCLEO_F091RC', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
64     ('NUCLEO_F103RB', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
65     ('NUCLEO_F302R8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
66     ('NUCLEO_F303RE', ('ARM', 'uARM', 'IAR')),
67     ('NUCLEO_F334R8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
68     ('NUCLEO_F401RE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
69     ('NUCLEO_F411RE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
70     ('NUCLEO_L053R8', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
71     ('NUCLEO_L152RE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
72     ('MTS_MDOT_F405RG', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
73     ('MTS_MDOT_F411RE', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
74
75     ('ARCH_MAX',     ('ARM', 'GCC_ARM')),
76
77     ('NRF51822',     ('ARM', 'GCC_ARM', 'IAR')),
78     ('NRF51_DK',     ('ARM', 'GCC_ARM', 'IAR')),
79     ('NRF51_DONGLE', ('ARM', 'GCC_ARM', 'IAR')),
80     ('HRM1017',      ('ARM', 'GCC_ARM', 'IAR')),
81     ('ARCH_BLE',     ('ARM', 'GCC_ARM', 'IAR')),
82     ('SEEED_TINY_BLE', ('ARM', 'GCC_ARM', 'IAR')),
83     ('RBLAB_NRF51822', ('ARM', 'GCC_ARM')),
84     ('RBLAB_BLENANO', ('ARM', 'GCC_ARM')),
85     ('WALLBOT_BLE',  ('ARM', 'GCC_ARM')),
86
87     ('LPC11U68',     ('ARM', 'uARM','GCC_ARM','GCC_CR', 'IAR')),
88     ('OC_MBUINO',     ('ARM', 'uARM', 'GCC_ARM', 'IAR')),
89
90     ('RZ_A1H'   ,     ('ARM', 'GCC_ARM')),
91 )
92
93
94 if __name__ == '__main__':
95     parser = OptionParser()
96     parser.add_option('-o', '--official', dest="official_only", default=False, action="store_true",
97                       help="Build using only the official toolchain for each target")
98     parser.add_option("-j", "--jobs", type="int", dest="jobs",
99                       default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs")
100     parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
101                       default=False, help="Verbose diagnostic output")
102     parser.add_option("-t", "--toolchains", dest="toolchains", help="Use toolchains names separated by comma")
103
104     parser.add_option("", "--report-build", dest="report_build_file_name", help="Output the build results to an html file")
105
106
107     options, args = parser.parse_args()
108     start = time()
109     failures = []
110     successes = []
111     skips = []
112     build_report = []
113     for target_name, toolchain_list in OFFICIAL_MBED_LIBRARY_BUILD:
114         if options.official_only:
115             toolchains = (getattr(TARGET_MAP[target_name], 'default_toolchain', 'ARM'),)
116         else:
117             toolchains = toolchain_list
118
119         if options.toolchains:
120             print "Only building using the following toolchains: %s" % (options.toolchains)
121             toolchainSet = set(toolchains)
122             toolchains = toolchainSet and set((options.toolchains).split(','))
123
124
125         cur_target_build_report = { "target": target_name, "passing": [], "failing": [], "skipped": []}
126
127         for toolchain in toolchains:
128             id = "%s::%s" % (target_name, toolchain)
129             try:
130                 built_mbed_lib = build_mbed_libs(TARGET_MAP[target_name], toolchain, verbose=options.verbose, jobs=options.jobs)
131
132                 if built_mbed_lib:
133                     successes.append(id)
134                     cur_target_build_report["passing"].append({ "toolchain": toolchain })
135                 else:
136                     skips.append(id)
137                     cur_target_build_report["skipped"].append({ "toolchain": toolchain })
138
139
140             except Exception, e:
141                 failures.append(id)
142                 cur_target_build_report["failing"].append({ "toolchain": toolchain })
143                 print e
144
145         if len(toolchains) > 0:
146             build_report.append(cur_target_build_report)
147
148     # Write summary of the builds
149
150     if options.report_build_file_name:
151         write_build_report(build_report, 'library_build/report.html', options.report_build_file_name)
152
153     print "\n\nCompleted in: (%.2f)s" % (time() - start)
154
155     if successes:
156         print "\n\nBuild successes:"
157         print "\n".join(["  * %s" % s for s in successes])
158
159     if skips:
160         print "\n\nBuild skips:"
161         print "\n".join(["  * %s" % s for s in skips])
162
163     if failures:
164         print "\n\nBuild failures:"
165         print "\n".join(["  * %s" % f for f in failures])
166         sys.exit(1)