TI MSP CGT added

This commit is contained in:
Ilia Motornyi
2021-10-12 18:37:48 +03:00
parent f3e0a58d96
commit 45f06715d2
13 changed files with 368 additions and 0 deletions

View File

@@ -0,0 +1 @@
/cmake-build*/

6
CMake-Texas-Instruments-MSP430-CGT/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,6 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
/deployment.xml

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="com.jetbrains.cidr.lang.workspace.compiler.custom.CustomCompilerService">
<option name="definitionsFile" value="$PROJECT_DIR$/custom-compiler-msp430.yaml" />
<option name="enabled" value="true" />
</component>
</project>

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
<component name="MarkdownNavigator.ProfileManager" plain-text-search-scope="Project Files" />
<component name="MarkdownProjectSettings" wasCopied="true">
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true" replaceUnicodeEmoji="false" lastLayoutSetsDefault="false">
<PanelProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
</PanelProvider>
</PreviewSettings>
<ParserSettings gitHubSyntaxChange="false" emojiShortcuts="1" emojiImages="0">
<PegdownExtensions>
<option name="ABBREVIATIONS" value="false" />
<option name="ANCHORLINKS" value="true" />
<option name="ASIDE" value="false" />
<option name="ATXHEADERSPACE" value="true" />
<option name="AUTOLINKS" value="false" />
<option name="DEFINITIONS" value="false" />
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
<option name="FENCED_CODE_BLOCKS" value="true" />
<option name="FOOTNOTES" value="false" />
<option name="HARDWRAPS" value="false" />
<option name="HTML_DEEP_PARSER" value="false" />
<option name="INSERTED" value="false" />
<option name="QUOTES" value="false" />
<option name="RELAXEDHRULES" value="true" />
<option name="SMARTS" value="false" />
<option name="STRIKETHROUGH" value="true" />
<option name="SUBSCRIPT" value="false" />
<option name="SUPERSCRIPT" value="false" />
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
<option name="SUPPRESS_INLINE_HTML" value="false" />
<option name="TABLES" value="true" />
<option name="TASKLISTITEMS" value="true" />
<option name="TOC" value="false" />
<option name="WIKILINKS" value="false" />
</PegdownExtensions>
<ParserOptions>
<option name="ADMONITION_EXT" value="false" />
<option name="ATTRIBUTES_EXT" value="false" />
<option name="COMMONMARK_LISTS" value="true" />
<option name="DUMMY" value="false" />
<option name="EMOJI_SHORTCUTS" value="true" />
<option name="ENUMERATED_REFERENCES_EXT" value="false" />
<option name="FLEXMARK_FRONT_MATTER" value="false" />
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
<option name="GFM_TABLE_RENDERING" value="true" />
<option name="GITBOOK_URL_ENCODING" value="false" />
<option name="GITHUB_LISTS" value="false" />
<option name="GITHUB_WIKI_LINKS" value="false" />
<option name="GITLAB_EXT" value="false" />
<option name="GITLAB_MATH_EXT" value="false" />
<option name="GITLAB_MERMAID_EXT" value="false" />
<option name="HEADER_ID_NON_ASCII_TO_LOWERCASE" value="false" />
<option name="HEADER_ID_NO_DUPED_DASHES" value="false" />
<option name="JEKYLL_FRONT_MATTER" value="false" />
<option name="MACROS_EXT" value="false" />
<option name="NO_TEXT_ATTRIBUTES" value="false" />
<option name="PARSE_HTML_ANCHOR_ID" value="false" />
<option name="PLANTUML_FENCED_CODE" value="false" />
<option name="PUML_FENCED_CODE" value="false" />
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
</ParserOptions>
</ParserSettings>
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false" imageUriSerials="false" addDocTypeHtml="true" noParaTags="false" plantUmlConversion="0" mathConversion="0">
<GeneratorProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
</GeneratorProvider>
<headerTop />
<headerBottom />
<bodyTop />
<bodyBottom />
</HtmlSettings>
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="true" isCssTextEnabled="false" isDynamicPageWidth="true">
<StylesheetProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
</StylesheetProvider>
<ScriptProviders />
<cssText />
<cssUriHistory />
</CssSettings>
<AnnotatorSettings targetHasSpaces="true" linkCaseMismatch="true" wikiCaseMismatch="true" wikiLinkHasDashes="true" notUnderWikiHome="true" targetNotWikiPageExt="true" notUnderSourceWikiHome="true" targetNameHasAnchor="true" targetPathHasAnchor="true" wikiLinkHasSlash="true" wikiLinkHasSubdir="true" wikiLinkHasOnlyAnchor="true" linkTargetsWikiHasExt="true" linkTargetsWikiHasBadExt="true" notUnderSameRepo="true" targetNotUnderVcs="false" linkNeedsExt="true" linkHasBadExt="true" linkTargetNeedsExt="true" linkTargetHasBadExt="true" wikiLinkNotInWiki="true" imageTargetNotInRaw="true" repoRelativeAcrossVcsRoots="true" multipleWikiTargetsMatch="true" unresolvedLinkReference="true" linkIsIgnored="true" anchorIsIgnored="true" anchorIsUnresolved="true" anchorLineReferenceIsUnresolved="true" anchorLineReferenceFormat="true" anchorHasDuplicates="true" abbreviationDuplicates="true" abbreviationNotUsed="true" attributeIdDuplicateDefinition="true" attributeIdNotUsed="true" footnoteDuplicateDefinition="true" footnoteUnresolved="true" footnoteDuplicates="true" footnoteNotUsed="true" macroDuplicateDefinition="true" macroUnresolved="true" macroDuplicates="true" macroNotUsed="true" referenceDuplicateDefinition="true" referenceUnresolved="true" referenceDuplicates="true" referenceNotUsed="true" referenceUnresolvedNumericId="true" enumRefDuplicateDefinition="true" enumRefUnresolved="true" enumRefDuplicates="true" enumRefNotUsed="true" enumRefLinkUnresolved="true" enumRefLinkDuplicates="true" simTocUpdateNeeded="true" simTocTitleSpaceNeeded="true" />
<HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="css" scriptDir="js" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetPathType="2" targetExt="" useTargetExt="false" noCssNoScripts="false" useElementStyleAttribute="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
<LinkMapSettings>
<textMaps />
</LinkMapSettings>
</component>
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/CMake-Texas-Instruments-MSP430-CGT.iml" filepath="$PROJECT_DIR$/.idea/CMake-Texas-Instruments-MSP430-CGT.iml" />
</modules>
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.21)
set(CMAKE_SYSTEM_NAME Generic)
# Trick CMake that the compiler always works
set(CMAKE_C_COMPILER_WORKS 1)
set(CMAKE_CXX_COMPILER_WORKS 1)
# End of trick
project(CMake-Texas-Instruments-MSP430-CGT C CXX)
# CMake 3.21 does not support TI compilers well, we need to make a couple of workarounds
# Explicitly set include and library directories
find_program(TOOLCHAIN_PATH ${CMAKE_C_COMPILER})
get_filename_component(TOOLCHAIN_PATH ${TOOLCHAIN_PATH} DIRECTORY)
get_filename_component(TOOLCHAIN_PATH ${TOOLCHAIN_PATH} DIRECTORY)
include_directories(${TOOLCHAIN_PATH}/include)
include_directories(${TOOLCHAIN_PATH}/include/libcxx)
add_link_options(--library=${TOOLCHAIN_PATH}/lib/lnkx.cmd --search_path=${TOOLCHAIN_PATH}/lib)
# End of the workaround
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_STANDARD 99)
set_source_files_properties(PROPERTIES LANGUAGE CXX)
add_executable(custom-compiler-test main.cpp cmain.c )

