Merge pull request #3765 from theotherjimmy/remove-zip-dupes

Remove duplicate files in zipped exports
pull/3798/head
Sam Grove 2017-02-17 09:19:12 -06:00 committed by GitHub
commit 9ea5702634
1 changed files with 32 additions and 28 deletions

View File

@ -104,33 +104,32 @@ def zip_export(file_name, prefix, resources, project_files, inc_repos):
with zipfile.ZipFile(file_name, "w") as zip_file: with zipfile.ZipFile(file_name, "w") as zip_file:
for prj_file in project_files: for prj_file in project_files:
zip_file.write(prj_file, join(prefix, basename(prj_file))) zip_file.write(prj_file, join(prefix, basename(prj_file)))
for loc, resource in resources.iteritems(): for loc, res in resources.iteritems():
for res in [resource] + resource.features.values(): to_zip = (
to_zip = ( res.headers + res.s_sources + res.c_sources +\
res.headers + res.s_sources + res.c_sources +\ res.cpp_sources + res.libraries + res.hex_files + \
res.cpp_sources + res.libraries + res.hex_files + \ [res.linker_script] + res.bin_files + res.objects + \
[res.linker_script] + res.bin_files + res.objects + \ res.json_files + res.lib_refs + res.lib_builds)
res.json_files + res.lib_refs + res.lib_builds) if inc_repos:
if inc_repos: for directory in res.repo_dirs:
for directory in res.repo_dirs: for root, _, files in walk(directory):
for root, _, files in walk(directory): for repo_file in files:
for repo_file in files: source = join(root, repo_file)
source = join(root, repo_file) to_zip.append(source)
to_zip.append(source) res.file_basepath[source] = res.base_path
res.file_basepath[source] = res.base_path to_zip += res.repo_files
to_zip += res.repo_files for source in to_zip:
for source in to_zip: if source:
if source: zip_file.write(
zip_file.write( source,
source, join(prefix, loc,
join(prefix, loc, relpath(source, res.file_basepath[source])))
relpath(source, res.file_basepath[source]))) for source in res.lib_builds:
for source in res.lib_builds: target_dir, _ = splitext(source)
target_dir, _ = splitext(source) dest = join(prefix, loc,
dest = join(prefix, loc, relpath(target_dir, res.file_basepath[source]),
relpath(target_dir, res.file_basepath[source]), ".bld", "bldrc")
".bld", "bldrc") zip_file.write(source, dest)
zip_file.write(source, dest)
@ -223,8 +222,13 @@ def export_project(src_paths, export_path, target, ide, libraries_paths=None,
macros=macros) macros=macros)
files.append(config_header) files.append(config_header)
if zip_proj: if zip_proj:
for resource in resource_dict.values():
for label, res in resource.features.iteritems():
if label not in toolchain.target.features:
resource.add(res)
if isinstance(zip_proj, basestring): if isinstance(zip_proj, basestring):
zip_export(join(export_path, zip_proj), name, resource_dict, files, inc_repos) zip_export(join(export_path, zip_proj), name, resource_dict, files,
inc_repos)
else: else:
zip_export(zip_proj, name, resource_dict, files, inc_repos) zip_export(zip_proj, name, resource_dict, files, inc_repos)