diff --git a/project_generator/project.py b/project_generator/project.py index 057d2a6a..d1b50a33 100644 --- a/project_generator/project.py +++ b/project_generator/project.py @@ -164,6 +164,8 @@ def get_project_template(name="Default", output_type='exe', debugger=None, build 'name': name, # project name 'output_type': output_type, # output type, default - exe 'target': '', # target + 'device': '', # device name' + 'pack' : '', #pack name 'tools_supported': [], # Tools which are supported, } project_template.update(ProjectTemplate._get_common_data_template()) diff --git a/project_generator/templates/csolution.cproject.yml.tmpl b/project_generator/templates/csolution.cproject.yml.tmpl new file mode 100644 index 00000000..084dd5c5 --- /dev/null +++ b/project_generator/templates/csolution.cproject.yml.tmpl @@ -0,0 +1,33 @@ +project: + setups: + - setup: Options for {{name}} + add-path: + {% for path in include_paths %}- {{path}} + {% endfor %} + debug: 'on' + define: + {% for symbol in macros %}- {{symbol | replace ('"', '\\"') }} + {% endfor %} + misc: + - C: + {% for flag in misc['c_flags'] %}- {{flag}} + {% endfor %} + C-CPP: + {% for flag in misc['cxx_flags'] %}- {{flag}} + {% endfor %} + Link: + {% for flag in misc['ld_flags'] %}- {{flag}} + {% endfor %} + - ASM: + {% for flag in misc['asm_flags'] %}- {{flag}} + {% endfor %} + linker: + - script: {{linker_file}} + groups:{% for group_name,files in groups.items() %} + - group: {{group_name}} + files:{% for file in files %} + - file: {{file.path}}{% endfor %} + {% endfor %} + + components: + - component: ARM::CMSIS:CORE diff --git a/project_generator/templates/csolution.csolution.yml.tmpl b/project_generator/templates/csolution.csolution.yml.tmpl new file mode 100644 index 00000000..b5ce53d0 --- /dev/null +++ b/project_generator/templates/csolution.csolution.yml.tmpl @@ -0,0 +1,19 @@ +# This project was exported via the project generator. +# More information https://github.com/project-generator/project_generator +solution: + created-for: CMSIS-Toolbox@2.2.0 + packs: + - pack: ARM::CMSIS + - pack: {{pack}} + compiler: AC6 + target-types: + - type: Debug + device: {{device}} + debug: on + optimize: none + - type: Release + device: {{device}} + debug: off + optimize: size + projects: + - project: {{name}}.cproject.yml diff --git a/project_generator/tools/csolution.py b/project_generator/tools/csolution.py new file mode 100644 index 00000000..f2b683fd --- /dev/null +++ b/project_generator/tools/csolution.py @@ -0,0 +1,72 @@ +# Copyright 2015 0xc0170 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + +import os +import copy +import logging +import subprocess + +from os.path import basename,join, normpath, dirname, exists +from .tool import Tool, Exporter +from .cmake import CMake +from .gccarm import MakefileGccArm +from ..util import SOURCE_KEYS + +logger = logging.getLogger('progen.tools.csolution') + +class csolution(CMake): + + file_types = {'cpp': 1, 'c': 1, 's': 1, 'obj': 1, 'lib': 1, 'h': 1} + def __init__(self, workspace, env_settings): + super(csolution, self).__init__(workspace, env_settings) + self.logging = logging + self.workspace['preprocess_linker_file'] = True + + @staticmethod + def get_toolnames(): + return ['csolution'] + + @staticmethod + def get_toolchain(): + return 'armclang' + + def _expand_one_file(self, source, new_data, extension): + return {'path': source, 'name': basename(source), 'type': str(self.file_types[extension.lower()])} + + def export_project(self): + """ Processes groups and misc options specific for eclipse, and run generator """ + output = copy.deepcopy(self.generated_project) + data_for_make = self.workspace.copy() + + expanded_dic = self.workspace.copy() + expanded_dic['rel_path'] = data_for_make['output_dir']['rel_path'] + groups = self._get_groups(expanded_dic) + expanded_dic['groups'] = {} + for group in groups: + expanded_dic['groups'][group] = [] + self._iterate(self.workspace, expanded_dic) + + # delete default group + if 'default' in expanded_dic['groups']: + del expanded_dic['groups']['default'] + + # Project file + project_path, output['files']['cproj'] = self.gen_file_jinja( + 'csolution.cproject.yml.tmpl', expanded_dic, expanded_dic['name']+'.cproject.yml', data_for_make['output_dir']['path']) + project_path, output['files']['proj_file'] = self.gen_file_jinja( + 'csolution.csolution.yml.tmpl', expanded_dic, expanded_dic['name']+'.csolution.yml', data_for_make['output_dir']['path']) + return output + + def get_workspace_template(self): + return 'cmakelist_armclang_workspace.tmpl' diff --git a/project_generator/tools_supported.py b/project_generator/tools_supported.py index bfbdbf72..47da0376 100644 --- a/project_generator/tools_supported.py +++ b/project_generator/tools_supported.py @@ -27,6 +27,7 @@ from .tools.cmakearmcc import CMakeArmcc from .tools.cmakearmclang import CMakeArmClang from .tools.visual_studio import VisualStudioMakeGCCARM, VisualStudioGDB +from .tools.csolution import csolution class ToolsSupported: """ Represents all tools available """ @@ -74,6 +75,7 @@ class ToolsSupported: 'cmake_armclang': CMakeArmClang, 'visual_studio_gdb': VisualStudioGDB, 'visual_studio_make_gcc_arm': VisualStudioMakeGCCARM, + 'csolution': csolution, } TOOLCHAINS = list(set([v.get_toolchain() for k, v in TOOLS_DICT.items() if v.get_toolchain() is not None]))