SDCC/STM8 added

This commit is contained in:
Ilia Motornyi
2021-10-13 17:35:22 +03:00
parent d208afc1a9
commit dbe42378d9
14 changed files with 247 additions and 3 deletions

1
CMake-SDCC/.gitignore vendored Normal file
View File

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

6
CMake-SDCC/.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

2
CMake-SDCC/.idea/CMake-SDCC.iml generated Normal file
View File

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

7
CMake-SDCC/.idea/custom-compiler.xml generated Normal file
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-sdcc-stm8.yaml" />
<option name="enabled" value="true" />
</component>
</project>

26
CMake-SDCC/.idea/jsonSchemas.xml generated Normal file
View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JsonSchemaMappingsProjectConfiguration">
<state>
<map>
<entry key="Custom Compiler Definition">
<value>
<SchemaInfo>
<option name="name" value="Custom Compiler Definition" />
<option name="relativePathToSchema" value="$APPLICATION_HOME_DIR$/plugins/cidr-compiler-custom/lib/cidr-compiler-custom.jar!/schemas/clion-custom-compilers-definition.json" />
<option name="schemaVersion" value="JSON Schema version 7" />
<option name="applicationDefined" value="true" />
<option name="patterns">
<list>
<Item>
<option name="path" value="custom-compiler-sdcc.yaml" />
</Item>
</list>
</option>
</SchemaInfo>
</value>
</entry>
</map>
</state>
</component>
</project>

88
CMake-SDCC/.idea/misc.xml generated Normal file
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>

8
CMake-SDCC/.idea/modules.xml generated Normal file
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-SDCC.iml" filepath="$PROJECT_DIR$/.idea/CMake-SDCC.iml" />
</modules>
</component>
</project>

6
CMake-SDCC/.idea/vcs.xml generated Normal file
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>

35
CMake-SDCC/CMakeLists.txt Normal file
View File

@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.21)
set(CMAKE_SYSTEM_NAME Generic)
# Trick CMake that the compiler always works
set(CMAKE_C_COMPILER_WORKS 1) #todo
set(CMAKE_CXX_COMPILER_WORKS 1) #todo
# End of trick
#Find the compiler
find_program(SDCC_COMPILER sdcc)
if (${CMAKE_HOST_WIN32})
if (NOT EXISTS "${SDCC_COMPILER}")
list(APPEND CMAKE_PROGRAM_PATH "C:/Program Files(86)/SDCC/bin")
find_program(SDCC_COMPILER sdcc)
endif ()
if (NOT EXISTS "${SDCC_COMPILER}")
list(APPEND CMAKE_PROGRAM_PATH "C:/Program Files/SDCC/bin")
find_program(SDCC_COMPILER sdcc)
endif ()
endif ()
if (EXISTS "${SDCC_COMPILER}")
set(CMAKE_C_COMPILER "${SDCC_COMPILER}")
else ()
message(FATAL_ERROR "SDCC compiler is not found at your computer.")
endif ()
project(CMake-SDCC C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_STANDARD 99)
add_compile_options(-mstm8)
add_link_options(-mstm8)
add_executable(custom-compiler-test cmain.c)

8
CMake-SDCC/README.md Normal file
View File

@@ -0,0 +1,8 @@
Test project for Custom Compiler feature
===
This project is an example how to use [SDCC](http://sdcc.sourceforge.net/) for stm8
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-sdcc-stm8.yaml](custom-compiler-sdcc-stm8.yaml)

22
CMake-SDCC/cmain.c Normal file
View File

@@ -0,0 +1,22 @@
#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) {}
}
int main() {
puts("Hello, World from C!");
return 0;
}
int putchar(int c) {
//fake function
return 1;
}

View File

@@ -0,0 +1,31 @@
compilers:
- description: SDCC 4.1.0 STM8 Medium Memory model
match-args: "-mstm8"
match-compiler-exe: "(.*/)?sdcc(\\.exe)?"
code-insight-target-name: avr
include-dirs: "${compiler-exe-dir}/../include"
defines-text: "
#define __STDC_VERSION__ 201112L
#define __SDCC_INT_LONG_REENT 1
#define __SDCC_MODEL_MEDIUM 1
#define __STDC_HOSTED__ 0
#define __STDC_UTF_16__ 1
#define __SDCC_VERSION_MINOR 1
#define __STDC_ISO_10646__ 201409L
#define __SDCC_VERSION_PATCH 0
#define __SDCC_stm8 1
#define __SDCC_FLOAT_REENT 1
#define __SDCC_VERSION_MAJOR 4
#define __STDC_NO_VLA__ 1
#define __SDCC 4_1_0
#define __STDC_UTF_32__ 1
#define __STDC_NO_THREADS__ 1
#define __SDCC_CHAR_UNSIGNED 1
#define __STDC_NO_ATOMICS__ 1
#define __SDCC_STACK_AUTO 1
#define __STDC__ 1
#define __SDCC_REVISION 12072
#define __STDC_NO_COMPLEX__ 1
"

View File

@@ -6,5 +6,3 @@ 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

@@ -16,4 +16,10 @@ Set of examples how to use [CLion](https://www.jetbrains.com/clion/) with variou
* Compiler definition file: [custom-compiler-msp430.yaml](CMake-Texas-Instruments-MSP430-CGT/custom-compiler-msp430.yaml)
* Host Platforms: Windows, Linux, Mac
* Target Platform: MSP430 MCU
* [CMake-SDCC](CMake-SDCC)
* Build System: [CMake](https://cmake.org/)
* Compiler: [SDCC](http://sdcc.sourceforge.net/) for stm8
* Compiler definition file: [custom-compiler-sdcc-stm8.yaml](CCMake-SDCC/custom-compiler-sdcc-stm8.yaml)
* Host Platforms: Windows, Linux, Mac
* Target Platform: STM8 MCU