mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

UserRevisionLine numberNew contents of line
be_bryan 0:b74591d5ab33 1 """The generic interface for all exporters.
be_bryan 0:b74591d5ab33 2 """
be_bryan 0:b74591d5ab33 3 # mbed SDK
be_bryan 0:b74591d5ab33 4 # Copyright (c) 2011-2016 ARM Limited
be_bryan 0:b74591d5ab33 5 #
be_bryan 0:b74591d5ab33 6 # Licensed under the Apache License, Version 2.0 (the "License");
be_bryan 0:b74591d5ab33 7 # you may not use this file except in compliance with the License.
be_bryan 0:b74591d5ab33 8 # You may obtain a copy of the License at
be_bryan 0:b74591d5ab33 9 #
be_bryan 0:b74591d5ab33 10 # http://www.apache.org/licenses/LICENSE-2.0
be_bryan 0:b74591d5ab33 11 #
be_bryan 0:b74591d5ab33 12 # Unless required by applicable law or agreed to in writing, software
be_bryan 0:b74591d5ab33 13 # distributed under the License is distributed on an "AS IS" BASIS,
be_bryan 0:b74591d5ab33 14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
be_bryan 0:b74591d5ab33 15 # See the License for the specific language governing permissions and
be_bryan 0:b74591d5ab33 16 # limitations under the License.
be_bryan 0:b74591d5ab33 17
be_bryan 0:b74591d5ab33 18 import sys
be_bryan 0:b74591d5ab33 19 from os.path import join, abspath, dirname, exists
be_bryan 0:b74591d5ab33 20 from os.path import basename, relpath, normpath, splitext
be_bryan 0:b74591d5ab33 21 from os import makedirs, walk
be_bryan 0:b74591d5ab33 22 import copy
be_bryan 0:b74591d5ab33 23 from shutil import rmtree, copyfile
be_bryan 0:b74591d5ab33 24 import zipfile
be_bryan 0:b74591d5ab33 25 ROOT = abspath(join(dirname(__file__), ".."))
be_bryan 0:b74591d5ab33 26 sys.path.insert(0, ROOT)
be_bryan 0:b74591d5ab33 27
be_bryan 0:b74591d5ab33 28 from tools.build_api import prepare_toolchain
be_bryan 0:b74591d5ab33 29 from tools.build_api import scan_resources
be_bryan 0:b74591d5ab33 30 from tools.toolchains import Resources
be_bryan 0:b74591d5ab33 31 from tools.export import lpcxpresso, ds5_5, iar, makefile
be_bryan 0:b74591d5ab33 32 from tools.export import embitz, coide, kds, simplicity, atmelstudio, mcuxpresso
be_bryan 0:b74591d5ab33 33 from tools.export import sw4stm32, e2studio, zip, cmsis, uvision, cdt, vscode
be_bryan 0:b74591d5ab33 34 from tools.export import gnuarmeclipse
be_bryan 0:b74591d5ab33 35 from tools.export import qtcreator
be_bryan 0:b74591d5ab33 36 from tools.targets import TARGET_NAMES
be_bryan 0:b74591d5ab33 37
be_bryan 0:b74591d5ab33 38 EXPORTERS = {
be_bryan 0:b74591d5ab33 39 'uvision5': uvision.Uvision,
be_bryan 0:b74591d5ab33 40 'uvision': uvision.Uvision,
be_bryan 0:b74591d5ab33 41 'lpcxpresso': lpcxpresso.LPCXpresso,
be_bryan 0:b74591d5ab33 42 'gcc_arm': makefile.GccArm,
be_bryan 0:b74591d5ab33 43 'make_gcc_arm': makefile.GccArm,
be_bryan 0:b74591d5ab33 44 'make_armc5': makefile.Armc5,
be_bryan 0:b74591d5ab33 45 'make_armc6': makefile.Armc6,
be_bryan 0:b74591d5ab33 46 'make_iar': makefile.IAR,
be_bryan 0:b74591d5ab33 47 'ds5_5': ds5_5.DS5_5,
be_bryan 0:b74591d5ab33 48 'iar': iar.IAR,
be_bryan 0:b74591d5ab33 49 'embitz' : embitz.EmBitz,
be_bryan 0:b74591d5ab33 50 'coide' : coide.CoIDE,
be_bryan 0:b74591d5ab33 51 'kds' : kds.KDS,
be_bryan 0:b74591d5ab33 52 'simplicityv3' : simplicity.SimplicityV3,
be_bryan 0:b74591d5ab33 53 'atmelstudio' : atmelstudio.AtmelStudio,
be_bryan 0:b74591d5ab33 54 'sw4stm32' : sw4stm32.Sw4STM32,
be_bryan 0:b74591d5ab33 55 'e2studio' : e2studio.E2Studio,
be_bryan 0:b74591d5ab33 56 'eclipse_gcc_arm' : cdt.EclipseGcc,
be_bryan 0:b74591d5ab33 57 'eclipse_iar' : cdt.EclipseIAR,
be_bryan 0:b74591d5ab33 58 'eclipse_armc5' : cdt.EclipseArmc5,
be_bryan 0:b74591d5ab33 59 'gnuarmeclipse': gnuarmeclipse.GNUARMEclipse,
be_bryan 0:b74591d5ab33 60 'mcuxpresso': mcuxpresso.MCUXpresso,
be_bryan 0:b74591d5ab33 61 'qtcreator': qtcreator.QtCreator,
be_bryan 0:b74591d5ab33 62 'vscode_gcc_arm' : vscode.VSCodeGcc,
be_bryan 0:b74591d5ab33 63 'vscode_iar' : vscode.VSCodeIAR,
be_bryan 0:b74591d5ab33 64 'vscode_armc5' : vscode.VSCodeArmc5
be_bryan 0:b74591d5ab33 65 }
be_bryan 0:b74591d5ab33 66
be_bryan 0:b74591d5ab33 67 ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """
be_bryan 0:b74591d5ab33 68 Sorry, the target %s is not currently supported on the %s toolchain.
be_bryan 0:b74591d5ab33 69 Please refer to <a href='/handbook/Exporting-to-offline-toolchains' target='_blank'>Exporting to offline toolchains</a> for more information.
be_bryan 0:b74591d5ab33 70 """
be_bryan 0:b74591d5ab33 71
be_bryan 0:b74591d5ab33 72 ERROR_MESSAGE_NOT_EXPORT_LIBS = """
be_bryan 0:b74591d5ab33 73 To export this project please <a href='http://mbed.org/compiler/?import=http://mbed.org/users/mbed_official/code/mbed-export/k&mode=lib' target='_blank'>import the export version of the mbed library</a>.
be_bryan 0:b74591d5ab33 74 """
be_bryan 0:b74591d5ab33 75
be_bryan 0:b74591d5ab33 76 def mcu_ide_list():
be_bryan 0:b74591d5ab33 77 """Shows list of exportable ides
be_bryan 0:b74591d5ab33 78
be_bryan 0:b74591d5ab33 79 """
be_bryan 0:b74591d5ab33 80 supported_ides = sorted(EXPORTERS.keys())
be_bryan 0:b74591d5ab33 81 return "\n".join(supported_ides)
be_bryan 0:b74591d5ab33 82
be_bryan 0:b74591d5ab33 83
be_bryan 0:b74591d5ab33 84 def mcu_ide_matrix(verbose_html=False):
be_bryan 0:b74591d5ab33 85 """Shows target map using prettytable
be_bryan 0:b74591d5ab33 86
be_bryan 0:b74591d5ab33 87 Keyword argumets:
be_bryan 0:b74591d5ab33 88 verbose_html - print the matrix in html format
be_bryan 0:b74591d5ab33 89 """
be_bryan 0:b74591d5ab33 90 supported_ides = sorted(EXPORTERS.keys())
be_bryan 0:b74591d5ab33 91 # Only use it in this function so building works without extra modules
be_bryan 0:b74591d5ab33 92 from prettytable import PrettyTable, ALL
be_bryan 0:b74591d5ab33 93
be_bryan 0:b74591d5ab33 94 # All tests status table print
be_bryan 0:b74591d5ab33 95 table_printer = PrettyTable(["Platform"] + supported_ides)
be_bryan 0:b74591d5ab33 96 # Align table
be_bryan 0:b74591d5ab33 97 for col in supported_ides:
be_bryan 0:b74591d5ab33 98 table_printer.align[col] = "c"
be_bryan 0:b74591d5ab33 99 table_printer.align["Platform"] = "l"
be_bryan 0:b74591d5ab33 100
be_bryan 0:b74591d5ab33 101 perm_counter = 0
be_bryan 0:b74591d5ab33 102 for target in sorted(TARGET_NAMES):
be_bryan 0:b74591d5ab33 103 row = [target] # First column is platform name
be_bryan 0:b74591d5ab33 104 for ide in supported_ides:
be_bryan 0:b74591d5ab33 105 text = "-"
be_bryan 0:b74591d5ab33 106 if EXPORTERS[ide].is_target_supported(target):
be_bryan 0:b74591d5ab33 107 if verbose_html:
be_bryan 0:b74591d5ab33 108 text = "&#10003;"
be_bryan 0:b74591d5ab33 109 else:
be_bryan 0:b74591d5ab33 110 text = "x"
be_bryan 0:b74591d5ab33 111 perm_counter += 1
be_bryan 0:b74591d5ab33 112 row.append(text)
be_bryan 0:b74591d5ab33 113 table_printer.add_row(row)
be_bryan 0:b74591d5ab33 114
be_bryan 0:b74591d5ab33 115 table_printer.border = True
be_bryan 0:b74591d5ab33 116 table_printer.vrules = ALL
be_bryan 0:b74591d5ab33 117 table_printer.hrules = ALL
be_bryan 0:b74591d5ab33 118 # creates a html page in a shorter format suitable for readme.md
be_bryan 0:b74591d5ab33 119 if verbose_html:
be_bryan 0:b74591d5ab33 120 result = table_printer.get_html_string()
be_bryan 0:b74591d5ab33 121 else:
be_bryan 0:b74591d5ab33 122 result = table_printer.get_string()
be_bryan 0:b74591d5ab33 123 result += "\n"
be_bryan 0:b74591d5ab33 124 result += "Total IDEs: %d\n"% (len(supported_ides))
be_bryan 0:b74591d5ab33 125 if verbose_html:
be_bryan 0:b74591d5ab33 126 result += "<br>"
be_bryan 0:b74591d5ab33 127 result += "Total platforms: %d\n"% (len(TARGET_NAMES))
be_bryan 0:b74591d5ab33 128 if verbose_html:
be_bryan 0:b74591d5ab33 129 result += "<br>"
be_bryan 0:b74591d5ab33 130 result += "Total permutations: %d"% (perm_counter)
be_bryan 0:b74591d5ab33 131 if verbose_html:
be_bryan 0:b74591d5ab33 132 result = result.replace("&amp;", "&")
be_bryan 0:b74591d5ab33 133 return result
be_bryan 0:b74591d5ab33 134
be_bryan 0:b74591d5ab33 135
be_bryan 0:b74591d5ab33 136 def get_exporter_toolchain(ide):
be_bryan 0:b74591d5ab33 137 """ Return the exporter class and the toolchain string as a tuple
be_bryan 0:b74591d5ab33 138
be_bryan 0:b74591d5ab33 139 Positional arguments:
be_bryan 0:b74591d5ab33 140 ide - the ide name of an exporter
be_bryan 0:b74591d5ab33 141 """
be_bryan 0:b74591d5ab33 142 return EXPORTERS[ide], EXPORTERS[ide].TOOLCHAIN
be_bryan 0:b74591d5ab33 143
be_bryan 0:b74591d5ab33 144
be_bryan 0:b74591d5ab33 145 def rewrite_basepath(file_name, resources, export_path, loc):
be_bryan 0:b74591d5ab33 146 """ Replace the basepath of filename with export_path
be_bryan 0:b74591d5ab33 147
be_bryan 0:b74591d5ab33 148 Positional arguments:
be_bryan 0:b74591d5ab33 149 file_name - the absolute path to a file
be_bryan 0:b74591d5ab33 150 resources - the resources object that the file came from
be_bryan 0:b74591d5ab33 151 export_path - the final destination of the file after export
be_bryan 0:b74591d5ab33 152 """
be_bryan 0:b74591d5ab33 153 new_f = join(loc, relpath(file_name, resources.file_basepath[file_name]))
be_bryan 0:b74591d5ab33 154 resources.file_basepath[new_f] = export_path
be_bryan 0:b74591d5ab33 155 return new_f
be_bryan 0:b74591d5ab33 156
be_bryan 0:b74591d5ab33 157
be_bryan 0:b74591d5ab33 158 def subtract_basepath(resources, export_path, loc=""):
be_bryan 0:b74591d5ab33 159 """ Rewrite all of the basepaths with the export_path
be_bryan 0:b74591d5ab33 160
be_bryan 0:b74591d5ab33 161 Positional arguments:
be_bryan 0:b74591d5ab33 162 resources - the resource object to rewrite the basepaths of
be_bryan 0:b74591d5ab33 163 export_path - the final destination of the resources with respect to the
be_bryan 0:b74591d5ab33 164 generated project files
be_bryan 0:b74591d5ab33 165 """
be_bryan 0:b74591d5ab33 166 keys = ['s_sources', 'c_sources', 'cpp_sources', 'hex_files',
be_bryan 0:b74591d5ab33 167 'objects', 'libraries', 'inc_dirs', 'headers', 'linker_script',
be_bryan 0:b74591d5ab33 168 'lib_dirs']
be_bryan 0:b74591d5ab33 169 for key in keys:
be_bryan 0:b74591d5ab33 170 vals = getattr(resources, key)
be_bryan 0:b74591d5ab33 171 if isinstance(vals, set):
be_bryan 0:b74591d5ab33 172 vals = list(vals)
be_bryan 0:b74591d5ab33 173 if isinstance(vals, list):
be_bryan 0:b74591d5ab33 174 new_vals = []
be_bryan 0:b74591d5ab33 175 for val in vals:
be_bryan 0:b74591d5ab33 176 new_vals.append(rewrite_basepath(val, resources, export_path,
be_bryan 0:b74591d5ab33 177 loc))
be_bryan 0:b74591d5ab33 178 if isinstance(getattr(resources, key), set):
be_bryan 0:b74591d5ab33 179 setattr(resources, key, set(new_vals))
be_bryan 0:b74591d5ab33 180 else:
be_bryan 0:b74591d5ab33 181 setattr(resources, key, new_vals)
be_bryan 0:b74591d5ab33 182 elif vals:
be_bryan 0:b74591d5ab33 183 setattr(resources, key, rewrite_basepath(vals, resources,
be_bryan 0:b74591d5ab33 184 export_path, loc))
be_bryan 0:b74591d5ab33 185
be_bryan 0:b74591d5ab33 186
be_bryan 0:b74591d5ab33 187 def generate_project_files(resources, export_path, target, name, toolchain, ide,
be_bryan 0:b74591d5ab33 188 macros=None):
be_bryan 0:b74591d5ab33 189 """Generate the project files for a project
be_bryan 0:b74591d5ab33 190
be_bryan 0:b74591d5ab33 191 Positional arguments:
be_bryan 0:b74591d5ab33 192 resources - a Resources object containing all of the files needed to build
be_bryan 0:b74591d5ab33 193 this project
be_bryan 0:b74591d5ab33 194 export_path - location to place project files
be_bryan 0:b74591d5ab33 195 name - name of the project
be_bryan 0:b74591d5ab33 196 toolchain - a toolchain class that corresponds to the toolchain used by the
be_bryan 0:b74591d5ab33 197 IDE or makefile
be_bryan 0:b74591d5ab33 198 ide - IDE name to export to
be_bryan 0:b74591d5ab33 199
be_bryan 0:b74591d5ab33 200 Optional arguments:
be_bryan 0:b74591d5ab33 201 macros - additional macros that should be defined within the exported
be_bryan 0:b74591d5ab33 202 project
be_bryan 0:b74591d5ab33 203 """
be_bryan 0:b74591d5ab33 204 exporter_cls, _ = get_exporter_toolchain(ide)
be_bryan 0:b74591d5ab33 205 exporter = exporter_cls(target, export_path, name, toolchain,
be_bryan 0:b74591d5ab33 206 extra_symbols=macros, resources=resources)
be_bryan 0:b74591d5ab33 207 exporter.generate()
be_bryan 0:b74591d5ab33 208 files = exporter.generated_files
be_bryan 0:b74591d5ab33 209 return files, exporter
be_bryan 0:b74591d5ab33 210
be_bryan 0:b74591d5ab33 211
be_bryan 0:b74591d5ab33 212 def zip_export(file_name, prefix, resources, project_files, inc_repos):
be_bryan 0:b74591d5ab33 213 """Create a zip file from an exported project.
be_bryan 0:b74591d5ab33 214
be_bryan 0:b74591d5ab33 215 Positional Parameters:
be_bryan 0:b74591d5ab33 216 file_name - the file name of the resulting zip file
be_bryan 0:b74591d5ab33 217 prefix - a directory name that will prefix the entire zip file's contents
be_bryan 0:b74591d5ab33 218 resources - a resources object with files that must be included in the zip
be_bryan 0:b74591d5ab33 219 project_files - a list of extra files to be added to the root of the prefix
be_bryan 0:b74591d5ab33 220 directory
be_bryan 0:b74591d5ab33 221 """
be_bryan 0:b74591d5ab33 222 with zipfile.ZipFile(file_name, "w") as zip_file:
be_bryan 0:b74591d5ab33 223 for prj_file in project_files:
be_bryan 0:b74591d5ab33 224 zip_file.write(prj_file, join(prefix, basename(prj_file)))
be_bryan 0:b74591d5ab33 225 for loc, res in resources.iteritems():
be_bryan 0:b74591d5ab33 226 to_zip = (
be_bryan 0:b74591d5ab33 227 res.headers + res.s_sources + res.c_sources +\
be_bryan 0:b74591d5ab33 228 res.cpp_sources + res.libraries + res.hex_files + \
be_bryan 0:b74591d5ab33 229 [res.linker_script] + res.bin_files + res.objects + \
be_bryan 0:b74591d5ab33 230 res.json_files + res.lib_refs + res.lib_builds)
be_bryan 0:b74591d5ab33 231 if inc_repos:
be_bryan 0:b74591d5ab33 232 for directory in res.repo_dirs:
be_bryan 0:b74591d5ab33 233 for root, _, files in walk(directory):
be_bryan 0:b74591d5ab33 234 for repo_file in files:
be_bryan 0:b74591d5ab33 235 source = join(root, repo_file)
be_bryan 0:b74591d5ab33 236 to_zip.append(source)
be_bryan 0:b74591d5ab33 237 res.file_basepath[source] = res.base_path
be_bryan 0:b74591d5ab33 238 to_zip += res.repo_files
be_bryan 0:b74591d5ab33 239 for source in to_zip:
be_bryan 0:b74591d5ab33 240 if source:
be_bryan 0:b74591d5ab33 241 zip_file.write(
be_bryan 0:b74591d5ab33 242 source,
be_bryan 0:b74591d5ab33 243 join(prefix, loc,
be_bryan 0:b74591d5ab33 244 relpath(source, res.file_basepath[source])))
be_bryan 0:b74591d5ab33 245 for source in res.lib_builds:
be_bryan 0:b74591d5ab33 246 target_dir, _ = splitext(source)
be_bryan 0:b74591d5ab33 247 dest = join(prefix, loc,
be_bryan 0:b74591d5ab33 248 relpath(target_dir, res.file_basepath[source]),
be_bryan 0:b74591d5ab33 249 ".bld", "bldrc")
be_bryan 0:b74591d5ab33 250 zip_file.write(source, dest)
be_bryan 0:b74591d5ab33 251
be_bryan 0:b74591d5ab33 252
be_bryan 0:b74591d5ab33 253
be_bryan 0:b74591d5ab33 254 def export_project(src_paths, export_path, target, ide, libraries_paths=None,
be_bryan 0:b74591d5ab33 255 linker_script=None, notify=None, verbose=False, name=None,
be_bryan 0:b74591d5ab33 256 inc_dirs=None, jobs=1, silent=False, extra_verbose=False,
be_bryan 0:b74591d5ab33 257 config=None, macros=None, zip_proj=None, inc_repos=False,
be_bryan 0:b74591d5ab33 258 build_profile=None, app_config=None):
be_bryan 0:b74591d5ab33 259 """Generates a project file and creates a zip archive if specified
be_bryan 0:b74591d5ab33 260
be_bryan 0:b74591d5ab33 261 Positional Arguments:
be_bryan 0:b74591d5ab33 262 src_paths - a list of paths from which to find source files
be_bryan 0:b74591d5ab33 263 export_path - a path specifying the location of generated project files
be_bryan 0:b74591d5ab33 264 target - the mbed board/mcu for which to generate the executable
be_bryan 0:b74591d5ab33 265 ide - the ide for which to generate the project fields
be_bryan 0:b74591d5ab33 266
be_bryan 0:b74591d5ab33 267 Keyword Arguments:
be_bryan 0:b74591d5ab33 268 libraries_paths - paths to additional libraries
be_bryan 0:b74591d5ab33 269 linker_script - path to the linker script for the specified target
be_bryan 0:b74591d5ab33 270 notify - function is passed all events, and expected to handle notification
be_bryan 0:b74591d5ab33 271 of the user, emit the events to a log, etc.
be_bryan 0:b74591d5ab33 272 verbose - assigns the notify function to toolchains print_notify_verbose
be_bryan 0:b74591d5ab33 273 name - project name
be_bryan 0:b74591d5ab33 274 inc_dirs - additional include directories
be_bryan 0:b74591d5ab33 275 jobs - number of threads
be_bryan 0:b74591d5ab33 276 silent - silent build - no output
be_bryan 0:b74591d5ab33 277 extra_verbose - assigns the notify function to toolchains
be_bryan 0:b74591d5ab33 278 print_notify_verbose
be_bryan 0:b74591d5ab33 279 config - toolchain's config object
be_bryan 0:b74591d5ab33 280 macros - User-defined macros
be_bryan 0:b74591d5ab33 281 zip_proj - string name of the zip archive you wish to creat (exclude arg
be_bryan 0:b74591d5ab33 282 if you do not wish to create an archive
be_bryan 0:b74591d5ab33 283 """
be_bryan 0:b74591d5ab33 284
be_bryan 0:b74591d5ab33 285 # Convert src_path to a list if needed
be_bryan 0:b74591d5ab33 286 if isinstance(src_paths, dict):
be_bryan 0:b74591d5ab33 287 paths = sum(src_paths.values(), [])
be_bryan 0:b74591d5ab33 288 elif isinstance(src_paths, list):
be_bryan 0:b74591d5ab33 289 paths = src_paths[:]
be_bryan 0:b74591d5ab33 290 else:
be_bryan 0:b74591d5ab33 291 paths = [src_paths]
be_bryan 0:b74591d5ab33 292
be_bryan 0:b74591d5ab33 293 # Extend src_paths wit libraries_paths
be_bryan 0:b74591d5ab33 294 if libraries_paths is not None:
be_bryan 0:b74591d5ab33 295 paths.extend(libraries_paths)
be_bryan 0:b74591d5ab33 296
be_bryan 0:b74591d5ab33 297 if not isinstance(src_paths, dict):
be_bryan 0:b74591d5ab33 298 src_paths = {"": paths}
be_bryan 0:b74591d5ab33 299
be_bryan 0:b74591d5ab33 300 # Export Directory
be_bryan 0:b74591d5ab33 301 if not exists(export_path):
be_bryan 0:b74591d5ab33 302 makedirs(export_path)
be_bryan 0:b74591d5ab33 303
be_bryan 0:b74591d5ab33 304 _, toolchain_name = get_exporter_toolchain(ide)
be_bryan 0:b74591d5ab33 305
be_bryan 0:b74591d5ab33 306 # Pass all params to the unified prepare_resources()
be_bryan 0:b74591d5ab33 307 toolchain = prepare_toolchain(
be_bryan 0:b74591d5ab33 308 paths, "", target, toolchain_name, macros=macros, jobs=jobs,
be_bryan 0:b74591d5ab33 309 notify=notify, silent=silent, verbose=verbose,
be_bryan 0:b74591d5ab33 310 extra_verbose=extra_verbose, config=config, build_profile=build_profile,
be_bryan 0:b74591d5ab33 311 app_config=app_config)
be_bryan 0:b74591d5ab33 312 # The first path will give the name to the library
be_bryan 0:b74591d5ab33 313 toolchain.RESPONSE_FILES = False
be_bryan 0:b74591d5ab33 314 if name is None:
be_bryan 0:b74591d5ab33 315 name = basename(normpath(abspath(src_paths[0])))
be_bryan 0:b74591d5ab33 316
be_bryan 0:b74591d5ab33 317 # Call unified scan_resources
be_bryan 0:b74591d5ab33 318 resource_dict = {loc: scan_resources(path, toolchain, inc_dirs=inc_dirs, collect_ignores=True)
be_bryan 0:b74591d5ab33 319 for loc, path in src_paths.iteritems()}
be_bryan 0:b74591d5ab33 320 resources = Resources()
be_bryan 0:b74591d5ab33 321 toolchain.build_dir = export_path
be_bryan 0:b74591d5ab33 322 config_header = toolchain.get_config_header()
be_bryan 0:b74591d5ab33 323 resources.headers.append(config_header)
be_bryan 0:b74591d5ab33 324 resources.file_basepath[config_header] = dirname(config_header)
be_bryan 0:b74591d5ab33 325
be_bryan 0:b74591d5ab33 326 if zip_proj:
be_bryan 0:b74591d5ab33 327 subtract_basepath(resources, ".")
be_bryan 0:b74591d5ab33 328 for loc, res in resource_dict.iteritems():
be_bryan 0:b74591d5ab33 329 temp = copy.deepcopy(res)
be_bryan 0:b74591d5ab33 330 subtract_basepath(temp, ".", loc)
be_bryan 0:b74591d5ab33 331 resources.add(temp)
be_bryan 0:b74591d5ab33 332 else:
be_bryan 0:b74591d5ab33 333 for _, res in resource_dict.iteritems():
be_bryan 0:b74591d5ab33 334 resources.add(res)
be_bryan 0:b74591d5ab33 335
be_bryan 0:b74591d5ab33 336 # Change linker script if specified
be_bryan 0:b74591d5ab33 337 if linker_script is not None:
be_bryan 0:b74591d5ab33 338 resources.linker_script = linker_script
be_bryan 0:b74591d5ab33 339
be_bryan 0:b74591d5ab33 340 files, exporter = generate_project_files(resources, export_path,
be_bryan 0:b74591d5ab33 341 target, name, toolchain, ide,
be_bryan 0:b74591d5ab33 342 macros=macros)
be_bryan 0:b74591d5ab33 343 files.append(config_header)
be_bryan 0:b74591d5ab33 344 if zip_proj:
be_bryan 0:b74591d5ab33 345 for resource in resource_dict.values():
be_bryan 0:b74591d5ab33 346 for label, res in resource.features.iteritems():
be_bryan 0:b74591d5ab33 347 if label not in toolchain.target.features:
be_bryan 0:b74591d5ab33 348 resource.add(res)
be_bryan 0:b74591d5ab33 349 if isinstance(zip_proj, basestring):
be_bryan 0:b74591d5ab33 350 zip_export(join(export_path, zip_proj), name, resource_dict,
be_bryan 0:b74591d5ab33 351 files + list(exporter.static_files), inc_repos)
be_bryan 0:b74591d5ab33 352 else:
be_bryan 0:b74591d5ab33 353 zip_export(zip_proj, name, resource_dict,
be_bryan 0:b74591d5ab33 354 files + list(exporter.static_files), inc_repos)
be_bryan 0:b74591d5ab33 355 else:
be_bryan 0:b74591d5ab33 356 for static_file in exporter.static_files:
be_bryan 0:b74591d5ab33 357 if not exists(join(export_path, basename(static_file))):
be_bryan 0:b74591d5ab33 358 copyfile(static_file, join(export_path, basename(static_file)))
be_bryan 0:b74591d5ab33 359
be_bryan 0:b74591d5ab33 360 return exporter