Skip to content

Commit b5c1899

Browse files
committed
Fix include paths for fragmented projects; remove deadcode
1 parent c550f9d commit b5c1899

File tree

1 file changed

+7
-55
lines changed

1 file changed

+7
-55
lines changed

tools/project_api.py

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ def get_exporter_toolchain(ide):
2424
return EXPORTERS[ide], EXPORTERS[ide].TOOLCHAIN
2525

2626

27-
def rewrite_basepath(file_name, resources, export_path):
27+
def rewrite_basepath(file_name, resources, export_path, loc):
2828
""" Replace the basepath of filename with export_path
2929
3030
Positional arguments:
3131
file_name - the absolute path to a file
3232
resources - the resources object that the file came from
3333
export_path - the final destination of the file after export
3434
"""
35-
new_f = relpath(file_name, resources.file_basepath[file_name])
35+
new_f = join(loc, relpath(file_name, resources.file_basepath[file_name]))
3636
resources.file_basepath[join(export_path, new_f)] = export_path
3737
return new_f
3838

3939

40-
def subtract_basepath(resources, export_path):
40+
def subtract_basepath(resources, export_path, loc=""):
4141
""" Rewrite all of the basepaths with the export_path
4242
4343
Positional arguments:
@@ -55,63 +55,15 @@ def subtract_basepath(resources, export_path):
5555
if isinstance(vals, list):
5656
new_vals = []
5757
for val in vals:
58-
new_vals.append(rewrite_basepath(val, resources, export_path))
58+
new_vals.append(rewrite_basepath(val, resources, export_path,
59+
loc))
5960
if isinstance(getattr(resources, key), set):
6061
setattr(resources, key, set(new_vals))
6162
else:
6263
setattr(resources, key, new_vals)
6364
elif vals:
6465
setattr(resources, key, rewrite_basepath(vals, resources,
65-
export_path))
66-
67-
68-
def prepare_project(src_paths, export_path, target, ide,
69-
libraries_paths=None, options=None, linker_script=None,
70-
clean=False, notify=None, verbose=False, name=None,
71-
inc_dirs=None, jobs=1, silent=False, extra_verbose=False,
72-
config=None, macros=None):
73-
""" This function normalizes the
74-
"""
75-
76-
# Convert src_path to a list if needed
77-
if type(src_paths) != type([]):
78-
src_paths = [src_paths]
79-
# Extend src_paths wiht libraries_paths
80-
if libraries_paths is not None:
81-
src_paths.extend(libraries_paths)
82-
83-
# Export Directory
84-
if exists(export_path) and clean:
85-
rmtree(export_path)
86-
if not exists(export_path):
87-
makedirs(export_path)
88-
89-
_, toolchain_name = get_exporter_toolchain(ide)
90-
91-
# Pass all params to the unified prepare_resources()
92-
toolchain = prepare_toolchain(src_paths, target,
93-
toolchain_name, macros=macros,
94-
options=options, clean=clean, jobs=jobs,
95-
notify=notify, silent=silent, verbose=verbose,
96-
extra_verbose=extra_verbose, config=config)
97-
98-
99-
# The first path will give the name to the library
100-
if name is None:
101-
name = basename(normpath(abspath(src_paths[0])))
102-
103-
# Call unified scan_resources
104-
resources = scan_resources(src_paths, toolchain, inc_dirs=inc_dirs)
105-
toolchain.build_dir = export_path
106-
config_header = toolchain.get_config_header()
107-
resources.headers.append(config_header)
108-
resources.file_basepath[config_header] = dirname(config_header)
109-
110-
# Change linker script if specified
111-
if linker_script is not None:
112-
resources.linker_script = linker_script
113-
114-
return resources, toolchain
66+
export_path, loc))
11567

11668

11769
def generate_project_files(resources, export_path, target, name, toolchain, ide,
@@ -243,7 +195,7 @@ def export_project(src_paths, export_path, target, ide,
243195
subtract_basepath(resources, export_path)
244196
for loc, res in resource_dict.iteritems():
245197
temp = copy.deepcopy(res)
246-
subtract_basepath(temp, join(export_path, loc))
198+
subtract_basepath(temp, export_path, loc)
247199
resources.add(temp)
248200
else:
249201
for _, res in resource_dict.iteritems():

0 commit comments

Comments
 (0)