Use relative path to scatter for include path

pull/5797/head
Jimmy Brisson 2018-01-31 15:52:48 -06:00
parent 9245b50a54
commit 9b8ba4dd98
3 changed files with 13 additions and 9 deletions

View File

@ -228,9 +228,10 @@ class Arm(Makefile):
def generate(self):
if self.resources.linker_script:
sct_file = self.resources.linker_script
new_script = self.toolchain.correct_scatter_shebang(
self.resources.linker_script)
if new_script is not self.resources.linker_script:
sct_file, join(self.resources.file_basepath[sct_file], "BUILD"))
if new_script is not sct_file:
self.resources.linker_script = new_script
self.generated_files.append(new_script)
return super(Arm, self).generate()

View File

@ -217,11 +217,13 @@ class Uvision(Exporter):
# UVFile tuples defined above
'project_files': sorted(list(self.format_src(srcs).iteritems()),
key=lambda (group, _): group.lower()),
'linker_script':self.toolchain.correct_scatter_shebang(
self.resources.linker_script),
'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'),
'device': DeviceUvision(self.target),
}
sct_file = self.resources.linker_script
ctx['linker_script'] = self.toolchain.correct_scatter_shebang(
sct_file, self.resources.file_basepath[sct_file])
if ctx['linker_script'] != sct_file:
self.generated_files.append(ctx['linker_script'])
core = ctx['device'].core
ctx['cputype'] = core.rstrip("FD")

View File

@ -16,8 +16,8 @@ limitations under the License.
"""
import re
from copy import copy
from os.path import join, dirname, splitext, basename, exists
from os import makedirs, write
from os.path import join, dirname, splitext, basename, exists, relpath
from os import makedirs, write, curdir
from tempfile import mkstemp
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
@ -184,7 +184,7 @@ class ARM(mbedToolchain):
def compile_cpp(self, source, object, includes):
return self.compile(self.cppc, source, object, includes)
def correct_scatter_shebang(self, scatter_file):
def correct_scatter_shebang(self, scatter_file, base_path=curdir):
"""Correct the shebang at the top of a scatter file.
Positional arguments:
@ -203,7 +203,8 @@ class ARM(mbedToolchain):
return scatter_file
else:
new_scatter = join(self.build_dir, ".link_script.sct")
self.SHEBANG += " -I %s" % dirname(scatter_file)
self.SHEBANG += " -I %s" % relpath(dirname(scatter_file),
base_path)
if self.need_update(new_scatter, [scatter_file]):
with open(new_scatter, "wb") as out:
out.write(self.SHEBANG)