2013-02-18 15:32:11 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
"""
|
|
|
|
LIBRARIES BUILD
|
|
|
|
"""
|
|
|
|
import sys
|
|
|
|
from time import time
|
|
|
|
from os.path import join, abspath, dirname
|
|
|
|
|
|
|
|
# Be sure that the tools directory is in the search path
|
|
|
|
ROOT = abspath(join(dirname(__file__), ".."))
|
|
|
|
sys.path.append(ROOT)
|
|
|
|
|
2013-04-18 14:43:29 +00:00
|
|
|
from workspace_tools.toolchains import TOOLCHAINS
|
|
|
|
from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
|
2013-03-14 11:52:38 +00:00
|
|
|
from workspace_tools.options import get_default_options_parser
|
2013-02-18 15:32:11 +00:00
|
|
|
from workspace_tools.build_api import build_mbed_libs, build_lib
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
start = time()
|
|
|
|
|
|
|
|
# Parse Options
|
|
|
|
parser = get_default_options_parser()
|
|
|
|
|
|
|
|
# Extra libraries
|
|
|
|
parser.add_option("-r", "--rtos", action="store_true", dest="rtos",
|
|
|
|
default=False, help="Compile the rtos")
|
|
|
|
parser.add_option("-b", "--debug", action="store_true", dest="debug",
|
|
|
|
default=False, help="Compile the debugging library")
|
|
|
|
parser.add_option("-f", "--fatfs", action="store_true", dest="fatfs",
|
|
|
|
default=False, help="Compile the fatfs")
|
|
|
|
parser.add_option("-e", "--eth", action="store_true", dest="eth",
|
|
|
|
default=False, help="Compile the ethernet library")
|
|
|
|
parser.add_option("-V", "--vodafone", action="store_true", dest="vodafone",
|
|
|
|
default=False, help="Compile the Vodafone library")
|
|
|
|
parser.add_option("-U", "--usb_host", action="store_true", dest="usb_host",
|
|
|
|
default=False, help="Compile the USB Host library")
|
|
|
|
parser.add_option("-u", "--usb", action="store_true", dest="usb",
|
|
|
|
default=False, help="Compile the USB Device library")
|
|
|
|
parser.add_option("-d", "--dsp", action="store_true", dest="dsp",
|
|
|
|
default=False, help="Compile the DSP library")
|
|
|
|
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
|
|
|
|
default=False, help="Verbose diagnostic output")
|
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
# Get target list
|
|
|
|
if options.mcu:
|
2013-03-14 11:52:38 +00:00
|
|
|
targets = [options.mcu]
|
2013-02-18 15:32:11 +00:00
|
|
|
else:
|
2013-04-18 14:43:29 +00:00
|
|
|
targets = TARGET_NAMES
|
2013-02-18 15:32:11 +00:00
|
|
|
|
|
|
|
# Get toolchains list
|
|
|
|
if options.tool:
|
|
|
|
toolchains = [options.tool]
|
|
|
|
else:
|
|
|
|
toolchains = TOOLCHAINS
|
|
|
|
|
|
|
|
# Get libraries list
|
|
|
|
libraries = []
|
|
|
|
|
|
|
|
# Additional Libraries
|
|
|
|
if options.rtos:
|
|
|
|
libraries.extend(["rtx", "rtos"])
|
|
|
|
if options.debug:
|
|
|
|
libraries.append("debug")
|
|
|
|
if options.fatfs:
|
|
|
|
libraries.append("fatfs")
|
|
|
|
if options.usb_host:
|
|
|
|
libraries.append("usb_host")
|
|
|
|
if options.eth:
|
|
|
|
libraries.append("eth")
|
|
|
|
if options.vodafone:
|
|
|
|
libraries.append("vodafone")
|
|
|
|
if options.usb:
|
|
|
|
libraries.append("usb")
|
|
|
|
if options.dsp:
|
|
|
|
libraries.extend(["cmsis_dsp", "dsp"])
|
|
|
|
|
|
|
|
# Build
|
|
|
|
failures = []
|
|
|
|
successes = []
|
|
|
|
for toolchain in toolchains:
|
|
|
|
for target in targets:
|
|
|
|
id = "%s::%s" % (toolchain, target)
|
|
|
|
try:
|
2013-04-18 14:43:29 +00:00
|
|
|
mcu = TARGET_MAP[target]
|
2013-07-02 15:43:29 +00:00
|
|
|
build_mbed_libs(mcu, toolchain, options=options.options,
|
2013-07-24 16:29:11 +00:00
|
|
|
verbose=options.verbose, clean=options.clean)
|
2013-02-18 15:32:11 +00:00
|
|
|
for lib_id in libraries:
|
2013-07-02 15:43:29 +00:00
|
|
|
build_lib(lib_id, mcu, toolchain, options=options.options,
|
2013-07-24 16:29:11 +00:00
|
|
|
verbose=options.verbose, clean=options.clean)
|
2013-02-18 15:32:11 +00:00
|
|
|
successes.append(id)
|
|
|
|
except Exception, e:
|
2013-06-24 13:32:08 +00:00
|
|
|
if options.verbose:
|
|
|
|
import sys, traceback
|
|
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
sys.exit(1)
|
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
failures.append(id)
|
|
|
|
print e
|
|
|
|
|
|
|
|
# Write summary of the builds
|
|
|
|
print "\n\nCompleted in: (%.2f)s" % (time() - start)
|
|
|
|
|
|
|
|
if successes:
|
|
|
|
print "\n\nBuild successes:"
|
|
|
|
print "\n".join([" * %s" % s for s in successes])
|
|
|
|
|
|
|
|
if failures:
|
|
|
|
print "\n\nBuild failures:"
|
|
|
|
print "\n".join([" * %s" % f for f in failures])
|