mirror of https://github.com/ARMmbed/mbed-os.git
Exporters - add relative paths handling
If we use source option, the paths should be relative to the source dir. Otherwise, mbed export scripts copies sources to temp dir.
parent
28334b00bb
commit
647cf23cf1
|
@ -55,7 +55,7 @@ def online_build_url_resolver(url):
|
|||
|
||||
|
||||
def export(project_path, project_name, ide, target, destination='/tmp/',
|
||||
tempdir=None, clean=True, extra_symbols=None, zip=True, build_url_resolver=online_build_url_resolver):
|
||||
tempdir=None, clean=True, extra_symbols=None, zip=True, build_url_resolver=online_build_url_resolver, relative=False):
|
||||
# Convention: we are using capitals for toolchain and target names
|
||||
if target is not None:
|
||||
target = target.upper()
|
||||
|
@ -99,7 +99,7 @@ def export(project_path, project_name, ide, target, destination='/tmp/',
|
|||
# target checked, export
|
||||
try:
|
||||
exporter = Exporter(target, tempdir, project_name, build_url_resolver, extra_symbols=extra_symbols)
|
||||
exporter.scan_and_copy_resources(project_path, tempdir)
|
||||
exporter.scan_and_copy_resources(project_path, tempdir, relative)
|
||||
exporter.generate()
|
||||
report['success'] = True
|
||||
except OldLibrariesException, e:
|
||||
|
|
|
@ -111,7 +111,7 @@ class Exporter(object):
|
|||
|
||||
return resources
|
||||
|
||||
def scan_and_copy_resources(self, prj_path, trg_path):
|
||||
def scan_and_copy_resources(self, prj_path, trg_path, relative=False):
|
||||
# Copy only the file for the required target and toolchain
|
||||
lib_builds = []
|
||||
for src in ['lib', 'src']:
|
||||
|
@ -136,9 +136,13 @@ class Exporter(object):
|
|||
fhandle = file(join(hgdir, 'keep.me'), 'a')
|
||||
fhandle.close()
|
||||
|
||||
# Final scan of the actual exported resources
|
||||
self.resources = self.toolchain.scan_resources(trg_path)
|
||||
self.resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
|
||||
if not relative:
|
||||
# Final scan of the actual exported resources
|
||||
self.resources = self.toolchain.scan_resources(trg_path)
|
||||
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)
|
||||
# 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:
|
||||
|
|
|
@ -5,11 +5,12 @@ sys.path.insert(0, ROOT)
|
|||
|
||||
from shutil import move, rmtree
|
||||
from optparse import OptionParser
|
||||
from os import path
|
||||
|
||||
from tools.paths import EXPORT_DIR, EXPORT_WORKSPACE, EXPORT_TMP
|
||||
from tools.paths import MBED_BASE, MBED_LIBRARIES
|
||||
from tools.export import export, setup_user_prj, EXPORTERS, mcu_ide_matrix
|
||||
from tools.utils import args_error
|
||||
from tools.utils import args_error, mkdir
|
||||
from tools.tests import TESTS, Test, TEST_MAP
|
||||
from tools.targets import TARGET_NAMES
|
||||
from tools.libraries import LIBRARIES
|
||||
|
@ -136,15 +137,19 @@ if __name__ == '__main__':
|
|||
zip = True
|
||||
clean = True
|
||||
|
||||
# source_dir = use relative paths, otherwise sources are copied
|
||||
sources_relative = True if options.source_dir else False
|
||||
|
||||
for mcu in mcus.split(','):
|
||||
# Program Number or name
|
||||
p, n, src = options.program, options.program_name, options.source_dir
|
||||
p, n, src, ide = options.program, options.program_name, options.source_dir, options.ide
|
||||
|
||||
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 = project_dir
|
||||
project_temp = options.source_dir
|
||||
mkdir(project_temp)
|
||||
lib_symbols = []
|
||||
if options.macros:
|
||||
lib_symbols += options.macros
|
||||
|
@ -204,7 +209,7 @@ if __name__ == '__main__':
|
|||
setup_user_prj(project_dir, test.source_dir, test.dependencies)
|
||||
|
||||
# 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)
|
||||
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))
|
||||
|
|
Loading…
Reference in New Issue