Skip to content

Commit cb39663

Browse files
authored
Merge pull request #3486 from theotherjimmy/clean-export-fix
Move clean functionality out of the export api
2 parents 6978a58 + 18ad176 commit cb39663

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

tools/project.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from os.path import normpath, realpath
1212

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

6768

6869
def export(target, ide, build=None, src=None, macros=None, project_id=None,
69-
clean=False, zip_proj=False, build_profile=None, export_path=None,
70-
silent=False):
70+
zip_proj=False, build_profile=None, export_path=None, silent=False):
7171
"""Do an export of a project.
7272
7373
Positional arguments:
@@ -89,9 +89,9 @@ def export(target, ide, build=None, src=None, macros=None, project_id=None,
8989

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

92-
return export_project(src, project_dir, target, ide, clean=clean, name=name,
93-
macros=macros, libraries_paths=lib, zip_proj=zip_name,
94-
build_profile=build_profile, silent=silent)
92+
return export_project(src, project_dir, target, ide, name=name,
93+
macros=macros, libraries_paths=lib, zip_proj=zip_name,
94+
build_profile=build_profile, silent=silent)
9595

9696

9797
def main():
@@ -238,10 +238,12 @@ def main():
238238
if options.mcu not in exporter.TARGETS:
239239
args_error(parser, "%s not supported by %s"%(options.mcu,options.ide))
240240
profile = extract_profile(parser, options, toolchain_name)
241+
if options.clean:
242+
rmtree(BUILD_DIR)
241243
export(options.mcu, options.ide, build=options.build,
242244
src=options.source_dir, macros=options.macros,
243-
project_id=options.program, clean=options.clean,
244-
zip_proj=zip_proj, build_profile=profile)
245+
project_id=options.program, zip_proj=zip_proj,
246+
build_profile=profile)
245247

246248

247249
if __name__ == "__main__":

tools/project_api.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,10 @@ def zip_export(file_name, prefix, resources, project_files, inc_repos):
134134

135135

136136

137-
def export_project(src_paths, export_path, target, ide,
138-
libraries_paths=None, linker_script=None, clean=False,
139-
notify=None, verbose=False, name=None, inc_dirs=None,
140-
jobs=1, silent=False, extra_verbose=False, config=None,
141-
macros=None, zip_proj=None, inc_repos=False,
137+
def export_project(src_paths, export_path, target, ide, libraries_paths=None,
138+
linker_script=None, notify=None, verbose=False, name=None,
139+
inc_dirs=None, jobs=1, silent=False, extra_verbose=False,
140+
config=None, macros=None, zip_proj=None, inc_repos=False,
142141
build_profile=None):
143142
"""Generates a project file and creates a zip archive if specified
144143
@@ -151,7 +150,6 @@ def export_project(src_paths, export_path, target, ide,
151150
Keyword Arguments:
152151
libraries_paths - paths to additional libraries
153152
linker_script - path to the linker script for the specified target
154-
clean - removes the export_path if it exists
155153
notify - function is passed all events, and expected to handle notification
156154
of the user, emit the events to a log, etc.
157155
verbose - assigns the notify function to toolchains print_notify_verbose
@@ -183,19 +181,16 @@ def export_project(src_paths, export_path, target, ide,
183181
src_paths = {"": paths}
184182

185183
# Export Directory
186-
if exists(export_path) and clean:
187-
rmtree(export_path)
188184
if not exists(export_path):
189185
makedirs(export_path)
190186

191187
_, toolchain_name = get_exporter_toolchain(ide)
192188

193189
# Pass all params to the unified prepare_resources()
194-
toolchain = prepare_toolchain(paths, target, toolchain_name,
195-
macros=macros, clean=clean, jobs=jobs,
196-
notify=notify, silent=silent, verbose=verbose,
197-
extra_verbose=extra_verbose, config=config,
198-
build_profile=build_profile)
190+
toolchain = prepare_toolchain(paths, target, toolchain_name, macros=macros,
191+
jobs=jobs, notify=notify, silent=silent,
192+
verbose=verbose, extra_verbose=extra_verbose,
193+
config=config, build_profile=build_profile)
199194
# The first path will give the name to the library
200195
if name is None:
201196
name = basename(normpath(abspath(src_paths[0])))

0 commit comments

Comments
 (0)