Merge pull request #6143 from theotherjimmy/multi-source-export

Correct mbed export with multiple --source params
pull/6280/head
Cruz Monrreal 2018-03-05 21:47:06 -06:00 committed by GitHub
commit e7fde46731
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 4 deletions

View File

@ -4,7 +4,7 @@ supported IDEs or project structures.
from __future__ import absolute_import, print_function from __future__ import absolute_import, print_function
import sys import sys
from os.path import (join, abspath, dirname, exists, basename, normpath, from os.path import (join, abspath, dirname, exists, basename, normpath,
realpath, basename) realpath, relpath, basename)
from os import remove from os import remove
ROOT = abspath(join(dirname(__file__), "..")) ROOT = abspath(join(dirname(__file__), ".."))
sys.path.insert(0, ROOT) sys.path.insert(0, ROOT)
@ -48,7 +48,7 @@ def setup_project(ide, target, program=None, source_dir=None, build=None, export
project_name = TESTS[program] project_name = TESTS[program]
else: else:
project_name = basename(normpath(realpath(source_dir[0]))) project_name = basename(normpath(realpath(source_dir[0])))
src_paths = source_dir src_paths = {relpath(path, project_dir): [path] for path in source_dir}
lib_paths = None lib_paths = None
else: else:
test = Test(program) test = Test(program)
@ -163,6 +163,12 @@ def main():
default=False, default=False,
help="writes tools/export/README.md") help="writes tools/export/README.md")
parser.add_argument("--build",
type=argparse_filestring_type,
dest="build_dir",
default=None,
help="Directory for the exported project files")
parser.add_argument("--source", parser.add_argument("--source",
action="append", action="append",
type=argparse_filestring_type, type=argparse_filestring_type,
@ -254,12 +260,16 @@ def main():
except (NotImplementedError, IOError, OSError): except (NotImplementedError, IOError, OSError):
pass pass
for f in EXPORTERS.values()[0].CLEAN_FILES: for f in EXPORTERS.values()[0].CLEAN_FILES:
try:
remove(f) remove(f)
except (IOError, OSError):
pass
try: try:
export(mcu, options.ide, build=options.build, export(mcu, options.ide, build=options.build,
src=options.source_dir, macros=options.macros, src=options.source_dir, macros=options.macros,
project_id=options.program, zip_proj=zip_proj, project_id=options.program, zip_proj=zip_proj,
build_profile=profile, app_config=options.app_config) build_profile=profile, app_config=options.app_config,
export_path=options.build_dir)
except NotSupportedException as exc: except NotSupportedException as exc:
print("[ERROR] %s" % str(exc)) print("[ERROR] %s" % str(exc))