mirror of https://github.com/ARMmbed/mbed-os.git
Allowed multiple --source specifications on the export command
The project name is set to the first --source argument. Resources (the class) is now a monoid.
parent
08ecdb296b
commit
d772ea7a00
|
@ -7,6 +7,7 @@ from jinja2 import Template, FileSystemLoader
|
|||
from jinja2.environment import Environment
|
||||
from contextlib import closing
|
||||
from zipfile import ZipFile, ZIP_DEFLATED
|
||||
from operator import add
|
||||
|
||||
from tools.utils import mkdir
|
||||
from tools.toolchains import TOOLCHAIN_CLASSES
|
||||
|
@ -111,17 +112,18 @@ class Exporter(object):
|
|||
|
||||
return resources
|
||||
|
||||
def scan_and_copy_resources(self, prj_path, trg_path, relative=False):
|
||||
def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):
|
||||
# Copy only the file for the required target and toolchain
|
||||
lib_builds = []
|
||||
for src in ['lib', 'src']:
|
||||
resources = self.__scan_and_copy(join(prj_path, src), trg_path)
|
||||
resources = reduce(add, [self.__scan_and_copy(join(path, src), trg_path) for path in prj_paths])
|
||||
lib_builds.extend(resources.lib_builds)
|
||||
|
||||
# The repository files
|
||||
for repo_dir in resources.repo_dirs:
|
||||
repo_files = self.__scan_all(repo_dir)
|
||||
self.toolchain.copy_files(repo_files, trg_path, rel_path=join(prj_path, src))
|
||||
for path in proj_paths :
|
||||
self.toolchain.copy_files(repo_files, trg_path, rel_path=join(path, src))
|
||||
|
||||
# The libraries builds
|
||||
for bld in lib_builds:
|
||||
|
@ -142,7 +144,7 @@ class Exporter(object):
|
|||
self.resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
|
||||
else:
|
||||
# use the prj_dir (source, not destination)
|
||||
self.resources = self.toolchain.scan_resources(prj_path)
|
||||
self.resources = reduce(add, [self.toolchain.scan_resources(path) for path in prj_paths])
|
||||
# Check the existence of a binary build of the mbed library for the desired target
|
||||
# This prevents exporting the mbed libraries from source
|
||||
# if not self.toolchain.mbed_libs:
|
||||
|
|
|
@ -79,6 +79,7 @@ if __name__ == '__main__':
|
|||
help="writes tools/export/README.md")
|
||||
|
||||
parser.add_option("--source",
|
||||
action="append",
|
||||
dest="source_dir",
|
||||
default=None,
|
||||
help="The source (input) directory")
|
||||
|
@ -147,8 +148,8 @@ if __name__ == '__main__':
|
|||
if src is not None:
|
||||
# --source is used to generate IDE files to toolchain directly in the source tree and doesn't generate zip file
|
||||
project_dir = options.source_dir
|
||||
project_name = basename(project_dir)
|
||||
project_temp = path.join(options.source_dir, 'projectfiles', ide)
|
||||
project_name = basename(project_dir[0])
|
||||
project_temp = path.join(options.source_dir[0], 'projectfiles', ide)
|
||||
mkdir(project_temp)
|
||||
lib_symbols = []
|
||||
if options.macros:
|
||||
|
@ -210,7 +211,6 @@ if __name__ == '__main__':
|
|||
|
||||
# Export to selected toolchain
|
||||
tmp_path, report = export(project_dir, project_name, ide, mcu, project_dir, project_temp, clean=clean, zip=zip, extra_symbols=lib_symbols, relative=sources_relative)
|
||||
print tmp_path
|
||||
if report['success']:
|
||||
zip_path = join(EXPORT_DIR, "%s_%s_%s.zip" % (project_name, ide, mcu))
|
||||
if zip:
|
||||
|
|
|
@ -83,6 +83,18 @@ class Resources:
|
|||
self.hex_files = []
|
||||
self.bin_files = []
|
||||
|
||||
def __add__(self, resources):
|
||||
if resources is None:
|
||||
return self
|
||||
else:
|
||||
return self.add(resources)
|
||||
|
||||
def __radd__(self, resources):
|
||||
if resources is None:
|
||||
return self
|
||||
else:
|
||||
return self.add(resources)
|
||||
|
||||
def add(self, resources):
|
||||
self.inc_dirs += resources.inc_dirs
|
||||
self.headers += resources.headers
|
||||
|
@ -106,6 +118,7 @@ class Resources:
|
|||
|
||||
self.hex_files += resources.hex_files
|
||||
self.bin_files += resources.bin_files
|
||||
return self
|
||||
|
||||
def relative_to(self, base, dot=False):
|
||||
for field in ['inc_dirs', 'headers', 's_sources', 'c_sources',
|
||||
|
|
Loading…
Reference in New Issue