Clone of official tools

Committer:
theotherjimmy
Date:
Tue Oct 10 16:56:30 2017 -0500
Revision:
40:7d3fa6b99b2b
Parent:
36:96847d42f010
Child:
43:2a7da56ebd24
Update to tools release 5.6.1

Who changed what in which revision?

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