Skip to content

Commit fa527cf

Browse files
committed
Rework vpaths and include file locating
1 parent 4b7f591 commit fa527cf

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

tools/export/gcc_arm_common.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ clean :
2929
{% endblock %}
3030
else
3131

32-
VPATH = $(SRCDIR)
32+
VPATH = {% for path in vpath %}{{path}} {% endfor %}
3333

3434
GCC_BIN =
3535
PROJECT = {{name}}
3636
OBJECTS = {% for f in to_be_compiled %}{{f}} {% endfor %}
3737
SYS_OBJECTS = {% for f in object_files %}{{f}} {% endfor %}
38-
INCLUDE_PATHS = {% for p in include_paths %}-I../{{p}} {% endfor %}
39-
LIBRARY_PATHS = {% for p in library_paths %}-L../{{p}} {% endfor %}
38+
INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %}
39+
LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %}
4040
LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %}
4141
LINKER_SCRIPT = {{linker_script}}
4242
{%- block additional_variables -%}{% endblock %}

tools/export/gccarm.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
limitations under the License.
1616
"""
1717
from exporters import Exporter
18-
from os.path import splitext, basename
19-
from os import curdir
18+
from os.path import splitext, basename, relpath, join, abspath
19+
from os import curdir, getcwd
2020

2121

2222
class GccArm(Exporter):
@@ -133,7 +133,7 @@ class GccArm(Exporter):
133133
def generate(self):
134134
# "make" wants Unix paths
135135
self.resources.win_to_unix()
136-
self.resources.relative_to(curdir)
136+
self.resources.relative_to(self.prj_paths[0])
137137

138138
to_be_compiled = []
139139
for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
@@ -148,6 +148,7 @@ def generate(self):
148148
l, _ = splitext(basename(lib))
149149
libraries.append(l[3:])
150150

151+
build_dir = abspath(join(self.inputDir, ".build"))
151152
ctx = {
152153
'name': self.program_name,
153154
'to_be_compiled': to_be_compiled,
@@ -157,7 +158,20 @@ def generate(self):
157158
'linker_script': self.resources.linker_script,
158159
'libraries': libraries,
159160
'symbols': self.get_symbols(),
160-
'cpu_flags': self.toolchain.cpu
161+
'cpu_flags': self.toolchain.cpu,
162+
'vpath': [relpath(s, build_dir) for s in self.prj_paths] if self.sources_relative else ["../"]
161163
}
164+
165+
for key in ['include_paths', 'library_paths', 'linker_script']:
166+
if isinstance(ctx[key], list):
167+
ctx[key] = [ctx['vpath'][0] + "/" + t for t in ctx[key]]
168+
else:
169+
ctx[key] = ctx['vpath'][0] + "/" + ctx[key]
170+
if "../." not in ctx["include_paths"]:
171+
ctx["include_paths"] += ['../.']
162172
ctx.update(self.progen_flags)
163173
self.gen_file('gcc_arm_%s.tmpl' % self.target.lower(), ctx, 'Makefile')
174+
175+
def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):
176+
self.prj_paths = prj_paths
177+
Exporter.scan_and_copy_resources(self, prj_paths, trg_path, relative)

0 commit comments

Comments
 (0)