Skip to content

Correct mbed export with multiple --source params #6143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions tools/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from __future__ import absolute_import, print_function
import sys
from os.path import (join, abspath, dirname, exists, basename, normpath,
realpath, basename)
realpath, relpath, basename)
from os import remove
ROOT = abspath(join(dirname(__file__), ".."))
sys.path.insert(0, ROOT)
Expand Down Expand Up @@ -48,7 +48,7 @@ def setup_project(ide, target, program=None, source_dir=None, build=None, export
project_name = TESTS[program]
else:
project_name = basename(normpath(realpath(source_dir[0])))
src_paths = source_dir
src_paths = {relpath(path, project_dir): [path] for path in source_dir}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if project_dir gets set to export_path but export_path (build argument) doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relpath will still work correctly. According to the docs; no fs access is done to verify the existence of the path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what about later when the exporter tries to put files there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just check this out and try it. Give me a bit.

lib_paths = None
else:
test = Test(program)
Expand Down Expand Up @@ -163,6 +163,12 @@ def main():
default=False,
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",
action="append",
type=argparse_filestring_type,
Expand Down Expand Up @@ -254,12 +260,16 @@ def main():
except (NotImplementedError, IOError, OSError):
pass
for f in EXPORTERS.values()[0].CLEAN_FILES:
remove(f)
try:
remove(f)
except (IOError, OSError):
pass
try:
export(mcu, options.ide, build=options.build,
src=options.source_dir, macros=options.macros,
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:
print("[ERROR] %s" % str(exc))

Expand Down