diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..d082185 --- /dev/null +++ b/.clangd @@ -0,0 +1,3 @@ +CompileFlags: + Add: [ --include=.sdcc.h, -Wno-tentative-definition-array, -Wno-main-return-type ] + Remove: [ -m*, --peep-file ] \ No newline at end of file diff --git a/.sdcc.h b/.sdcc.h new file mode 100644 index 0000000..9ef5764 --- /dev/null +++ b/.sdcc.h @@ -0,0 +1,9 @@ +#define __z88dk_fastcall +#define __at(...) +#define __preserves_regs(...) +#define __naked +#define __z88dk_callee +#define __critical +#define __interrupt(...) +#define __sdcccall(...) +typedef unsigned char __sfr; \ No newline at end of file diff --git a/IDE.md b/IDE.md new file mode 100644 index 0000000..791f14c --- /dev/null +++ b/IDE.md @@ -0,0 +1,38 @@ +devkitSMS IDE support +===================== + +### How to set up your devkitSMS project for official VSCode with C/C++ extension: + +* copy into your project folder + * the folder `ide/.vscode/` + * the file `.sdcc.h` +* edit `.vscode/c_cpp_properties.json` + * correct `compilerPath` as needed + * set an environment variable `DEVKITSMS_BASE=`, or just replace all `${env:DEVKITSMS_BASE}` + +Forks of VSCode cannot access the C/C++ extension. Instead try installing the clangd extension and following the instructions below. + +### How to generate a compilation database for your devkitSMS project: + +Example using bear + +* copy the file `ide/.bearconfig` into your project folder +* in your new `.bearconfig` correct the compilers path as needed +* add `compile_commands.json` to your project `.gitignore` or equivalent +* generate the compilation database: +```sh + make clean + bear -c .bearconfig -- make +``` +* regenerate whenever you add a new source file to your project + +[Other generation options](https://sarcasm.github.io/notes/dev/compilation-database.html#how-to-generate-a-json-compilation-database) + +### How to set up your devkitSMS project for clangd: + +* copy files into your project folder: + * `.clangd` + * `.sdcc.h` +* have clangd run with arguments: `--query-driver=/usr/bin/sdcc --compile-commands-dir=$YOUR_PROJECT_DIR"` + * correct `/usr/bin/sdcc` to your compiler path as needed + * For example in VSCode with clangd extension, copy the folder `ide/.vscode/` into your project folder, or copy the `clangd.arguments` setting from `ide/.vscode/settings.json` into your project's existing `.vscode/settings.json` diff --git a/ide/.bearconfig b/ide/.bearconfig new file mode 100644 index 0000000..5c86ad3 --- /dev/null +++ b/ide/.bearconfig @@ -0,0 +1,3 @@ +schema: "4.1" +compilers: + - path: /usr/bin/sdcc \ No newline at end of file diff --git a/ide/.vscode/c_cpp_properties.json b/ide/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..01e26ee --- /dev/null +++ b/ide/.vscode/c_cpp_properties.json @@ -0,0 +1,23 @@ +{ + "configurations": [ + { + "name": "SMS", + "includePath": [ + "${workspaceFolder}/**", + "${env:DEVKITSMS_BASE}/SMSlib/src", + "${env:DEVKITSMS_BASE}/PSGlib/src", + "${env:DEVKITSMS_BASE}/SGlib/src", + "${env:DEVKITSMS_BASE}/MBMlib/src" + ], + "defines": [], + "cStandard": "c99", + "cppStandard": "c++17", + "intelliSenseMode": "${default}", + "compilerPath": "/usr/bin/sdcc", + "forcedInclude": [ + ".sdcc.h" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/ide/.vscode/settings.json b/ide/.vscode/settings.json new file mode 100644 index 0000000..f21879c --- /dev/null +++ b/ide/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "clangd.arguments": [ + "--query-driver=/usr/bin/sdcc", + "--compile-commands-dir=${workspaceFolder}" + ] +}