Skip to content

Commit 3b4a463

Browse files
committed
Move all generated file paths to FileRefs in the exporters.
The FileRefs allow you to preserve the correct file paths in the online compiler. It also allows you to preserve the correct file paths for generated files.
1 parent e239549 commit 3b4a463

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

tools/export/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _inner_zip_export(resources, prj_files, inc_repos):
164164
to_zip = sum((resources.get_file_refs(ftype) for ftype
165165
in Resources.ALL_FILE_TYPES),
166166
[])
167-
to_zip.extend(FileRef(basename(pfile), pfile) for pfile in prj_files)
167+
to_zip.extend(prj_files)
168168
for dest, source in resources.get_file_refs(FileType.BLD_REF):
169169
target_dir, _ = splitext(dest)
170170
dest = join(target_dir, ".bld", "bldrc")

tools/export/exporters.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from tools.targets import TARGET_MAP
2929
from tools.utils import mkdir
30-
from tools.resources import FileType
30+
from tools.resources import FileType, FileRef
3131

3232
"""Just a template for subclassing"""
3333

@@ -95,9 +95,17 @@ def __init__(self, target, export_dir, project_name, toolchain,
9595
resources.win_to_unix()
9696
self.resources = resources
9797
self.generated_files = []
98+
getting_started_name = "GettingStarted.html"
99+
dot_mbed_name = ".mbed"
98100
self.static_files = (
99-
join(self.TEMPLATE_DIR, "GettingStarted.html"),
100-
join(self.TEMPLATE_DIR, ".mbed"),
101+
FileRef(
102+
getting_started_name,
103+
join(self.TEMPLATE_DIR, getting_started_name)
104+
),
105+
FileRef(
106+
dot_mbed_name,
107+
join(self.TEMPLATE_DIR, dot_mbed_name)
108+
),
101109
)
102110
self.builder_files_dict = {}
103111
self.add_config()
@@ -204,7 +212,7 @@ def gen_file(self, template_file, data, target_file, **kwargs):
204212
mkdir(dirname(target_path))
205213
logging.debug("Generating: %s", target_path)
206214
open(target_path, "w").write(target_text)
207-
self.generated_files += [target_path]
215+
self.generated_files += [FileRef(target_file, target_path)]
208216

209217
def gen_file_nonoverwrite(self, template_file, data, target_file, **kwargs):
210218
"""Generates or selectively appends a project file from a template"""
@@ -221,7 +229,7 @@ def gen_file_nonoverwrite(self, template_file, data, target_file, **kwargs):
221229
else:
222230
logging.debug("Generating: %s", target_path)
223231
open(target_path, "w").write(target_text)
224-
self.generated_files += [target_path]
232+
self.generated_files += [FileRef(template_file, target_path)]
225233

226234
def _gen_file_inner(self, template_file, data, target_file, **kwargs):
227235
"""Generates a project file from a template using jinja"""
@@ -237,7 +245,7 @@ def _gen_file_inner(self, template_file, data, target_file, **kwargs):
237245
target_path = join(self.export_dir, target_file)
238246
logging.debug("Generating: %s", target_path)
239247
open(target_path, "w").write(target_text)
240-
self.generated_files += [target_path]
248+
self.generated_files += [FileRef(target_file, target_path)]
241249

242250
def make_key(self, src):
243251
"""From a source file, extract group name

0 commit comments

Comments
 (0)