Skip to content

Commit fb6fcc5

Browse files
committed
Only enable uvision postbuild when in a non-zipped exported project.
Projects that are zipped are typically from the online compiler or they are meant to be used in a separate environment. Since the postbuild script requires the Mbed OS tools to present in the project, we will disable the postbuild script when the project is exported to a zipped project.
1 parent bbef60f commit fb6fcc5

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

tools/export/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def get_exporter_toolchain(ide):
136136

137137

138138
def generate_project_files(resources, export_path, target, name, toolchain, ide,
139-
macros=None):
139+
zip, macros=None):
140140
"""Generate the project files for a project
141141
142142
Positional arguments:
@@ -147,13 +147,14 @@ def generate_project_files(resources, export_path, target, name, toolchain, ide,
147147
toolchain - a toolchain class that corresponds to the toolchain used by the
148148
IDE or makefile
149149
ide - IDE name to export to
150+
zip - True if the exported project will be zipped
150151
151152
Optional arguments:
152153
macros - additional macros that should be defined within the exported
153154
project
154155
"""
155156
exporter_cls, _ = get_exporter_toolchain(ide)
156-
exporter = exporter_cls(target, export_path, name, toolchain,
157+
exporter = exporter_cls(target, export_path, name, toolchain, zip,
157158
extra_symbols=macros, resources=resources)
158159
exporter.generate()
159160
files = exporter.generated_files
@@ -278,9 +279,9 @@ def export_project(src_paths, export_path, target, ide, libraries_paths=None,
278279
if toolchain.config.name:
279280
name = toolchain.config.name
280281

281-
files, exporter = generate_project_files(resources, export_path,
282-
target, name, toolchain, ide,
283-
macros=macros)
282+
files, exporter = generate_project_files(
283+
resources, export_path, target, name, toolchain, ide, zip_proj, macros=macros
284+
)
284285
if zip_proj:
285286
resources.add_features(ALLOWED_FEATURES)
286287
if isinstance(zip_proj, basestring):

tools/export/exporters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ class Exporter(object):
7373
CLEAN_FILES = ("GettingStarted.html",)
7474

7575

76-
def __init__(self, target, export_dir, project_name, toolchain,
76+
def __init__(self, target, export_dir, project_name, toolchain, zip,
7777
extra_symbols=None, resources=None):
7878
"""Initialize an instance of class exporter
7979
Positional arguments:
8080
target - the target mcu/board for this project
8181
export_dir - the directory of the exported project files
8282
project_name - the name of the project
8383
toolchain - an instance of class toolchain
84+
zip - True if the exported project will be zipped
8485
8586
Keyword arguments:
8687
extra_symbols - a list of extra macros for the toolchain
@@ -94,6 +95,7 @@ def __init__(self, target, export_dir, project_name, toolchain,
9495
self.jinja_environment = Environment(loader=jinja_loader)
9596
resources.win_to_unix()
9697
self.resources = resources
98+
self.zip = zip
9799
self.generated_files = []
98100
getting_started_name = "GettingStarted.html"
99101
dot_mbed_name = ".mbed"

tools/export/uvision/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from builtins import str
33

44
import os
5-
from os.path import normpath, exists, dirname, join, abspath
5+
from os.path import normpath, exists, dirname, join, abspath, relpath
66
import ntpath
77
import copy
88
from collections import namedtuple
@@ -247,7 +247,7 @@ def generate(self):
247247
'postbuild_step_active': 0,
248248
}
249249

250-
if self.toolchain.config.has_regions:
250+
if self.toolchain.config.has_regions and not self.zip:
251251
# Serialize region information
252252
export_info = {}
253253
restrict_size = getattr(self.toolchain.config.target, "restrict_size")
@@ -262,8 +262,9 @@ def generate(self):
262262
r._replace(filename=binary_path) if r.active else r for r in region_list
263263
]
264264
# Enable the post build step
265+
postbuild_script_path = join(relpath(dirname(__file__)), "postbuild.py")
265266
ctx['postbuild_step'] = (
266-
'python mbed-os/tools/export/uvision/postbuild.py "$K\\" "#L"'
267+
'python {} "$K\\" "#L"'.format(postbuild_script_path)
267268
)
268269
ctx['postbuild_step_active'] = 1
269270
ctx['export_info'] = json.dumps(export_info, indent=4)

0 commit comments

Comments
 (0)