Skip to content

Commit e7fde46

Browse files
authored
Merge pull request #6143 from theotherjimmy/multi-source-export
Correct mbed export with multiple --source params
2 parents f1d493d + 262c737 commit e7fde46

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tools/project.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from __future__ import absolute_import, print_function
55
import sys
66
from os.path import (join, abspath, dirname, exists, basename, normpath,
7-
realpath, basename)
7+
realpath, relpath, basename)
88
from os import remove
99
ROOT = abspath(join(dirname(__file__), ".."))
1010
sys.path.insert(0, ROOT)
@@ -48,7 +48,7 @@ def setup_project(ide, target, program=None, source_dir=None, build=None, export
4848
project_name = TESTS[program]
4949
else:
5050
project_name = basename(normpath(realpath(source_dir[0])))
51-
src_paths = source_dir
51+
src_paths = {relpath(path, project_dir): [path] for path in source_dir}
5252
lib_paths = None
5353
else:
5454
test = Test(program)
@@ -163,6 +163,12 @@ def main():
163163
default=False,
164164
help="writes tools/export/README.md")
165165

166+
parser.add_argument("--build",
167+
type=argparse_filestring_type,
168+
dest="build_dir",
169+
default=None,
170+
help="Directory for the exported project files")
171+
166172
parser.add_argument("--source",
167173
action="append",
168174
type=argparse_filestring_type,
@@ -254,12 +260,16 @@ def main():
254260
except (NotImplementedError, IOError, OSError):
255261
pass
256262
for f in EXPORTERS.values()[0].CLEAN_FILES:
257-
remove(f)
263+
try:
264+
remove(f)
265+
except (IOError, OSError):
266+
pass
258267
try:
259268
export(mcu, options.ide, build=options.build,
260269
src=options.source_dir, macros=options.macros,
261270
project_id=options.program, zip_proj=zip_proj,
262-
build_profile=profile, app_config=options.app_config)
271+
build_profile=profile, app_config=options.app_config,
272+
export_path=options.build_dir)
263273
except NotSupportedException as exc:
264274
print("[ERROR] %s" % str(exc))
265275

0 commit comments

Comments
 (0)