Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: project.py
- Revision:
- 40:7d3fa6b99b2b
- Parent:
- 38:399953da035d
- Child:
- 41:2a77626a4c21
--- a/project.py Wed Jul 19 16:44:30 2017 -0500
+++ b/project.py Tue Oct 10 16:56:30 2017 -0500
@@ -15,12 +15,14 @@
from tools.export import EXPORTERS, mcu_ide_matrix, mcu_ide_list, export_project, get_exporter_toolchain
from tools.tests import TESTS, TEST_MAP
from tools.tests import test_known, test_name_known, Test
-from tools.targets import TARGET_NAMES
+from tools.targets import TARGET_NAMES, set_targets_json_location
from tools.utils import argparse_filestring_type, argparse_profile_filestring_type, argparse_many, args_error
from tools.utils import argparse_force_lowercase_type
from tools.utils import argparse_force_uppercase_type
from tools.utils import print_large_string
from tools.options import extract_profile, list_profiles, extract_mcus
+from tools.build_profiles import find_targets_json, find_build_profile, get_toolchain_profile
+from tools.toolchains import mbedToolchain
def setup_project(ide, target, program=None, source_dir=None, build=None, export_path=None):
"""Generate a name, if not provided, and find dependencies
@@ -89,6 +91,45 @@
zip_name = name+".zip" if zip_proj else None
+ ###################################
+ # mbed Classic/2.0/libary support #
+
+ # Find build system profile
+ profile = None
+ targets_json = None
+ for path in src:
+ profile = find_build_profile(path) or profile
+ if profile:
+ targets_json = join(dirname(dirname(abspath(__file__))), 'legacy_targets.json')
+ else:
+ targets_json = find_targets_json(path) or targets_json
+
+ # Apply targets.json to active targets
+ if targets_json:
+ if not silent:
+ print("Using targets from %s" % targets_json)
+ set_targets_json_location(targets_json)
+
+ # Apply profile to toolchains
+ if profile:
+ def init_hook(self):
+ profile_data = get_toolchain_profile(self.name, profile)
+ if not profile_data:
+ return
+ if not silent:
+ self.info("Using toolchain %s profile %s" % (self.name, profile))
+
+ for k,v in profile_data.items():
+ if self.flags.has_key(k):
+ self.flags[k] = v
+ else:
+ setattr(self, k, v)
+
+ mbedToolchain.init = init_hook
+
+ # mbed Classic/2.0/libary support #
+ ###################################
+
return export_project(src, project_dir, target, ide, name=name,
macros=macros, libraries_paths=lib, zip_proj=zip_name,
build_profile=build_profile, silent=silent,
@@ -107,7 +148,7 @@
parser.add_argument("-m", "--mcu",
metavar="MCU",
- type=argparse_force_uppercase_type(targetnames, "MCU"),
+ type=str.upper,
help="generate project for the given MCU ({})".format(
', '.join(targetnames)))
@@ -235,19 +276,17 @@
if exists(EXPORT_DIR):
rmtree(EXPORT_DIR)
- for mcu in options.mcu:
- zip_proj = not bool(options.source_dir)
+ zip_proj = not bool(options.source_dir)
if (options.program is None) and (not options.source_dir):
args_error(parser, "one of -p, -n, or --source is required")
- # Export to selected toolchain
exporter, toolchain_name = get_exporter_toolchain(options.ide)
- if options.mcu not in exporter.TARGETS:
- args_error(parser, "%s not supported by %s"%(options.mcu,options.ide))
+ mcu = extract_mcus(parser, options)[0]
+ if not exporter.is_target_supported(mcu):
+ args_error(parser, "%s not supported by %s"%(mcu,options.ide))
profile = extract_profile(parser, options, toolchain_name, fallback="debug")
if options.clean:
rmtree(BUILD_DIR)
- mcu = extract_mcus(parser, options)[0]
export(mcu, options.ide, build=options.build,
src=options.source_dir, macros=options.macros,
project_id=options.program, zip_proj=zip_proj,
