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.
pull/10021/head
Brian Daniels 2019-04-08 14:42:51 -05:00
parent bbef60fbf2
commit fb6fcc5324
3 changed files with 13 additions and 9 deletions

View File

@ -136,7 +136,7 @@ def get_exporter_toolchain(ide):
def generate_project_files(resources, export_path, target, name, toolchain, ide, def generate_project_files(resources, export_path, target, name, toolchain, ide,
macros=None): zip, macros=None):
"""Generate the project files for a project """Generate the project files for a project
Positional arguments: Positional arguments:
@ -147,13 +147,14 @@ def generate_project_files(resources, export_path, target, name, toolchain, ide,
toolchain - a toolchain class that corresponds to the toolchain used by the toolchain - a toolchain class that corresponds to the toolchain used by the
IDE or makefile IDE or makefile
ide - IDE name to export to ide - IDE name to export to
zip - True if the exported project will be zipped
Optional arguments: Optional arguments:
macros - additional macros that should be defined within the exported macros - additional macros that should be defined within the exported
project project
""" """
exporter_cls, _ = get_exporter_toolchain(ide) exporter_cls, _ = get_exporter_toolchain(ide)
exporter = exporter_cls(target, export_path, name, toolchain, exporter = exporter_cls(target, export_path, name, toolchain, zip,
extra_symbols=macros, resources=resources) extra_symbols=macros, resources=resources)
exporter.generate() exporter.generate()
files = exporter.generated_files files = exporter.generated_files
@ -278,9 +279,9 @@ def export_project(src_paths, export_path, target, ide, libraries_paths=None,
if toolchain.config.name: if toolchain.config.name:
name = toolchain.config.name name = toolchain.config.name
files, exporter = generate_project_files(resources, export_path, files, exporter = generate_project_files(
target, name, toolchain, ide, resources, export_path, target, name, toolchain, ide, zip_proj, macros=macros
macros=macros) )
if zip_proj: if zip_proj:
resources.add_features(ALLOWED_FEATURES) resources.add_features(ALLOWED_FEATURES)
if isinstance(zip_proj, basestring): if isinstance(zip_proj, basestring):

View File

@ -73,7 +73,7 @@ class Exporter(object):
CLEAN_FILES = ("GettingStarted.html",) CLEAN_FILES = ("GettingStarted.html",)
def __init__(self, target, export_dir, project_name, toolchain, def __init__(self, target, export_dir, project_name, toolchain, zip,
extra_symbols=None, resources=None): extra_symbols=None, resources=None):
"""Initialize an instance of class exporter """Initialize an instance of class exporter
Positional arguments: Positional arguments:
@ -81,6 +81,7 @@ class Exporter(object):
export_dir - the directory of the exported project files export_dir - the directory of the exported project files
project_name - the name of the project project_name - the name of the project
toolchain - an instance of class toolchain toolchain - an instance of class toolchain
zip - True if the exported project will be zipped
Keyword arguments: Keyword arguments:
extra_symbols - a list of extra macros for the toolchain extra_symbols - a list of extra macros for the toolchain
@ -94,6 +95,7 @@ class Exporter(object):
self.jinja_environment = Environment(loader=jinja_loader) self.jinja_environment = Environment(loader=jinja_loader)
resources.win_to_unix() resources.win_to_unix()
self.resources = resources self.resources = resources
self.zip = zip
self.generated_files = [] self.generated_files = []
getting_started_name = "GettingStarted.html" getting_started_name = "GettingStarted.html"
dot_mbed_name = ".mbed" dot_mbed_name = ".mbed"

View File

@ -2,7 +2,7 @@ from __future__ import print_function, absolute_import
from builtins import str from builtins import str
import os import os
from os.path import normpath, exists, dirname, join, abspath from os.path import normpath, exists, dirname, join, abspath, relpath
import ntpath import ntpath
import copy import copy
from collections import namedtuple from collections import namedtuple
@ -247,7 +247,7 @@ class Uvision(Exporter):
'postbuild_step_active': 0, 'postbuild_step_active': 0,
} }
if self.toolchain.config.has_regions: if self.toolchain.config.has_regions and not self.zip:
# Serialize region information # Serialize region information
export_info = {} export_info = {}
restrict_size = getattr(self.toolchain.config.target, "restrict_size") restrict_size = getattr(self.toolchain.config.target, "restrict_size")
@ -262,8 +262,9 @@ class Uvision(Exporter):
r._replace(filename=binary_path) if r.active else r for r in region_list r._replace(filename=binary_path) if r.active else r for r in region_list
] ]
# Enable the post build step # Enable the post build step
postbuild_script_path = join(relpath(dirname(__file__)), "postbuild.py")
ctx['postbuild_step'] = ( ctx['postbuild_step'] = (
'python mbed-os/tools/export/uvision/postbuild.py "$K\\" "#L"' 'python {} "$K\\" "#L"'.format(postbuild_script_path)
) )
ctx['postbuild_step_active'] = 1 ctx['postbuild_step_active'] = 1
ctx['export_info'] = json.dumps(export_info, indent=4) ctx['export_info'] = json.dumps(export_info, indent=4)