Skip to content

Move clean functionality out of the export api #3486

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 1 commit into from
Dec 23, 2016
Merged
Show file tree
Hide file tree
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
16 changes: 9 additions & 7 deletions tools/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from os.path import normpath, realpath

from tools.paths import EXPORT_DIR, MBED_HAL, MBED_LIBRARIES, MBED_TARGETS_PATH
from tools.settings import BUILD_DIR
from tools.export import EXPORTERS, mcu_ide_matrix
from tools.tests import TESTS, TEST_MAP
from tools.tests import test_known, test_name_known, Test
Expand Down Expand Up @@ -66,8 +67,7 @@ def setup_project(ide, target, program=None, source_dir=None, build=None, export


def export(target, ide, build=None, src=None, macros=None, project_id=None,
clean=False, zip_proj=False, build_profile=None, export_path=None,
silent=False):
zip_proj=False, build_profile=None, export_path=None, silent=False):
"""Do an export of a project.

Positional arguments:
Expand All @@ -89,9 +89,9 @@ def export(target, ide, build=None, src=None, macros=None, project_id=None,

zip_name = name+".zip" if zip_proj else None

return export_project(src, project_dir, target, ide, clean=clean, name=name,
macros=macros, libraries_paths=lib, zip_proj=zip_name,
build_profile=build_profile, silent=silent)
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)


def main():
Expand Down Expand Up @@ -238,10 +238,12 @@ def main():
if options.mcu not in exporter.TARGETS:
args_error(parser, "%s not supported by %s"%(options.mcu,options.ide))
profile = extract_profile(parser, options, toolchain_name)
if options.clean:
rmtree(BUILD_DIR)
export(options.mcu, options.ide, build=options.build,
src=options.source_dir, macros=options.macros,
project_id=options.program, clean=options.clean,
zip_proj=zip_proj, build_profile=profile)
project_id=options.program, zip_proj=zip_proj,
build_profile=profile)


if __name__ == "__main__":
Expand Down
21 changes: 8 additions & 13 deletions tools/project_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,10 @@ def zip_export(file_name, prefix, resources, project_files, inc_repos):



def export_project(src_paths, export_path, target, ide,
libraries_paths=None, linker_script=None, clean=False,
notify=None, verbose=False, name=None, inc_dirs=None,
jobs=1, silent=False, extra_verbose=False, config=None,
macros=None, zip_proj=None, inc_repos=False,
def export_project(src_paths, export_path, target, ide, libraries_paths=None,
linker_script=None, notify=None, verbose=False, name=None,
inc_dirs=None, jobs=1, silent=False, extra_verbose=False,
config=None, macros=None, zip_proj=None, inc_repos=False,
build_profile=None):
"""Generates a project file and creates a zip archive if specified

Expand All @@ -151,7 +150,6 @@ def export_project(src_paths, export_path, target, ide,
Keyword Arguments:
libraries_paths - paths to additional libraries
linker_script - path to the linker script for the specified target
clean - removes the export_path if it exists
notify - function is passed all events, and expected to handle notification
of the user, emit the events to a log, etc.
verbose - assigns the notify function to toolchains print_notify_verbose
Expand Down Expand Up @@ -183,19 +181,16 @@ def export_project(src_paths, export_path, target, ide,
src_paths = {"": paths}

# Export Directory
if exists(export_path) and clean:
rmtree(export_path)
if not exists(export_path):
makedirs(export_path)

_, toolchain_name = get_exporter_toolchain(ide)

# Pass all params to the unified prepare_resources()
toolchain = prepare_toolchain(paths, target, toolchain_name,
macros=macros, clean=clean, jobs=jobs,
notify=notify, silent=silent, verbose=verbose,
extra_verbose=extra_verbose, config=config,
build_profile=build_profile)
toolchain = prepare_toolchain(paths, target, toolchain_name, macros=macros,
jobs=jobs, notify=notify, silent=silent,
verbose=verbose, extra_verbose=extra_verbose,
config=config, build_profile=build_profile)
# The first path will give the name to the library
if name is None:
name = basename(normpath(abspath(src_paths[0])))
Expand Down