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/',
|
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
|
# Convention: we are using capitals for toolchain and target names
|
||||||
if target is not None:
|
if target is not None:
|
||||||
target = target.upper()
|
target = target.upper()
|
||||||
|
@ -99,7 +99,7 @@ def export(project_path, project_name, ide, target, destination='/tmp/',
|
||||||
# target checked, export
|
# target checked, export
|
||||||
try:
|
try:
|
||||||
exporter = Exporter(target, tempdir, project_name, build_url_resolver, extra_symbols=extra_symbols)
|
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()
|
exporter.generate()
|
||||||
report['success'] = True
|
report['success'] = True
|
||||||
except OldLibrariesException, e:
|
except OldLibrariesException, e:
|
||||||
|
|
|
@ -111,7 +111,7 @@ class Exporter(object):
|
||||||
|
|
||||||
return resources
|
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
|
# Copy only the file for the required target and toolchain
|
||||||
lib_builds = []
|
lib_builds = []
|
||||||
for src in ['lib', 'src']:
|
for src in ['lib', 'src']:
|
||||||
|
@ -136,9 +136,13 @@ class Exporter(object):
|
||||||
fhandle = file(join(hgdir, 'keep.me'), 'a')
|
fhandle = file(join(hgdir, 'keep.me'), 'a')
|
||||||
fhandle.close()
|
fhandle.close()
|
||||||
|
|
||||||
# Final scan of the actual exported resources
|
if not relative:
|
||||||
self.resources = self.toolchain.scan_resources(trg_path)
|
# Final scan of the actual exported resources
|
||||||
self.resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
|
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
|
# 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:
|
||||||
|
|
|
@ -5,11 +5,12 @@ sys.path.insert(0, ROOT)
|
||||||
|
|
||||||
from shutil import move, rmtree
|
from shutil import move, rmtree
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
from os import path
|
||||||
|
|
||||||
from tools.paths import EXPORT_DIR, EXPORT_WORKSPACE, EXPORT_TMP
|
from tools.paths import EXPORT_DIR, EXPORT_WORKSPACE, EXPORT_TMP
|
||||||
from tools.paths import MBED_BASE, MBED_LIBRARIES
|
from tools.paths import MBED_BASE, MBED_LIBRARIES
|
||||||
from tools.export import export, setup_user_prj, EXPORTERS, mcu_ide_matrix
|
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.tests import TESTS, Test, TEST_MAP
|
||||||
from tools.targets import TARGET_NAMES
|
from tools.targets import TARGET_NAMES
|
||||||
from tools.libraries import LIBRARIES
|
from tools.libraries import LIBRARIES
|
||||||
|
@ -136,15 +137,19 @@ if __name__ == '__main__':
|
||||||
zip = True
|
zip = True
|
||||||
clean = 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(','):
|
for mcu in mcus.split(','):
|
||||||
# Program Number or name
|
# 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:
|
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)
|
||||||
project_temp = project_dir
|
project_temp = options.source_dir
|
||||||
|
mkdir(project_temp)
|
||||||
lib_symbols = []
|
lib_symbols = []
|
||||||
if options.macros:
|
if options.macros:
|
||||||
lib_symbols += options.macros
|
lib_symbols += options.macros
|
||||||
|
@ -204,7 +209,7 @@ if __name__ == '__main__':
|
||||||
setup_user_prj(project_dir, test.source_dir, test.dependencies)
|
setup_user_prj(project_dir, test.source_dir, test.dependencies)
|
||||||
|
|
||||||
# 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)
|
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
|
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))
|
||||||
|
|
Loading…
Reference in New Issue