def generate(self): """ Generate the .project and .cproject files. """ if not self.resources.linker_script: raise NotSupportedException("No linker script found.") self.resources.win_to_unix() # TODO: use some logger to display additional info if verbose libraries = [] # print 'libraries' # print self.resources.libraries for lib in self.libraries: l, _ = splitext(basename(lib)) libraries.append(l[3:]) self.system_libraries = ['stdc++', 'supc++', 'm', 'c', 'gcc', 'nosys'] # Read in all profiles, we'll extract compiler options. profiles = self.get_all_profiles() profile_ids = [s.lower() for s in profiles] profile_ids.sort() # TODO: get the list from existing .cproject build_folders = [s.capitalize() for s in profile_ids] build_folders.append('BUILD') # print build_folders objects = [self.filter_dot(s) for s in self.resources.objects] for bf in build_folders: objects = [o for o in objects if not o.startswith(bf + '/')] # print 'objects' # print objects self.compute_exclusions() self.include_path = [ self.filter_dot(s) for s in self.resources.inc_dirs ] self.as_defines = self.toolchain.get_symbols(True) self.c_defines = self.toolchain.get_symbols() self.cpp_defines = self.c_defines self.ld_script = self.filter_dot(self.resources.linker_script) self.options = {} profile_ids.remove('develop') for id in profile_ids: # There are 4 categories of options, a category common too # all tools and a specific category for each of the tools. opts = {} opts['common'] = {} opts['as'] = {} opts['c'] = {} opts['cpp'] = {} opts['ld'] = {} opts['id'] = id opts['name'] = opts['id'].capitalize() print profile = profiles[id] # A small hack, do not bother with src_path again, # pass an empty string to avoid crashing. src_paths = [''] target_name = self.toolchain.target.name toolchain = prepare_toolchain(src_paths, "", target_name, self.TOOLCHAIN, build_profile=[profile]) # Hack to fill in build_dir toolchain.build_dir = self.toolchain.build_dir flags = self.toolchain_flags(toolchain) # Most GNU ARM Eclipse options have a parent, # either debug or release. if '-O0' in flags['common_flags'] or '-Og' in flags['common_flags']: opts['parent_id'] = 'debug' else: opts['parent_id'] = 'release' self.process_options(opts, flags, libraries) opts['as']['defines'] = self.as_defines opts['c']['defines'] = self.c_defines opts['cpp']['defines'] = self.cpp_defines opts['common']['include_paths'] = self.include_path opts['common']['excluded_folders'] = '|'.join( self.excluded_folders) self.excluded_folders = [ item.replace("\\", "/") for item in self.excluded_folders ] opts['ld']['library_paths'] = [ self.filter_dot(s) for s in self.resources.lib_dirs ] opts['ld']['object_files'] = objects opts['ld']['user_libraries'] = libraries opts['ld']['system_libraries'] = self.system_libraries opts['ld']['script'] = "linker-script-%s.ld" % id opts['cpp_cmd'] = " ".join(toolchain.preproc) # Unique IDs used in multiple places. # Those used only once are implemented with {{u.id}}. u = UID() uid = {} uid['config'] = u.id uid['tool_c_compiler'] = u.id uid['tool_c_compiler_input'] = u.id uid['tool_cpp_compiler'] = u.id uid['tool_cpp_compiler_input'] = u.id opts['uid'] = uid self.options[id] = opts jinja_ctx = { 'name': self.project_name, 'ld_script': self.ld_script, # Compiler & linker command line options 'options': self.options, # Must be an object with an `id` property, which # will be called repeatedly, to generate multiple UIDs. 'u': u, } self.gen_file('mcuxpresso/.project.tmpl', jinja_ctx, '.project', trim_blocks=True, lstrip_blocks=True) self.gen_file('mcuxpresso/{0}_cproject.tmpl'.format(target_name), jinja_ctx, '.cproject', trim_blocks=True, lstrip_blocks=True) self.gen_file('mcuxpresso/makefile.targets.tmpl', jinja_ctx, 'makefile.targets', trim_blocks=True, lstrip_blocks=True) self.gen_file_nonoverwrite('mcuxpresso/mbedignore.tmpl', jinja_ctx, '.mbedignore') print('Done. Import the \'{0}\' project in MCUXpresso.'.format( self.project_name))
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from os.path import splitext, basename, join from tools.utils import mkdir from tools.export.gnuarmeclipse import GNUARMEclipse from tools.export.gnuarmeclipse import UID from tools.build_api import prepare_toolchain from sys import flags, platform # Global random number generator instance. u = UID() class Sw4STM32(GNUARMEclipse): """ Sw4STM32 class """ NAME = 'Sw4STM32' TOOLCHAIN = 'GCC_ARM' BOARDS = { 'B96B_F446VE': { 'name': 'B96B-F446VE', 'mcuId': 'STM32F446VETx' }, 'DISCO_F051R8': {