2013-08-06 13:38:00 +00:00
|
|
|
"""
|
|
|
|
mbed SDK
|
|
|
|
Copyright (c) 2011-2013 ARM Limited
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
2014-07-01 16:45:12 +00:00
|
|
|
You may obtain a copy of the License at
|
2013-08-06 13:38:00 +00:00
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
"""
|
2014-06-11 13:47:54 +00:00
|
|
|
|
|
|
|
import tempfile
|
2014-07-29 13:48:48 +00:00
|
|
|
import re
|
2013-02-18 15:32:11 +00:00
|
|
|
from os.path import join, exists, basename
|
2013-06-10 14:44:08 +00:00
|
|
|
from shutil import rmtree
|
2013-02-18 15:32:11 +00:00
|
|
|
from types import ListType
|
|
|
|
|
2014-06-11 14:51:32 +00:00
|
|
|
from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext
|
2013-07-24 16:29:11 +00:00
|
|
|
from workspace_tools.toolchains import TOOLCHAIN_CLASSES
|
2013-06-24 13:32:08 +00:00
|
|
|
from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON
|
2013-06-10 14:44:08 +00:00
|
|
|
from workspace_tools.libraries import Library
|
2014-06-09 15:10:47 +00:00
|
|
|
from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
|
2013-06-10 14:44:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
def build_project(src_path, build_path, target, toolchain_name,
|
2013-07-02 15:43:29 +00:00
|
|
|
libraries_paths=None, options=None, linker_script=None,
|
2014-07-09 17:00:21 +00:00
|
|
|
clean=False, notify=None, verbose=False, name=None, macros=None, inc_dirs=None, jobs=1):
|
2014-07-01 16:45:12 +00:00
|
|
|
""" This function builds project. Project can be for example one test / UT """
|
2013-06-10 14:44:08 +00:00
|
|
|
# Toolchain instance
|
2013-10-21 08:11:06 +00:00
|
|
|
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, notify, macros)
|
2013-06-10 14:44:08 +00:00
|
|
|
toolchain.VERBOSE = verbose
|
2014-07-09 17:00:21 +00:00
|
|
|
toolchain.jobs = jobs
|
2013-06-10 14:44:08 +00:00
|
|
|
toolchain.build_all = clean
|
2013-10-17 15:19:07 +00:00
|
|
|
src_paths = [src_path] if type(src_path) != ListType else src_path
|
2014-07-01 16:45:12 +00:00
|
|
|
|
|
|
|
# We need to remove all paths which are repeated to avoid
|
|
|
|
# multiple compilations and linking with the same objects
|
|
|
|
src_paths = [src_paths[0]] + list(set(src_paths[1:]))
|
|
|
|
|
2014-07-14 16:45:01 +00:00
|
|
|
PROJECT_BASENAME = basename(src_paths[0])
|
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
if name is None:
|
2014-07-14 16:45:01 +00:00
|
|
|
# We will use default project name based on project folder name
|
|
|
|
name = PROJECT_BASENAME
|
|
|
|
toolchain.info("Building project %s (%s, %s)" % (PROJECT_BASENAME.upper(), target.name, toolchain_name))
|
|
|
|
else:
|
|
|
|
# User used custom global project name to have the same name for the
|
|
|
|
toolchain.info("Building project %s to %s (%s, %s)" % (PROJECT_BASENAME.upper(), name, target.name, toolchain_name))
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# Scan src_path and libraries_paths for resources
|
2013-10-17 15:19:07 +00:00
|
|
|
resources = toolchain.scan_resources(src_paths[0])
|
|
|
|
for path in src_paths[1:]:
|
|
|
|
resources.add(toolchain.scan_resources(path))
|
2013-06-10 14:44:08 +00:00
|
|
|
if libraries_paths is not None:
|
2013-07-24 16:29:11 +00:00
|
|
|
src_paths.extend(libraries_paths)
|
2013-06-10 14:44:08 +00:00
|
|
|
for path in libraries_paths:
|
|
|
|
resources.add(toolchain.scan_resources(path))
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
if linker_script is not None:
|
|
|
|
resources.linker_script = linker_script
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# Build Directory
|
|
|
|
if clean:
|
|
|
|
if exists(build_path):
|
|
|
|
rmtree(build_path)
|
|
|
|
mkdir(build_path)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2014-07-01 16:45:12 +00:00
|
|
|
# We need to add if necessary additional include directories
|
|
|
|
if inc_dirs:
|
|
|
|
if type(inc_dirs) == ListType:
|
|
|
|
resources.inc_dirs.extend(inc_dirs)
|
|
|
|
else:
|
|
|
|
resources.inc_dirs.append(inc_dirs)
|
|
|
|
|
2013-07-24 16:29:11 +00:00
|
|
|
# Compile Sources
|
|
|
|
for path in src_paths:
|
|
|
|
src = toolchain.scan_resources(path)
|
|
|
|
objects = toolchain.compile_sources(src, build_path, resources.inc_dirs)
|
|
|
|
resources.objects.extend(objects)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-07-24 16:29:11 +00:00
|
|
|
# Link Program
|
|
|
|
return toolchain.link_program(resources, build_path, name)
|
2013-06-10 14:44:08 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
|
2013-04-18 14:43:29 +00:00
|
|
|
def build_library(src_paths, build_path, target, toolchain_name,
|
2013-07-02 15:43:29 +00:00
|
|
|
dependencies_paths=None, options=None, name=None, clean=False,
|
2014-07-09 17:00:21 +00:00
|
|
|
notify=None, verbose=False, macros=None, inc_dirs=None, jobs=1):
|
2014-07-01 16:45:12 +00:00
|
|
|
""" src_path: the path of the source directory
|
|
|
|
build_path: the path of the build directory
|
|
|
|
target: ['LPC1768', 'LPC11U24', 'LPC2368']
|
|
|
|
toolchain: ['ARM', 'uARM', 'GCC_ARM', 'GCC_CS', 'GCC_CR']
|
|
|
|
library_paths: List of paths to additional libraries
|
|
|
|
clean: Rebuild everything if True
|
|
|
|
notify: Notify function for logs
|
|
|
|
verbose: Write the actual tools command lines if True
|
|
|
|
inc_dirs: additional include directories which should be included in build"""
|
|
|
|
if type(src_paths) != ListType:
|
|
|
|
src_paths = [src_paths]
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
for src_path in src_paths:
|
|
|
|
if not exists(src_path):
|
|
|
|
raise Exception("The library source folder does not exist: %s", src_path)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
# Toolchain instance
|
2014-06-02 14:44:45 +00:00
|
|
|
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
2013-02-18 15:32:11 +00:00
|
|
|
toolchain.VERBOSE = verbose
|
2014-07-09 17:00:21 +00:00
|
|
|
toolchain.jobs = jobs
|
2013-02-18 15:32:11 +00:00
|
|
|
toolchain.build_all = clean
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# The first path will give the name to the library
|
|
|
|
name = basename(src_paths[0])
|
2014-07-10 17:26:39 +00:00
|
|
|
toolchain.info("Building library %s (%s, %s)" % (name.upper(), target.name, toolchain_name))
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
# Scan Resources
|
|
|
|
resources = []
|
|
|
|
for src_path in src_paths:
|
|
|
|
resources.append(toolchain.scan_resources(src_path))
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# Dependencies Include Paths
|
2013-07-24 16:29:11 +00:00
|
|
|
dependencies_include_dir = []
|
2013-06-10 14:44:08 +00:00
|
|
|
if dependencies_paths is not None:
|
|
|
|
for path in dependencies_paths:
|
2013-07-24 16:29:11 +00:00
|
|
|
lib_resources = toolchain.scan_resources(path)
|
|
|
|
dependencies_include_dir.extend(lib_resources.inc_dirs)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2014-07-01 16:45:12 +00:00
|
|
|
if inc_dirs:
|
|
|
|
dependencies_include_dir.extend(inc_dirs)
|
|
|
|
|
2013-02-18 15:32:11 +00:00
|
|
|
# Create the desired build directory structure
|
|
|
|
bin_path = join(build_path, toolchain.obj_path)
|
|
|
|
mkdir(bin_path)
|
|
|
|
tmp_path = join(build_path, '.temp', toolchain.obj_path)
|
|
|
|
mkdir(tmp_path)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# Copy Headers
|
2013-02-18 15:32:11 +00:00
|
|
|
for resource in resources:
|
2013-06-14 16:32:15 +00:00
|
|
|
toolchain.copy_files(resource.headers, build_path, rel_path=resource.base_path)
|
2013-10-17 09:01:55 +00:00
|
|
|
dependencies_include_dir.extend(toolchain.scan_resources(build_path).inc_dirs)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# Compile Sources
|
2013-02-18 15:32:11 +00:00
|
|
|
objects = []
|
|
|
|
for resource in resources:
|
2013-07-24 16:29:11 +00:00
|
|
|
objects.extend(toolchain.compile_sources(resource, tmp_path, dependencies_include_dir))
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
toolchain.build_library(objects, bin_path, name)
|
2013-02-18 15:32:11 +00:00
|
|
|
|
|
|
|
|
2014-06-02 14:44:45 +00:00
|
|
|
def build_lib(lib_id, target, toolchain, options=None, verbose=False, clean=False, macros=None, notify=None):
|
2013-02-18 15:32:11 +00:00
|
|
|
lib = Library(lib_id)
|
|
|
|
if lib.is_supported(target, toolchain):
|
2014-07-01 16:45:12 +00:00
|
|
|
# We need to combine macros from parameter list with macros from library definition
|
|
|
|
MACROS = lib.macros if lib.macros else []
|
|
|
|
if macros:
|
|
|
|
MACROS.extend(macros)
|
|
|
|
|
2013-07-24 16:29:11 +00:00
|
|
|
build_library(lib.source_dir, lib.build_dir, target, toolchain,
|
|
|
|
lib.dependencies, options,
|
2014-07-01 16:45:12 +00:00
|
|
|
verbose=verbose, clean=clean, macros=MACROS, notify=notify, inc_dirs=lib.inc_dirs)
|
2013-02-18 15:32:11 +00:00
|
|
|
else:
|
2014-07-28 13:20:17 +00:00
|
|
|
print 'Library "%s" is not yet supported on target %s with toolchain %s' % (lib_id, target.name, toolchain)
|
2013-02-18 15:32:11 +00:00
|
|
|
|
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# We do have unique legacy conventions about how we build and package the mbed library
|
2014-07-09 17:00:21 +00:00
|
|
|
def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1):
|
2014-06-23 12:36:55 +00:00
|
|
|
""" Function returns True is library was built and false if building was skipped """
|
2013-06-10 14:44:08 +00:00
|
|
|
# Check toolchain support
|
|
|
|
if toolchain_name not in target.supported_toolchains:
|
2014-08-01 14:27:34 +00:00
|
|
|
supported_toolchains_text = ", ".join(target.supported_toolchains)
|
2014-07-09 13:51:54 +00:00
|
|
|
print '%s target is not yet supported by toolchain %s' % (target.name, toolchain_name)
|
2014-08-01 14:27:34 +00:00
|
|
|
print '%s target supports %s toolchain%s' % (target.name, supported_toolchains_text, 's' if len(target.supported_toolchains) > 1 else '')
|
2014-06-23 12:36:55 +00:00
|
|
|
return False
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# Toolchain
|
2014-06-02 14:44:45 +00:00
|
|
|
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
2013-06-10 14:44:08 +00:00
|
|
|
toolchain.VERBOSE = verbose
|
2014-07-09 17:00:21 +00:00
|
|
|
toolchain.jobs = jobs
|
2013-07-24 16:29:11 +00:00
|
|
|
toolchain.build_all = clean
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# Source and Build Paths
|
2013-06-24 13:32:08 +00:00
|
|
|
BUILD_TARGET = join(MBED_LIBRARIES, "TARGET_" + target.name)
|
|
|
|
BUILD_TOOLCHAIN = join(BUILD_TARGET, "TOOLCHAIN_" + toolchain.name)
|
2013-06-10 14:44:08 +00:00
|
|
|
mkdir(BUILD_TOOLCHAIN)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
TMP_PATH = join(MBED_LIBRARIES, '.temp', toolchain.obj_path)
|
|
|
|
mkdir(TMP_PATH)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# CMSIS
|
2014-07-10 17:26:39 +00:00
|
|
|
toolchain.info("Building library %s (%s, %s)"% ('CMSIS', target.name, toolchain_name))
|
2013-06-24 13:32:08 +00:00
|
|
|
cmsis_src = join(MBED_TARGETS_PATH, "cmsis")
|
2013-06-10 14:44:08 +00:00
|
|
|
resources = toolchain.scan_resources(cmsis_src)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-24 13:32:08 +00:00
|
|
|
toolchain.copy_files(resources.headers, BUILD_TARGET)
|
|
|
|
toolchain.copy_files(resources.linker_script, BUILD_TOOLCHAIN)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-28 20:05:27 +00:00
|
|
|
objects = toolchain.compile_sources(resources, TMP_PATH)
|
2013-06-14 16:32:15 +00:00
|
|
|
toolchain.copy_files(objects, BUILD_TOOLCHAIN)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-06-10 14:44:08 +00:00
|
|
|
# mbed
|
2014-07-10 17:26:39 +00:00
|
|
|
toolchain.info("Building library %s (%s, %s)" % ('MBED', target.name, toolchain_name))
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-07-23 16:22:57 +00:00
|
|
|
# Common Headers
|
2013-06-14 16:32:15 +00:00
|
|
|
toolchain.copy_files(toolchain.scan_resources(MBED_API).headers, MBED_LIBRARIES)
|
|
|
|
toolchain.copy_files(toolchain.scan_resources(MBED_HAL).headers, MBED_LIBRARIES)
|
2014-06-02 14:44:45 +00:00
|
|
|
|
2013-07-23 16:22:57 +00:00
|
|
|
# Target specific sources
|
|
|
|
HAL_SRC = join(MBED_TARGETS_PATH, "hal")
|
|
|
|
hal_implementation = toolchain.scan_resources(HAL_SRC)
|
Target K64F addition.
Squashed commit of the following:
commit db3c9f7682083abeb291e01df31e67e4c50845b3
Author: 0xc0170 <c0170@rocketmail.com>
Date: Wed Apr 2 09:52:00 2014 +0200
K64F - KSDK - Warnings fixes
commit a639a5cdff889c13509c954b0a34ebac861c1361
Merge: 67a2c2a f3de345
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Apr 1 12:48:35 2014 +0200
Merge branch latest 'master' into dev_target_k64f
Conflicts:
libraries/rtos/rtx/RTX_Conf_CM.c
workspace_tools/build_api.py
commit 67a2c2aeb976f264db52ea10d18fea9de0d7685f
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sun Mar 30 13:19:51 2014 +0200
K64F - PinName for buttons (SW2, SW3)
commit 957573e2cd42d5c73ed99477abb98c8b883695b2
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Mar 25 11:46:57 2014 +0100
K64F - pins addition to mbed HAL, uart - 4 instances, fix i2c instance which was not stored
commit 2347a6d03984e297190910a250f2771032ae6327
Author: sg- <sam.w.grove@gmail.com>
Date: Mon Mar 24 15:20:51 2014 -0500
Added wait to i2c stop
commit b7b4a9c72e8724087a44078c41a2cb33e4c8d5e3
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Mar 24 19:28:16 2014 +0100
K64F - I2c - ack flag retreive correction (logic inverted in ksdk hal)
commit 46c875251263029e32463c3b48473b10496088d9
Author: sg- <sam.w.grove@gmail.com>
Date: Mon Mar 24 13:16:18 2014 -0500
Added I2C Pinnames
commit b71c7a0dfba7025662f9a9d176494ce4dc86273e
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Mar 18 17:02:34 2014 +0100
K64F Arduino pinNames update
commit d41b0ee493263d1d80fcb72b3f0d4d788359c7c9
Merge: 9c0a982 e2574eb
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Mar 18 14:57:57 2014 +0100
Merge remote-tracking branch 'upstream/master' into dev_target_k64f.
K64F gpio changed according to the latest mbed master.
Conflicts:
libraries/rtos/rtx/RTX_CM_lib.h
workspace_tools/export/uvision4.py
commit 9c0a9822ab14263fff5e3b6459b7c2b4a77ce30c
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Mar 17 21:08:17 2014 +0100
K64F - sleep support
commit 5edcf3603d2e7b00eedbb377203a054b7a01e51d
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sun Mar 16 18:19:55 2014 +0100
K64F - pullup/down corrections, LED1 - R, LED2 - G, LED3 - B
commit a2b3b53a1474d32779654765cd1ce2ba2c6b2186
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Mar 13 20:55:39 2014 +0100
K64F - SPI - delays are set, pin definition for tests
commit 1f3b3abe16f4afaaf1b75cb4bf3e3a9d5b6e50a7
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Mar 11 21:26:00 2014 +0100
K64F - DAC update - tested with test a8
- internal reference set to VDDA
- PinName DAC0_OUT
commit 26d8cf47f8c0786b290ae659beb022901029b313
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Mar 11 08:31:44 2014 +0100
KSDK - drivers layer removal, mbed HAL using only KSDK HAL
- ADC corrections with channels, and clock configuration
commit 67ebe14f5c88725033ea0fb135d94b6bf9a00fdb
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Mar 10 12:46:08 2014 +0100
K20 copy files removed, targets.py - vertical alignment for K64F definition
commit be5c562d513c808e5bd425195a4fb1c71f47a57e
Merge: 696a713 fe0aca9
Author: Emilio Monti <emilmont@gmail.com>
Date: Mon Mar 10 11:14:55 2014 +0000
Merge branch 'rtos_support' into dev_target_k64f
commit 696a713751194b4762f1cdf6c17c0786decd7808
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Mar 10 12:05:30 2014 +0100
[FIX] K64F - adc, sgtl driver updates
commit fe0aca9940bbdd5ee70a1a7341a0a2ad2abf912b
Author: Emilio Monti <emilmont@gmail.com>
Date: Mon Mar 10 11:04:16 2014 +0000
Add RTOS support for K64F
commit 5c3edcbca6dbcce628c7cde51ac94a6fc6278ba5
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sun Mar 9 20:43:38 2014 +0100
K64F - uvision templates update
- uvision 5.10 supports K64F
commit 33f18d11d0eadb9243f1be0ae96c5f82e2913d48
Merge: 26f7587 74e9b2e
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sat Mar 8 10:34:25 2014 +0100
Update branch from mbed master
- merge branch 'master' into dev_target_k64f
Conflicts:
libraries/USBDevice/USBDevice/USBEndpoints.h
libraries/USBDevice/USBDevice/USBHAL_KL25Z.cpp
workspace_tools/export/uvision4.py
workspace_tools/targets.py
commit 26f75872b19a1db2a3abb34c6e773bac56acb32f
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Mar 6 22:15:53 2014 +0100
K64F - USBDevice - MPU disable in init
commit e54d6bbaa68827bd63058fbf2428e289d15ac1f7
Author: 0xc0170 <c0170@rocketmail.com>
Date: Wed Feb 26 21:06:58 2014 +0100
K64F - clock setup 4 (usb clock enable)
commit c4165732b9520cb31ae3d649d50c353d09dc9932
Author: 0xc0170 <c0170@rocketmail.com>
Date: Wed Feb 26 20:01:47 2014 +0100
K64F - USBDevice addition
commit 9fcdbb8562b1415561b04e902fcdbb4724add5af
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Feb 24 19:11:48 2014 +0100
K64F SPI HAL - initial version
commit 8093df58fa7d17fcb5ad04872c958d5254ee1d8a
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sat Feb 22 13:14:44 2014 +0100
K64F - RTC and I2C implementation (using KPSDK HAL)
- instance correction in objects and peripherals names headers
commit 7ef3fbda605c2bd53a86f37d0676c0393b2e2949
Author: 0xc0170 <c0170@rocketmail.com>
Date: Fri Feb 14 09:45:27 2014 +0100
mbed RTC HAL for K64F
commit e40332fd2db8bf36b3e6cabac5729e013da40c28
Merge: e059f65 6bfcd87
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Feb 13 14:20:20 2014 +0100
Merge branch 'master' into dev_target_k64f
Conflicts:
workspace_tools/build_api.py
workspace_tools/export/uvision4.py
workspace_tools/targets.py
workspace_tools/toolchains/__init__.py
commit e059f65fd09694418f9fa4f38da90954ab9decfe
Author: 0xc0170 <c0170@rocketmail.com>
Date: Wed Feb 5 21:35:49 2014 +0100
pwm mbed HAL
- using jusst ftm hal from KPSDK, not yet functional
commit b784278872b1d66ce2940f4988e0479971de8bc0
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Feb 3 18:28:24 2014 +0100
uvision exporters for K64F, uticker - lptmr
- lptmr - no hal neiter driver, quick implementation using registers and internal clock
- exporters for K64F - using K60 1MB target, because K64F is not available in 4.7 yet
commit 7a030693e025c2bd456563f3e6f4456033d3f644
Author: Bogdan Marinescu <bogdan.marinescu@arm.com>
Date: Tue Jan 28 16:29:54 2014 +0200
Attempt to keep target's include directory structure
commit a2445b383224125abf4ee23bd17f1e685010a4a5
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Jan 27 07:25:16 2014 +0100
Original KPSDK include directory structure for device
commit 9c07c58bb9cf5e9d8be4c3bec117ee87a5ea81c0
Author: 0xc0170 <c0170@rocketmail.com>
Date: Fri Jan 24 16:51:17 2014 +0000
K64F ADC - initial commit
- ADC using KPSDK driver
commit 88e03ef8c5855a57887bb36cddfa5ab1491d400c
Author: 0xc0170 <c0170@rocketmail.com>
Date: Fri Jan 24 12:18:14 2014 +0000
GPI IRQ
- nvic vectors number correction
- gpio irq HAL implementation
commit e83f1108ae9f779ce240d6cdfe23532bfa00a55e
Author: 0xc0170 <c0170@rocketmail.com>
Date: Fri Jan 24 10:06:44 2014 +0000
PORT HAL implementation
- using gpio hal port
commit 75c21943200c8240d1edaf0a67f84b9f3b43db7f
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Jan 23 16:02:36 2014 +0000
Serial (only 8bit at the moment), using KPSDK HAL
commit 296e79def617f005918cd8e2aa574f2908a362ca
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Jan 23 08:35:50 2014 +0000
Folder structure correction for K64F - KPSDK
- scripts reverted, only new macro is available
- K64F specific headers are in HAL in device folder
commit f236b1ffcb9c8b443ad8483bca8b0e564a63f004
Author: 0xc0170 <c0170@rocketmail.com>
Date: Wed Jan 22 16:07:30 2014 +0100
update KPSDK to RC1
- the update causes few more dependences which were reported. Will be removed later (usb, boards)
- pit timer - hal use , pit driver uses us period
commit f02c5353d4920e885f803ad235e5e82001e97b94
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Jan 21 09:45:55 2014 +0100
KPSDK In/out declaration removal
commit 8c88e098b4dc4901753309f1e6db4adb8aca4384
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Jan 21 09:12:41 2014 +0100
gpio_t struct only needs pinName
- gpio_init creates init objects on stack
commit 6b96d4ea2c5a6a2cb13571d740ffb679a62f8f3d
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Jan 20 19:59:03 2014 +0100
us ticker - pit implementation (not functional yet)
- pit driver in KPSDK - added sdk prefix to needed functions
commit 098e60a3846abcd4c9c00bd199b01d4b1899807f
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Jan 20 13:01:58 2014 +0100
GPIO HAL - gpio_set implementation
commit 2bfebbfc75dcd08c20297ba42dc0cc82e5381a40
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sun Jan 19 20:46:55 2014 +0100
GPIO KPSDK changes
- gpio driver - sdk prefix, no lookuptable, input/output declaration, refactoring, set MUX to GPIO
- gpio api in mbed implementation, tested on blue led
commit d083733c485fbdd79ed9ce87100df9fee82294a7
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sat Jan 18 17:14:09 2014 +0100
Update folder structure for KPSDK
- drivers addition
- usb (needed by drivers - needs to be fixed)
- utilities
- hal folder
- drivers/flash removed (needs to be fixed)
- usb host removed (needs to be fixed)
commit 9abcf3d94a2cc849cd6e586c1bad650b6a340a0c
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Jan 16 11:06:16 2014 +0100
Initial commit for K64F
- KPSDK addition
- CMSIS + HAL for K64F
- HAL is not yet implemented
- scripts - target contain macros, ignore folders, cmsis copy folders
2014-04-02 12:39:01 +00:00
|
|
|
toolchain.copy_files(hal_implementation.headers + hal_implementation.hex_files, BUILD_TARGET, HAL_SRC)
|
|
|
|
incdirs = toolchain.scan_resources(BUILD_TARGET).inc_dirs
|
|
|
|
objects = toolchain.compile_sources(hal_implementation, TMP_PATH, [MBED_LIBRARIES] + incdirs)
|
|
|
|
|
2013-07-23 16:22:57 +00:00
|
|
|
# Common Sources
|
|
|
|
mbed_resources = toolchain.scan_resources(MBED_COMMON)
|
Target K64F addition.
Squashed commit of the following:
commit db3c9f7682083abeb291e01df31e67e4c50845b3
Author: 0xc0170 <c0170@rocketmail.com>
Date: Wed Apr 2 09:52:00 2014 +0200
K64F - KSDK - Warnings fixes
commit a639a5cdff889c13509c954b0a34ebac861c1361
Merge: 67a2c2a f3de345
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Apr 1 12:48:35 2014 +0200
Merge branch latest 'master' into dev_target_k64f
Conflicts:
libraries/rtos/rtx/RTX_Conf_CM.c
workspace_tools/build_api.py
commit 67a2c2aeb976f264db52ea10d18fea9de0d7685f
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sun Mar 30 13:19:51 2014 +0200
K64F - PinName for buttons (SW2, SW3)
commit 957573e2cd42d5c73ed99477abb98c8b883695b2
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Mar 25 11:46:57 2014 +0100
K64F - pins addition to mbed HAL, uart - 4 instances, fix i2c instance which was not stored
commit 2347a6d03984e297190910a250f2771032ae6327
Author: sg- <sam.w.grove@gmail.com>
Date: Mon Mar 24 15:20:51 2014 -0500
Added wait to i2c stop
commit b7b4a9c72e8724087a44078c41a2cb33e4c8d5e3
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Mar 24 19:28:16 2014 +0100
K64F - I2c - ack flag retreive correction (logic inverted in ksdk hal)
commit 46c875251263029e32463c3b48473b10496088d9
Author: sg- <sam.w.grove@gmail.com>
Date: Mon Mar 24 13:16:18 2014 -0500
Added I2C Pinnames
commit b71c7a0dfba7025662f9a9d176494ce4dc86273e
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Mar 18 17:02:34 2014 +0100
K64F Arduino pinNames update
commit d41b0ee493263d1d80fcb72b3f0d4d788359c7c9
Merge: 9c0a982 e2574eb
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Mar 18 14:57:57 2014 +0100
Merge remote-tracking branch 'upstream/master' into dev_target_k64f.
K64F gpio changed according to the latest mbed master.
Conflicts:
libraries/rtos/rtx/RTX_CM_lib.h
workspace_tools/export/uvision4.py
commit 9c0a9822ab14263fff5e3b6459b7c2b4a77ce30c
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Mar 17 21:08:17 2014 +0100
K64F - sleep support
commit 5edcf3603d2e7b00eedbb377203a054b7a01e51d
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sun Mar 16 18:19:55 2014 +0100
K64F - pullup/down corrections, LED1 - R, LED2 - G, LED3 - B
commit a2b3b53a1474d32779654765cd1ce2ba2c6b2186
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Mar 13 20:55:39 2014 +0100
K64F - SPI - delays are set, pin definition for tests
commit 1f3b3abe16f4afaaf1b75cb4bf3e3a9d5b6e50a7
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Mar 11 21:26:00 2014 +0100
K64F - DAC update - tested with test a8
- internal reference set to VDDA
- PinName DAC0_OUT
commit 26d8cf47f8c0786b290ae659beb022901029b313
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Mar 11 08:31:44 2014 +0100
KSDK - drivers layer removal, mbed HAL using only KSDK HAL
- ADC corrections with channels, and clock configuration
commit 67ebe14f5c88725033ea0fb135d94b6bf9a00fdb
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Mar 10 12:46:08 2014 +0100
K20 copy files removed, targets.py - vertical alignment for K64F definition
commit be5c562d513c808e5bd425195a4fb1c71f47a57e
Merge: 696a713 fe0aca9
Author: Emilio Monti <emilmont@gmail.com>
Date: Mon Mar 10 11:14:55 2014 +0000
Merge branch 'rtos_support' into dev_target_k64f
commit 696a713751194b4762f1cdf6c17c0786decd7808
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Mar 10 12:05:30 2014 +0100
[FIX] K64F - adc, sgtl driver updates
commit fe0aca9940bbdd5ee70a1a7341a0a2ad2abf912b
Author: Emilio Monti <emilmont@gmail.com>
Date: Mon Mar 10 11:04:16 2014 +0000
Add RTOS support for K64F
commit 5c3edcbca6dbcce628c7cde51ac94a6fc6278ba5
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sun Mar 9 20:43:38 2014 +0100
K64F - uvision templates update
- uvision 5.10 supports K64F
commit 33f18d11d0eadb9243f1be0ae96c5f82e2913d48
Merge: 26f7587 74e9b2e
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sat Mar 8 10:34:25 2014 +0100
Update branch from mbed master
- merge branch 'master' into dev_target_k64f
Conflicts:
libraries/USBDevice/USBDevice/USBEndpoints.h
libraries/USBDevice/USBDevice/USBHAL_KL25Z.cpp
workspace_tools/export/uvision4.py
workspace_tools/targets.py
commit 26f75872b19a1db2a3abb34c6e773bac56acb32f
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Mar 6 22:15:53 2014 +0100
K64F - USBDevice - MPU disable in init
commit e54d6bbaa68827bd63058fbf2428e289d15ac1f7
Author: 0xc0170 <c0170@rocketmail.com>
Date: Wed Feb 26 21:06:58 2014 +0100
K64F - clock setup 4 (usb clock enable)
commit c4165732b9520cb31ae3d649d50c353d09dc9932
Author: 0xc0170 <c0170@rocketmail.com>
Date: Wed Feb 26 20:01:47 2014 +0100
K64F - USBDevice addition
commit 9fcdbb8562b1415561b04e902fcdbb4724add5af
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Feb 24 19:11:48 2014 +0100
K64F SPI HAL - initial version
commit 8093df58fa7d17fcb5ad04872c958d5254ee1d8a
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sat Feb 22 13:14:44 2014 +0100
K64F - RTC and I2C implementation (using KPSDK HAL)
- instance correction in objects and peripherals names headers
commit 7ef3fbda605c2bd53a86f37d0676c0393b2e2949
Author: 0xc0170 <c0170@rocketmail.com>
Date: Fri Feb 14 09:45:27 2014 +0100
mbed RTC HAL for K64F
commit e40332fd2db8bf36b3e6cabac5729e013da40c28
Merge: e059f65 6bfcd87
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Feb 13 14:20:20 2014 +0100
Merge branch 'master' into dev_target_k64f
Conflicts:
workspace_tools/build_api.py
workspace_tools/export/uvision4.py
workspace_tools/targets.py
workspace_tools/toolchains/__init__.py
commit e059f65fd09694418f9fa4f38da90954ab9decfe
Author: 0xc0170 <c0170@rocketmail.com>
Date: Wed Feb 5 21:35:49 2014 +0100
pwm mbed HAL
- using jusst ftm hal from KPSDK, not yet functional
commit b784278872b1d66ce2940f4988e0479971de8bc0
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Feb 3 18:28:24 2014 +0100
uvision exporters for K64F, uticker - lptmr
- lptmr - no hal neiter driver, quick implementation using registers and internal clock
- exporters for K64F - using K60 1MB target, because K64F is not available in 4.7 yet
commit 7a030693e025c2bd456563f3e6f4456033d3f644
Author: Bogdan Marinescu <bogdan.marinescu@arm.com>
Date: Tue Jan 28 16:29:54 2014 +0200
Attempt to keep target's include directory structure
commit a2445b383224125abf4ee23bd17f1e685010a4a5
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Jan 27 07:25:16 2014 +0100
Original KPSDK include directory structure for device
commit 9c07c58bb9cf5e9d8be4c3bec117ee87a5ea81c0
Author: 0xc0170 <c0170@rocketmail.com>
Date: Fri Jan 24 16:51:17 2014 +0000
K64F ADC - initial commit
- ADC using KPSDK driver
commit 88e03ef8c5855a57887bb36cddfa5ab1491d400c
Author: 0xc0170 <c0170@rocketmail.com>
Date: Fri Jan 24 12:18:14 2014 +0000
GPI IRQ
- nvic vectors number correction
- gpio irq HAL implementation
commit e83f1108ae9f779ce240d6cdfe23532bfa00a55e
Author: 0xc0170 <c0170@rocketmail.com>
Date: Fri Jan 24 10:06:44 2014 +0000
PORT HAL implementation
- using gpio hal port
commit 75c21943200c8240d1edaf0a67f84b9f3b43db7f
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Jan 23 16:02:36 2014 +0000
Serial (only 8bit at the moment), using KPSDK HAL
commit 296e79def617f005918cd8e2aa574f2908a362ca
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Jan 23 08:35:50 2014 +0000
Folder structure correction for K64F - KPSDK
- scripts reverted, only new macro is available
- K64F specific headers are in HAL in device folder
commit f236b1ffcb9c8b443ad8483bca8b0e564a63f004
Author: 0xc0170 <c0170@rocketmail.com>
Date: Wed Jan 22 16:07:30 2014 +0100
update KPSDK to RC1
- the update causes few more dependences which were reported. Will be removed later (usb, boards)
- pit timer - hal use , pit driver uses us period
commit f02c5353d4920e885f803ad235e5e82001e97b94
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Jan 21 09:45:55 2014 +0100
KPSDK In/out declaration removal
commit 8c88e098b4dc4901753309f1e6db4adb8aca4384
Author: 0xc0170 <c0170@rocketmail.com>
Date: Tue Jan 21 09:12:41 2014 +0100
gpio_t struct only needs pinName
- gpio_init creates init objects on stack
commit 6b96d4ea2c5a6a2cb13571d740ffb679a62f8f3d
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Jan 20 19:59:03 2014 +0100
us ticker - pit implementation (not functional yet)
- pit driver in KPSDK - added sdk prefix to needed functions
commit 098e60a3846abcd4c9c00bd199b01d4b1899807f
Author: 0xc0170 <c0170@rocketmail.com>
Date: Mon Jan 20 13:01:58 2014 +0100
GPIO HAL - gpio_set implementation
commit 2bfebbfc75dcd08c20297ba42dc0cc82e5381a40
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sun Jan 19 20:46:55 2014 +0100
GPIO KPSDK changes
- gpio driver - sdk prefix, no lookuptable, input/output declaration, refactoring, set MUX to GPIO
- gpio api in mbed implementation, tested on blue led
commit d083733c485fbdd79ed9ce87100df9fee82294a7
Author: 0xc0170 <c0170@rocketmail.com>
Date: Sat Jan 18 17:14:09 2014 +0100
Update folder structure for KPSDK
- drivers addition
- usb (needed by drivers - needs to be fixed)
- utilities
- hal folder
- drivers/flash removed (needs to be fixed)
- usb host removed (needs to be fixed)
commit 9abcf3d94a2cc849cd6e586c1bad650b6a340a0c
Author: 0xc0170 <c0170@rocketmail.com>
Date: Thu Jan 16 11:06:16 2014 +0100
Initial commit for K64F
- KPSDK addition
- CMSIS + HAL for K64F
- HAL is not yet implemented
- scripts - target contain macros, ignore folders, cmsis copy folders
2014-04-02 12:39:01 +00:00
|
|
|
objects += toolchain.compile_sources(mbed_resources, TMP_PATH, [MBED_LIBRARIES] + incdirs)
|
2014-03-25 11:43:54 +00:00
|
|
|
|
|
|
|
# A number of compiled files need to be copied as objects as opposed to
|
|
|
|
# being part of the mbed library, for reasons that have to do with the way
|
|
|
|
# the linker search for symbols in archives. These are:
|
|
|
|
# - retarget.o: to make sure that the C standard lib symbols get overridden
|
|
|
|
# - board.o: mbed_die is weak
|
|
|
|
# - mbed_overrides.o: this contains platform overrides of various weak SDK functions
|
|
|
|
separate_names, separate_objects = ['retarget.o', 'board.o', 'mbed_overrides.o'], []
|
2013-06-14 16:32:15 +00:00
|
|
|
for o in objects:
|
2014-03-25 11:43:54 +00:00
|
|
|
for name in separate_names:
|
|
|
|
if o.endswith(name):
|
|
|
|
separate_objects.append(o)
|
|
|
|
for o in separate_objects:
|
|
|
|
objects.remove(o)
|
2013-06-10 14:44:08 +00:00
|
|
|
toolchain.build_library(objects, BUILD_TOOLCHAIN, "mbed")
|
2014-03-25 11:43:54 +00:00
|
|
|
for o in separate_objects:
|
|
|
|
toolchain.copy_files(o, BUILD_TOOLCHAIN)
|
2014-06-23 12:36:55 +00:00
|
|
|
return True
|
2014-06-09 15:10:47 +00:00
|
|
|
|
2014-08-04 13:29:20 +00:00
|
|
|
|
2014-06-09 15:10:47 +00:00
|
|
|
def get_unique_supported_toolchains():
|
|
|
|
""" Get list of all unique toolchains supported by targets """
|
|
|
|
unique_supported_toolchains = []
|
|
|
|
for target in TARGET_NAMES:
|
|
|
|
for toolchain in TARGET_MAP[target].supported_toolchains:
|
|
|
|
if toolchain not in unique_supported_toolchains:
|
|
|
|
unique_supported_toolchains.append(toolchain)
|
|
|
|
return unique_supported_toolchains
|
|
|
|
|
|
|
|
|
2014-07-29 13:48:48 +00:00
|
|
|
def mcu_toolchain_matrix(verbose_html=False, platform_filter=None):
|
2014-06-09 15:10:47 +00:00
|
|
|
""" Shows target map using prettytable """
|
|
|
|
unique_supported_toolchains = get_unique_supported_toolchains()
|
|
|
|
from prettytable import PrettyTable # Only use it in this function so building works without extra modules
|
|
|
|
|
|
|
|
# All tests status table print
|
|
|
|
columns = ["Platform"] + unique_supported_toolchains
|
|
|
|
pt = PrettyTable(["Platform"] + unique_supported_toolchains)
|
|
|
|
# Align table
|
|
|
|
for col in columns:
|
|
|
|
pt.align[col] = "c"
|
|
|
|
pt.align["Platform"] = "l"
|
|
|
|
|
2014-07-01 16:45:12 +00:00
|
|
|
perm_counter = 0
|
2014-07-29 14:43:41 +00:00
|
|
|
target_counter = 0
|
2014-06-09 15:10:47 +00:00
|
|
|
for target in sorted(TARGET_NAMES):
|
2014-07-29 13:48:48 +00:00
|
|
|
if platform_filter is not None:
|
|
|
|
# FIlter out platforms using regex
|
|
|
|
if re.search(platform_filter, target) is None:
|
|
|
|
continue
|
2014-07-29 14:43:41 +00:00
|
|
|
target_counter += 1
|
2014-07-29 13:48:48 +00:00
|
|
|
|
2014-06-09 15:10:47 +00:00
|
|
|
row = [target] # First column is platform name
|
2014-07-03 09:27:08 +00:00
|
|
|
default_toolchain = TARGET_MAP[target].default_toolchain
|
2014-06-09 15:10:47 +00:00
|
|
|
for unique_toolchain in unique_supported_toolchains:
|
|
|
|
text = "-"
|
2014-07-03 09:27:08 +00:00
|
|
|
if default_toolchain == unique_toolchain:
|
2014-07-02 10:07:42 +00:00
|
|
|
text = "Default"
|
2014-07-08 13:09:50 +00:00
|
|
|
perm_counter += 1
|
2014-07-02 10:07:42 +00:00
|
|
|
elif unique_toolchain in TARGET_MAP[target].supported_toolchains:
|
2014-06-09 15:10:47 +00:00
|
|
|
text = "Supported"
|
2014-06-09 15:25:53 +00:00
|
|
|
perm_counter += 1
|
2014-07-01 16:45:12 +00:00
|
|
|
row.append(text)
|
2014-06-09 15:10:47 +00:00
|
|
|
pt.add_row(row)
|
2014-06-11 12:15:14 +00:00
|
|
|
|
|
|
|
result = pt.get_html_string() if verbose_html else pt.get_string()
|
|
|
|
result += "\n"
|
2014-07-02 10:07:42 +00:00
|
|
|
result += "*Default - default on-line compiler\n"
|
|
|
|
result += "*Supported - supported off-line compiler\n"
|
|
|
|
result += "\n"
|
2014-07-29 14:43:41 +00:00
|
|
|
result += "Total platforms: %d\n"% (target_counter)
|
2014-06-11 12:15:14 +00:00
|
|
|
result += "Total permutations: %d"% (perm_counter)
|
|
|
|
return result
|
2014-06-10 14:29:15 +00:00
|
|
|
|
|
|
|
|
2014-07-10 09:56:14 +00:00
|
|
|
def get_target_supported_toolchains(target):
|
|
|
|
""" Returns target supported toolchains list """
|
|
|
|
return TARGET_MAP[target].supported_toolchains if target in TARGET_MAP else None
|
|
|
|
|
|
|
|
|
2014-07-09 17:00:21 +00:00
|
|
|
def static_analysis_scan(target, toolchain_name, CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1):
|
2014-06-10 14:29:15 +00:00
|
|
|
# Toolchain
|
|
|
|
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
|
|
|
toolchain.VERBOSE = verbose
|
2014-07-09 17:00:21 +00:00
|
|
|
toolchain.jobs = jobs
|
2014-06-10 14:29:15 +00:00
|
|
|
toolchain.build_all = clean
|
|
|
|
|
|
|
|
# Source and Build Paths
|
|
|
|
BUILD_TARGET = join(MBED_LIBRARIES, "TARGET_" + target.name)
|
|
|
|
BUILD_TOOLCHAIN = join(BUILD_TARGET, "TOOLCHAIN_" + toolchain.name)
|
|
|
|
mkdir(BUILD_TOOLCHAIN)
|
|
|
|
|
|
|
|
TMP_PATH = join(MBED_LIBRARIES, '.temp', toolchain.obj_path)
|
|
|
|
mkdir(TMP_PATH)
|
|
|
|
|
|
|
|
# CMSIS
|
2014-07-10 17:26:39 +00:00
|
|
|
toolchain.info("Static analysis for %s (%s, %s)" % ('CMSIS', target.name, toolchain_name))
|
2014-06-10 14:29:15 +00:00
|
|
|
cmsis_src = join(MBED_TARGETS_PATH, "cmsis")
|
|
|
|
resources = toolchain.scan_resources(cmsis_src)
|
|
|
|
|
2014-06-10 15:38:43 +00:00
|
|
|
# Copy files before analysis
|
2014-06-10 14:29:15 +00:00
|
|
|
toolchain.copy_files(resources.headers, BUILD_TARGET)
|
|
|
|
toolchain.copy_files(resources.linker_script, BUILD_TOOLCHAIN)
|
|
|
|
|
2014-06-10 15:38:43 +00:00
|
|
|
# Gather include paths, c, cpp sources and macros to transfer to cppcheck command line
|
2014-06-12 15:03:03 +00:00
|
|
|
includes = ["-I%s"% i for i in resources.inc_dirs]
|
|
|
|
includes.append("-I%s"% str(BUILD_TARGET))
|
2014-06-10 14:29:15 +00:00
|
|
|
c_sources = " ".join(resources.c_sources)
|
|
|
|
cpp_sources = " ".join(resources.cpp_sources)
|
2014-06-12 15:03:03 +00:00
|
|
|
macros = ["-D%s"% s for s in toolchain.get_symbols() + toolchain.macros]
|
2014-06-10 14:29:15 +00:00
|
|
|
|
2014-06-11 16:08:35 +00:00
|
|
|
includes = map(str.strip, includes)
|
|
|
|
macros = map(str.strip, macros)
|
2014-06-11 13:47:54 +00:00
|
|
|
|
2014-06-11 16:08:35 +00:00
|
|
|
check_cmd = CPPCHECK_CMD
|
|
|
|
check_cmd += CPPCHECK_MSG_FORMAT
|
|
|
|
check_cmd += includes
|
|
|
|
check_cmd += macros
|
|
|
|
|
|
|
|
# We need to pass some params via file to avoid "command line too long in some OSs"
|
2014-06-11 13:47:54 +00:00
|
|
|
tmp_file = tempfile.NamedTemporaryFile(delete=False)
|
|
|
|
tmp_file.writelines(line + '\n' for line in c_sources.split())
|
|
|
|
tmp_file.writelines(line + '\n' for line in cpp_sources.split())
|
|
|
|
tmp_file.close()
|
2014-06-11 16:08:35 +00:00
|
|
|
check_cmd += ["--file-list=%s"% tmp_file.name]
|
2014-06-10 14:29:15 +00:00
|
|
|
|
2014-06-11 16:08:35 +00:00
|
|
|
_stdout, _stderr, _rc = run_cmd(check_cmd)
|
2014-06-10 15:38:43 +00:00
|
|
|
if verbose:
|
2014-06-11 14:26:00 +00:00
|
|
|
print _stdout
|
|
|
|
print _stderr
|
2014-06-10 14:29:15 +00:00
|
|
|
|
2014-06-11 13:47:54 +00:00
|
|
|
# =========================================================================
|
2014-06-11 14:07:38 +00:00
|
|
|
|
2014-06-10 14:29:15 +00:00
|
|
|
# MBED
|
2014-07-10 17:26:39 +00:00
|
|
|
toolchain.info("Static analysis for %s (%s, %s)" % ('MBED', target.name, toolchain_name))
|
2014-06-10 14:29:15 +00:00
|
|
|
|
|
|
|
# Common Headers
|
|
|
|
toolchain.copy_files(toolchain.scan_resources(MBED_API).headers, MBED_LIBRARIES)
|
|
|
|
toolchain.copy_files(toolchain.scan_resources(MBED_HAL).headers, MBED_LIBRARIES)
|
|
|
|
|
|
|
|
# Target specific sources
|
|
|
|
HAL_SRC = join(MBED_TARGETS_PATH, "hal")
|
|
|
|
hal_implementation = toolchain.scan_resources(HAL_SRC)
|
2014-06-10 15:38:43 +00:00
|
|
|
|
|
|
|
# Copy files before analysis
|
2014-06-10 14:29:15 +00:00
|
|
|
toolchain.copy_files(hal_implementation.headers + hal_implementation.hex_files, BUILD_TARGET, HAL_SRC)
|
|
|
|
incdirs = toolchain.scan_resources(BUILD_TARGET)
|
|
|
|
|
2014-06-11 16:08:35 +00:00
|
|
|
target_includes = ["-I%s" % i for i in incdirs.inc_dirs]
|
2014-06-12 15:03:03 +00:00
|
|
|
target_includes.append("-I%s"% str(BUILD_TARGET))
|
|
|
|
target_includes.append("-I%s"% str(HAL_SRC))
|
2014-06-10 14:29:15 +00:00
|
|
|
target_c_sources = " ".join(incdirs.c_sources)
|
|
|
|
target_cpp_sources = " ".join(incdirs.cpp_sources)
|
2014-06-12 15:03:03 +00:00
|
|
|
target_macros = ["-D%s"% s for s in toolchain.get_symbols() + toolchain.macros]
|
2014-06-10 14:29:15 +00:00
|
|
|
|
|
|
|
# Common Sources
|
|
|
|
mbed_resources = toolchain.scan_resources(MBED_COMMON)
|
|
|
|
|
2014-06-10 15:38:43 +00:00
|
|
|
# Gather include paths, c, cpp sources and macros to transfer to cppcheck command line
|
2014-06-11 16:08:35 +00:00
|
|
|
mbed_includes = ["-I%s" % i for i in mbed_resources.inc_dirs]
|
2014-06-12 15:03:03 +00:00
|
|
|
mbed_includes.append("-I%s"% str(BUILD_TARGET))
|
|
|
|
mbed_includes.append("-I%s"% str(MBED_COMMON))
|
|
|
|
mbed_includes.append("-I%s"% str(MBED_API))
|
|
|
|
mbed_includes.append("-I%s"% str(MBED_HAL))
|
2014-06-10 14:29:15 +00:00
|
|
|
mbed_c_sources = " ".join(mbed_resources.c_sources)
|
|
|
|
mbed_cpp_sources = " ".join(mbed_resources.cpp_sources)
|
|
|
|
|
2014-06-11 16:08:35 +00:00
|
|
|
target_includes = map(str.strip, target_includes)
|
|
|
|
mbed_includes = map(str.strip, mbed_includes)
|
|
|
|
target_macros = map(str.strip, target_macros)
|
|
|
|
|
|
|
|
check_cmd = CPPCHECK_CMD
|
|
|
|
check_cmd += CPPCHECK_MSG_FORMAT
|
|
|
|
check_cmd += target_includes
|
|
|
|
check_cmd += mbed_includes
|
|
|
|
check_cmd += target_macros
|
2014-06-11 13:47:54 +00:00
|
|
|
|
|
|
|
# We need to pass some parames via file to avoid "command line too long in some OSs"
|
|
|
|
tmp_file = tempfile.NamedTemporaryFile(delete=False)
|
|
|
|
tmp_file.writelines(line + '\n' for line in target_c_sources.split())
|
|
|
|
tmp_file.writelines(line + '\n' for line in target_cpp_sources.split())
|
|
|
|
tmp_file.writelines(line + '\n' for line in mbed_c_sources.split())
|
|
|
|
tmp_file.writelines(line + '\n' for line in mbed_cpp_sources.split())
|
|
|
|
tmp_file.close()
|
2014-06-11 16:08:35 +00:00
|
|
|
check_cmd += ["--file-list=%s"% tmp_file.name]
|
2014-06-10 14:29:15 +00:00
|
|
|
|
2014-06-11 16:08:35 +00:00
|
|
|
_stdout, _stderr, _rc = run_cmd_ext(check_cmd)
|
2014-06-10 15:38:43 +00:00
|
|
|
if verbose:
|
2014-06-11 14:26:00 +00:00
|
|
|
print _stdout
|
|
|
|
print _stderr
|
2014-06-10 16:25:54 +00:00
|
|
|
|
|
|
|
|
2014-07-01 16:45:12 +00:00
|
|
|
def static_analysis_scan_lib(lib_id, target, toolchain, cppcheck_cmd, cppcheck_msg_format,
|
|
|
|
options=None, verbose=False, clean=False, macros=None, notify=None):
|
2014-06-10 16:25:54 +00:00
|
|
|
lib = Library(lib_id)
|
|
|
|
if lib.is_supported(target, toolchain):
|
2014-07-01 16:45:12 +00:00
|
|
|
static_analysis_scan_library(lib.source_dir, lib.build_dir, target, toolchain, cppcheck_cmd, cppcheck_msg_format,
|
2014-06-10 16:25:54 +00:00
|
|
|
lib.dependencies, options,
|
|
|
|
verbose=verbose, clean=clean, macros=macros, notify=notify)
|
|
|
|
else:
|
|
|
|
print 'Library "%s" is not yet supported on target %s with toolchain %s' % (lib_id, target.name, toolchain)
|
|
|
|
|
|
|
|
|
2014-07-01 16:45:12 +00:00
|
|
|
def static_analysis_scan_library(src_paths, build_path, target, toolchain_name, cppcheck_cmd, cppcheck_msg_format,
|
2014-06-10 16:25:54 +00:00
|
|
|
dependencies_paths=None, options=None, name=None, clean=False,
|
2014-07-09 17:00:21 +00:00
|
|
|
notify=None, verbose=False, macros=None, jobs=1):
|
2014-07-01 16:45:12 +00:00
|
|
|
""" Function scans library (or just some set of sources/headers) for staticly detectable defects """
|
|
|
|
if type(src_paths) != ListType:
|
|
|
|
src_paths = [src_paths]
|
2014-06-10 16:25:54 +00:00
|
|
|
|
|
|
|
for src_path in src_paths:
|
|
|
|
if not exists(src_path):
|
|
|
|
raise Exception("The library source folder does not exist: %s", src_path)
|
|
|
|
|
|
|
|
# Toolchain instance
|
|
|
|
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify)
|
|
|
|
toolchain.VERBOSE = verbose
|
2014-07-09 17:00:21 +00:00
|
|
|
toolchain.jobs = jobs
|
2014-06-10 16:25:54 +00:00
|
|
|
|
|
|
|
# The first path will give the name to the library
|
|
|
|
name = basename(src_paths[0])
|
2014-07-10 17:26:39 +00:00
|
|
|
toolchain.info("Static analysis for library %s (%s, %s)" % (name.upper(), target.name, toolchain_name))
|
2014-06-10 16:25:54 +00:00
|
|
|
|
|
|
|
# Scan Resources
|
|
|
|
resources = []
|
|
|
|
for src_path in src_paths:
|
|
|
|
resources.append(toolchain.scan_resources(src_path))
|
|
|
|
|
|
|
|
# Dependencies Include Paths
|
|
|
|
dependencies_include_dir = []
|
|
|
|
if dependencies_paths is not None:
|
|
|
|
for path in dependencies_paths:
|
|
|
|
lib_resources = toolchain.scan_resources(path)
|
|
|
|
dependencies_include_dir.extend(lib_resources.inc_dirs)
|
|
|
|
|
|
|
|
# Create the desired build directory structure
|
|
|
|
bin_path = join(build_path, toolchain.obj_path)
|
|
|
|
mkdir(bin_path)
|
|
|
|
tmp_path = join(build_path, '.temp', toolchain.obj_path)
|
|
|
|
mkdir(tmp_path)
|
|
|
|
|
|
|
|
# Gather include paths, c, cpp sources and macros to transfer to cppcheck command line
|
2014-06-11 16:08:35 +00:00
|
|
|
includes = ["-I%s" % i for i in dependencies_include_dir + src_paths]
|
2014-06-10 16:25:54 +00:00
|
|
|
c_sources = " "
|
|
|
|
cpp_sources = " "
|
2014-06-11 16:08:35 +00:00
|
|
|
macros = ['-D%s' % s for s in toolchain.get_symbols() + toolchain.macros]
|
2014-06-10 16:25:54 +00:00
|
|
|
|
|
|
|
# Copy Headers
|
|
|
|
for resource in resources:
|
|
|
|
toolchain.copy_files(resource.headers, build_path, rel_path=resource.base_path)
|
2014-06-11 16:08:35 +00:00
|
|
|
includes += ["-I%s" % i for i in resource.inc_dirs]
|
2014-06-10 16:25:54 +00:00
|
|
|
c_sources += " ".join(resource.c_sources) + " "
|
|
|
|
cpp_sources += " ".join(resource.cpp_sources) + " "
|
|
|
|
|
|
|
|
dependencies_include_dir.extend(toolchain.scan_resources(build_path).inc_dirs)
|
|
|
|
|
2014-06-11 16:08:35 +00:00
|
|
|
includes = map(str.strip, includes)
|
|
|
|
macros = map(str.strip, macros)
|
|
|
|
|
2014-07-01 16:45:12 +00:00
|
|
|
check_cmd = cppcheck_cmd
|
|
|
|
check_cmd += cppcheck_msg_format
|
2014-06-11 16:08:35 +00:00
|
|
|
check_cmd += includes
|
|
|
|
check_cmd += macros
|
2014-06-11 13:47:54 +00:00
|
|
|
|
2014-07-01 16:45:12 +00:00
|
|
|
# We need to pass some parameters via file to avoid "command line too long in some OSs"
|
|
|
|
# Temporary file is created to store e.g. cppcheck list of files for command line
|
2014-06-11 13:47:54 +00:00
|
|
|
tmp_file = tempfile.NamedTemporaryFile(delete=False)
|
|
|
|
tmp_file.writelines(line + '\n' for line in c_sources.split())
|
|
|
|
tmp_file.writelines(line + '\n' for line in cpp_sources.split())
|
|
|
|
tmp_file.close()
|
2014-06-11 16:08:35 +00:00
|
|
|
check_cmd += ["--file-list=%s"% tmp_file.name]
|
2014-06-10 16:25:54 +00:00
|
|
|
|
2014-07-01 16:45:12 +00:00
|
|
|
# This will allow us to grab result from both stdio and stderr outputs (so we can show them)
|
|
|
|
# We assume static code analysis tool is outputting defects on STDERR
|
2014-06-11 16:08:35 +00:00
|
|
|
_stdout, _stderr, _rc = run_cmd_ext(check_cmd)
|
2014-06-10 16:25:54 +00:00
|
|
|
if verbose:
|
2014-06-11 14:26:00 +00:00
|
|
|
print _stdout
|
|
|
|
print _stderr
|
2014-06-23 12:36:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
def print_build_results(result_list, build_name):
|
2014-07-01 16:45:12 +00:00
|
|
|
""" Generate result string for build results """
|
2014-06-23 12:36:55 +00:00
|
|
|
result = ""
|
|
|
|
if result_list:
|
|
|
|
result += build_name + "\n"
|
|
|
|
result += "\n".join([" * %s" % f for f in result_list])
|
2014-07-28 13:20:17 +00:00
|
|
|
result += "\n"
|
2014-06-23 12:36:55 +00:00
|
|
|
return result
|