View File

@@ -0,0 +1,23 @@
{
"version": 2,
"configurePresets": [
{
"name": "cl430",
"generator": "Ninja",
"binaryDir": "cmake-build-cl430",
"vendor": {
"jetbrains.com/clion": {
"toolchain": "MSP430"
}
}
}
],
"buildPresets": [
{
"name": "cl430",
"displayName": "Texas Instruments CGT MSP430 V21",
"description": "Automatic preset for TI MSP430 compiler",
"configurePreset": "cl430"
}
]
}

View File

@@ -0,0 +1,10 @@
Test project for Custom Compiler Feature
===
This project is an example how to use [TI MSP430 CGT compiler](https://www.ti.com/tool/MSP-CGT)
with [CMake](https://cmake.org/) and [CLion](https://www.jetbrains.com/clion/)
using [Custom Defined Compiler](https://youtrack.jetbrains.com/issue/CPP-9615)
There is a custom compiler definition file for the compiler: [custom-compiler-msp430.yaml](custom-compiler-msp430.yaml)
**NB**: The compiler is supposed to be installed to `c:\tools\bcc102` folder

View File

@@ -0,0 +1,16 @@
#include <stdio.h>
#pragma message ("Compile C")
int getInt();
long long fn() {
return 3ll;
}
void fan(unsigned int x) {
const int res = x == 123;
if (x == 456) {}
}
void c_main() {
puts("Hello, World from C!");
}

View File

@@ -0,0 +1,166 @@
compilers:
- description: C11 TI CGT MSP430 v21
match-sources: ".*\\.c"
match-language: C
match-compiler-exe: "(.*/)?my_compiler(\\.exe)?"
code-insight-target-name: msp430
include-dirs: ${compiler-exe-dir}/../include
defines:
_DATA_ACCESS:
defines-text: "
#define __unsigned_chars__ 1
#define __PRAGMA_REDEFINE_EXTNAME 1
#define __DATE__ \"Oct 1 2021\"
#define __TIME__ \"12:35:40\"
#define __STDC__ 1
#define __STDC_VERSION__ 201112L
#define __STDC_UTF_16__ 1
#define __STDC_UTF_32__ 1
#define __STDC_HOSTED__ 1
#define __TI_C99_COMPLEX_ENABLED__ 1
#define __STDC_NO_THREADS__ 1
#define __edg_front_end__ 1
#define __EDG_VERSION__ 413
#define __EDG_SIZE_TYPE__ unsigned int
#define __EDG_PTRDIFF_TYPE__ int
#define __VERSION__ \"EDG gcc 4.8 mode\"
#define __CHAR16_TYPE__ unsigned short
#define __CHAR32_TYPE__ unsigned long
#define __TI_COMPILER_VERSION__ 21006000
#define __COMPILER_VERSION__ 21006000
#define __TI_COMPILER_VERSION_QUAL_ID__ 21147
#define __TI_COMPILER_VERSION_QUAL__ QUAL_LETTER
#define __MSP430__ 1
#define __SIZE_T_TYPE__ unsigned
#define __PTRDIFF_T_TYPE__ int
#define __WCHAR_T_TYPE__ unsigned int
#define __TI_EABI__ 1
#define __ELF__ 1
#define __little_endian__ 1
#define __LITTLE_ENDIAN__ 1
#define __TI_STRICT_ANSI_MODE__ 0
#define __TI_WCHAR_T_BITS__ 16
#define __TI_GNU_ATTRIBUTE_SUPPORT__ 1
#define __TI_STRICT_FP_MODE__ 1
#define __CHAR_BIT__ 8
#define __SCHAR_MAX__ 127
#define __SHRT_MAX__ 32767
#define __INT_MAX__ 32767
#define __LONG_MAX__ 2147483647
#define __LONG_LONG_MAX__ 9223372036854775807
#define __SIZEOF_INT__ 2
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_WCHAR_T__ 2
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_LONG_DOUBLE__ 8
#define __SIZEOF_SIZE_T__ 2
#define __SIZEOF_WINT_T__ 2
#define __SIZEOF_PTRDIFF_T__ 2
#define _OPTIMIZE_FOR_SPACE 1
#define _INLINE 1
"
- description: Cpp14 TI CGT MSP430 v21
match-sources: ".*\\.cpp"
match-language: CPP
match-compiler-exe: "(.*/)?my_compiler(\\.exe)?"
code-insight-target-name: msp430
include-dirs: ["${compiler-exe-dir}/../include/libcxx","${compiler-exe-dir}/../include"]
defines:
_DATA_ACCESS: #TI specific keyword
defines-text: "
#define __unsigned_chars__ 1
#define __PRAGMA_REDEFINE_EXTNAME 1
#define __DATE__ \"Oct 1 2021\"
#define __TIME__ \"12:37:15\"
#define __STDC__ 1
#define __STDC_HOSTED__ 1
#define __cplusplus 201402L
#define _WCHAR_T 1
#define __CHAR16_T_AND_CHAR32_T 1
#define _BOOL 1
#define __ARRAY_OPERATORS 1
#define __PLACEMENT_DELETE 1
#define __EDG_RUNTIME_USES_NAMESPACES 1
#define __EDG_IA64_ABI 1
#define __EDG_IA64_ABI_VARIANT_CTORS_AND_DTORS_RETURN_THIS 1
#define __EDG_IA64_ABI_USE_VARIANT_INT_STATIC_INIT_GUARD 1
#define __cpp_initializer_lists 200806
#define __cpp_sized_deallocation 201309
#define __cpp_unicode_characters 200704
#define __cpp_aggregate_nsdmi 201304
#define __cpp_alias_templates 200704
#define __cpp_attributes 200809
#define __cpp_binary_literals 201304
#define __cpp_decltype 200707
#define __cpp_decltype_auto 201304
#define __cpp_delegating_constructors 200604
#define __cpp_generic_lambdas 201304
#define __cpp_inheriting_constructors 200802
#define __cpp_init_captures 201304
#define __cpp_lambdas 200907
#define __cpp_nsdmi 200809
#define __cpp_raw_strings 200710
#define __cpp_ref_qualifiers 200710
#define __cpp_return_type_deduction 201304
#define __cpp_rvalue_references 200610
#define __cpp_unicode_literals 200710
#define __cpp_user_defined_literals 200809
#define __cpp_variable_templates 201304
#define __cpp_variadic_templates 200704
#define __cpp_constexpr 201304
#define __cpp_range_based_for 200907
#define __cpp_static_assert 200410
#define __TI_C99_COMPLEX_ENABLED__ 1
#define __EDG_TYPE_TRAITS_ENABLED 1
#define __VARIADIC_TEMPLATES 1
#define __EDG_CONSTEXPR_ENABLED__ 1
#define __edg_front_end__ 1
#define __EDG_VERSION__ 413
#define __EDG_SIZE_TYPE__ unsigned int
#define __EDG_PTRDIFF_TYPE__ int
#define __GNUC_STDC_INLINE__ 1
#define __VERSION__ \"EDG g++ 4.8 mode\"
#define __CHAR16_TYPE__ unsigned short
#define __CHAR32_TYPE__ unsigned long
#define __TI_COMPILER_VERSION__ 21006000
#define __COMPILER_VERSION__ 21006000
#define __TI_COMPILER_VERSION_QUAL_ID__ 21147
#define __TI_COMPILER_VERSION_QUAL__ QUAL_LETTER
#define __MSP430__ 1
#define __SIZE_T_TYPE__ unsigned
#define __PTRDIFF_T_TYPE__ int
#define __WCHAR_T_TYPE__ unsigned int
#define __TI_EABI__ 1
#define __ELF__ 1
#define __little_endian__ 1
#define __LITTLE_ENDIAN__ 1
#define __TI_STRICT_ANSI_MODE__ 0
#define __TI_WCHAR_T_BITS__ 16
#define __TI_GNU_ATTRIBUTE_SUPPORT__ 1
#define __TI_STRICT_FP_MODE__ 1
#define __CHAR_BIT__ 8
#define __SCHAR_MAX__ 127
#define __SHRT_MAX__ 32767
#define __INT_MAX__ 32767
#define __LONG_MAX__ 2147483647
#define __LONG_LONG_MAX__ 9223372036854775807
#define __SIZEOF_INT__ 2
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_WCHAR_T__ 2
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_LONG_DOUBLE__ 8
#define __SIZEOF_SIZE_T__ 2
#define __SIZEOF_WINT_T__ 2
#define __SIZEOF_PTRDIFF_T__ 2
#define _OPTIMIZE_FOR_SPACE 1
#define _INLINE 1
"

View File

@@ -0,0 +1,10 @@
#include <iostream>
#pragma message ("Compile C++")
extern "C" void c_main(void);
int main() {
std::cout << "Hello, World, from C++!" << std::endl;
c_main();
return 0;
}