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 jinja2.environment import Environment
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from zipfile import ZipFile, ZIP_DEFLATED
|
from zipfile import ZipFile, ZIP_DEFLATED
|
||||||
|
from operator import add
|
||||||
|
|
||||||
from tools.utils import mkdir
|
from tools.utils import mkdir
|
||||||
from tools.toolchains import TOOLCHAIN_CLASSES
|
from tools.toolchains import TOOLCHAIN_CLASSES
|
||||||
|
@ -111,17 +112,18 @@ class Exporter(object):
|
||||||
|
|
||||||
return resources
|
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
|
# Copy only the file for the required target and toolchain
|
||||||
lib_builds = []
|
lib_builds = []
|
||||||
for src in ['lib', 'src']:
|
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)
|
lib_builds.extend(resources.lib_builds)
|
||||||
|
|
||||||
# The repository files
|
# The repository files
|
||||||
for repo_dir in resources.repo_dirs:
|
for repo_dir in resources.repo_dirs:
|
||||||
repo_files = self.__scan_all(repo_dir)
|
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
|
# The libraries builds
|
||||||
for bld in lib_builds:
|
for bld in lib_builds:
|
||||||
|
@ -142,7 +144,7 @@ class Exporter(object):
|
||||||
self.resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
|
self.resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
|
||||||
else:
|
else:
|
||||||
# use the prj_dir (source, not destination)
|
# 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
|
# Check the existence of a binary build of the mbed library for the desired target
|
||||||
# This prevents exporting the mbed libraries from source
|
# This prevents exporting the mbed libraries from source
|
||||||
# if not self.toolchain.mbed_libs:
|
# if not self.toolchain.mbed_libs:
|
||||||
|
|
|
@ -79,6 +79,7 @@ if __name__ == '__main__':
|
||||||
help="writes tools/export/README.md")
|
help="writes tools/export/README.md")
|
||||||
|
|
||||||
parser.add_option("--source",
|
parser.add_option("--source",
|
||||||
|
action="append",
|
||||||
dest="source_dir",
|
dest="source_dir",
|
||||||
default=None,
|
default=None,
|
||||||
help="The source (input) directory")
|
help="The source (input) directory")
|
||||||
|
@ -147,8 +148,8 @@ if __name__ == '__main__':
|
||||||
if src is not None:
|
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
|
# --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_dir = options.source_dir
|
||||||
project_name = basename(project_dir)
|
project_name = basename(project_dir[0])
|
||||||
project_temp = path.join(options.source_dir, 'projectfiles', ide)
|
project_temp = path.join(options.source_dir[0], 'projectfiles', ide)
|
||||||
mkdir(project_temp)
|
mkdir(project_temp)
|
||||||
lib_symbols = []
|
lib_symbols = []
|
||||||
if options.macros:
|
if options.macros:
|
||||||
|
@ -210,7 +211,6 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Export to selected toolchain
|
# 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)
|
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']:
|
if report['success']:
|
||||||
zip_path = join(EXPORT_DIR, "%s_%s_%s.zip" % (project_name, ide, mcu))
|
zip_path = join(EXPORT_DIR, "%s_%s_%s.zip" % (project_name, ide, mcu))
|
||||||
if zip:
|
if zip:
|
||||||
|
|
|
@ -83,6 +83,18 @@ class Resources:
|
||||||
self.hex_files = []
|
self.hex_files = []
|
||||||
self.bin_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):
|
def add(self, resources):
|
||||||
self.inc_dirs += resources.inc_dirs
|
self.inc_dirs += resources.inc_dirs
|
||||||
self.headers += resources.headers
|
self.headers += resources.headers
|
||||||
|
@ -106,6 +118,7 @@ class Resources:
|
||||||
|
|
||||||
self.hex_files += resources.hex_files
|
self.hex_files += resources.hex_files
|
||||||
self.bin_files += resources.bin_files
|
self.bin_files += resources.bin_files
|
||||||
|
return self
|
||||||
|
|
||||||
def relative_to(self, base, dot=False):
|
def relative_to(self, base, dot=False):
|
||||||
for field in ['inc_dirs', 'headers', 's_sources', 'c_sources',
|
for field in ['inc_dirs', 'headers', 's_sources', 'c_sources',
|
||||||
|
|
Loading…
Reference in New Issue