mirror of
https://github.com/pret/pokeplatinum.git
synced 2026-04-24 15:07:47 -05:00
Merge pull request #118 from pret/feature/clangd_compatible_compile_commands
GCC-friendly compile_commands.json maker
This commit is contained in:
commit
b6626c5c6b
2
.clangd
Normal file
2
.clangd
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Diagnostics:
|
||||
Suppress: 'pp_including_mainfile_in_preamble'
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -87,3 +87,5 @@ sdk/
|
|||
|
||||
__pycache__
|
||||
.cache
|
||||
|
||||
compile_commands.json
|
||||
|
|
|
|||
25
CONTRIBUTING.md
Normal file
25
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# Contributing to pret/pokeplatinum
|
||||
|
||||
This document provides a synopsis and loose guidelines for how to contribute to this project. It is a work in progress. Maintainers should expand this document.
|
||||
|
||||
## Contents
|
||||
- [Editor enhancements](#editor-enhancements)
|
||||
|
||||
<a href="editor-enhancements"></a>
|
||||
## Editor enhancements
|
||||
|
||||
This repository includes a script to generate a `compile_commands.json` that is compatible with C language servers such as `clangd`.
|
||||
|
||||
### Requirements
|
||||
|
||||
- python3.8 or newer
|
||||
- gcc-arm-none-eabi
|
||||
- clangd
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
./gen_compile_commands.py
|
||||
```
|
||||
|
||||
This will create a file named `compile_commands.json` in the project root, overwriting the previous copy.
|
||||
228
gen_compile_commands.py
Normal file
228
gen_compile_commands.py
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
import json
|
||||
import pathlib
|
||||
|
||||
homedir = pathlib.Path(__file__).parent
|
||||
builddir = homedir / 'build'
|
||||
|
||||
arm7_c_flags = [
|
||||
'arm-none-eabi-gcc',
|
||||
'-c',
|
||||
'-O3',
|
||||
'-std=c99',
|
||||
'-mcpu=arm7tdmi',
|
||||
'-mfloat-abi=soft',
|
||||
'-nostdinc',
|
||||
'-D_NITRO',
|
||||
'-DSDK_4M',
|
||||
'-DSDK_ARM7',
|
||||
'-DSDK_CODE_ARM',
|
||||
'-DSDK_CW',
|
||||
'-DSDK_CW_FORCE_EXPORT_SUPPORT',
|
||||
'-DSDK_FINALROM',
|
||||
'-DSDK_TS',
|
||||
]
|
||||
|
||||
arm9_c_flags = [
|
||||
'arm-none-eabi-gcc',
|
||||
'-c',
|
||||
'-O3',
|
||||
'-std=c99',
|
||||
'-mcpu=arm946e-s',
|
||||
'-mfloat-abi=soft',
|
||||
'-nostdinc',
|
||||
'-D_NITRO',
|
||||
'-DLINK_PPWLOBBY',
|
||||
'-DNNS_FINALROM',
|
||||
'-DSDK_4M',
|
||||
'-DSDK_ARM9',
|
||||
'-DSDK_CODE_ARM',
|
||||
'-DSDK_CW',
|
||||
'-DSDK_CW_FORCE_EXPORT_SUPPORT',
|
||||
'-DSDK_FINALROM',
|
||||
'-DSDK_TS',
|
||||
]
|
||||
|
||||
asm_commands = [
|
||||
{
|
||||
'directory': builddir,
|
||||
'arguments': [
|
||||
'arm-none-eabi-as',
|
||||
'-mcpu=arm946e-s',
|
||||
'-o',
|
||||
file.with_suffix('.o'),
|
||||
file.resolve()
|
||||
],
|
||||
'file': file.resolve()
|
||||
} for file in (homedir / 'asm').rglob('*.s')
|
||||
]
|
||||
|
||||
nitrosdk_c_commands = [
|
||||
{
|
||||
'directory': builddir,
|
||||
'arguments': arm9_c_flags + [
|
||||
f'-I{homedir}/tools/cw/include/MSL_C',
|
||||
f'-I{homedir}/tools/cw/include/MSL_Extras',
|
||||
f'-I{homedir}/subprojects/NitroSDK-4.2.30001/include',
|
||||
f'-I{builddir}/subprojects/NitroSDK-4.2.30001/gen',
|
||||
'-o',
|
||||
file.with_suffix('.o'),
|
||||
file.resolve()
|
||||
],
|
||||
'file': file.resolve()
|
||||
} for file in (homedir / 'subprojects/NitroSDK-4.2.30001').rglob('*.c')
|
||||
]
|
||||
|
||||
nitrosystem_c_commands = [
|
||||
{
|
||||
'directory': builddir,
|
||||
'arguments': arm9_c_flags + [
|
||||
f'-I{homedir}/tools/cw/include/MSL_C',
|
||||
f'-I{homedir}/tools/cw/include/MSL_Extras',
|
||||
f'-I{homedir}/subprojects/NitroSDK-4.2.30001/include',
|
||||
f'-I{builddir}/subprojects/NitroSDK-4.2.30001/gen',
|
||||
f'-I{homedir}/subprojects/NitroSystem-071126.1/include',
|
||||
'-o',
|
||||
file.with_suffix('.o'),
|
||||
file.resolve()
|
||||
],
|
||||
'file': file.resolve()
|
||||
} for file in (homedir / 'subprojects/NitroSystem-071126.1').rglob('*.c')
|
||||
]
|
||||
|
||||
nitrowifi_c_commands = [
|
||||
{
|
||||
'directory': builddir,
|
||||
'arguments': arm9_c_flags + [
|
||||
f'-I{homedir}/tools/cw/include/MSL_C',
|
||||
f'-I{homedir}/tools/cw/include/MSL_Extras',
|
||||
f'-I{homedir}/subprojects/NitroSDK-4.2.30001/include',
|
||||
f'-I{builddir}/subprojects/NitroSDK-4.2.30001/gen',
|
||||
f'-I{homedir}/subprojects/NitroSystem-071126.1/include',
|
||||
f'-I{homedir}/subprojects/NitroWiFi-2.1.30003/include',
|
||||
'-o',
|
||||
file.with_suffix('.o'),
|
||||
file.resolve()
|
||||
],
|
||||
'file': file.resolve()
|
||||
} for file in (homedir / 'subprojects/NitroWiFi-2.1.30003').rglob('*.c')
|
||||
]
|
||||
|
||||
nitrodwc_c_commands = [
|
||||
{
|
||||
'directory': builddir,
|
||||
'arguments': arm9_c_flags + [
|
||||
f'-I{homedir}/tools/cw/include/MSL_C',
|
||||
f'-I{homedir}/tools/cw/include/MSL_Extras',
|
||||
f'-I{homedir}/subprojects/NitroSDK-4.2.30001/include',
|
||||
f'-I{builddir}/subprojects/NitroSDK-4.2.30001/gen',
|
||||
f'-I{homedir}/subprojects/NitroSystem-071126.1/include',
|
||||
f'-I{homedir}/subprojects/NitroWiFi-2.1.30003/include',
|
||||
f'-I{homedir}/subprojects/NitroDWC-2.2.30008/include',
|
||||
'-o',
|
||||
file.with_suffix('.o'),
|
||||
file.resolve()
|
||||
],
|
||||
'file': file.resolve()
|
||||
} for file in (homedir / 'subprojects/NitroDWC-2.2.30008').rglob('*.c')
|
||||
]
|
||||
|
||||
libvct_c_commands = [
|
||||
{
|
||||
'directory': builddir,
|
||||
'arguments': arm9_c_flags + [
|
||||
f'-I{homedir}/tools/cw/include/MSL_C',
|
||||
f'-I{homedir}/tools/cw/include/MSL_Extras',
|
||||
f'-I{homedir}/subprojects/NitroSDK-4.2.30001/include',
|
||||
f'-I{builddir}/subprojects/NitroSDK-4.2.30001/gen',
|
||||
f'-I{homedir}/subprojects/NitroSystem-071126.1/include',
|
||||
f'-I{homedir}/subprojects/NitroWiFi-2.1.30003/include',
|
||||
f'-I{homedir}/subprojects/NitroDWC-2.2.30008/include',
|
||||
f'-I{homedir}/subprojects/libvct-1.3.1/include',
|
||||
'-o',
|
||||
file.with_suffix('.o'),
|
||||
file.resolve()
|
||||
],
|
||||
'file': file.resolve()
|
||||
} for file in (homedir / 'subprojects/libvct-1.3.1').rglob('*.c')
|
||||
]
|
||||
|
||||
libcrypto_c_commands = [
|
||||
{
|
||||
'directory': builddir,
|
||||
'arguments': arm9_c_flags + [
|
||||
f'-I{homedir}/tools/cw/include/MSL_C',
|
||||
f'-I{homedir}/tools/cw/include/MSL_Extras',
|
||||
f'-I{homedir}/subprojects/NitroSDK-4.2.30001/include',
|
||||
f'-I{builddir}/subprojects/NitroSDK-4.2.30001/gen',
|
||||
f'-I{homedir}/subprojects/NitroSystem-071126.1/include',
|
||||
f'-I{homedir}/subprojects/NitroWiFi-2.1.30003/include',
|
||||
f'-I{homedir}/subprojects/NitroDWC-2.2.30008/include',
|
||||
f'-I{homedir}/subprojects/libvct-1.3.1/include',
|
||||
f'-I{homedir}/subprojects/libcrypto/include',
|
||||
'-o',
|
||||
file.with_suffix('.o'),
|
||||
file.resolve()
|
||||
],
|
||||
'file': file.resolve()
|
||||
} for file in (homedir / 'subprojects/libcrypto').rglob('*.c')
|
||||
]
|
||||
|
||||
ppwlobby_c_commands = [
|
||||
{
|
||||
'directory': builddir,
|
||||
'arguments': arm9_c_flags + [
|
||||
f'-I{homedir}/tools/cw/include/MSL_C',
|
||||
f'-I{homedir}/tools/cw/include/MSL_Extras',
|
||||
f'-I{homedir}/subprojects/NitroSDK-4.2.30001/include',
|
||||
f'-I{builddir}/subprojects/NitroSDK-4.2.30001/gen',
|
||||
f'-I{homedir}/subprojects/NitroSystem-071126.1/include',
|
||||
f'-I{homedir}/subprojects/NitroWiFi-2.1.30003/include',
|
||||
f'-I{homedir}/subprojects/NitroDWC-2.2.30008/include',
|
||||
f'-I{homedir}/subprojects/libvct-1.3.1/include',
|
||||
f'-I{homedir}/subprojects/libcrypto/include',
|
||||
f'-I{homedir}/subprojects/ppwlobby/include',
|
||||
'-o',
|
||||
file.with_suffix('.o'),
|
||||
file.resolve()
|
||||
],
|
||||
'file': file.resolve()
|
||||
} for file in (homedir / 'subprojects/ppwlobby').rglob('*.c')
|
||||
]
|
||||
|
||||
c_commands = [
|
||||
{
|
||||
'directory': builddir,
|
||||
'arguments': arm9_c_flags + [
|
||||
f'-I{homedir}/tools/cw/include/MSL_C',
|
||||
f'-I{homedir}/tools/cw/include/MSL_Extras',
|
||||
f'-I{homedir}/subprojects/NitroSDK-4.2.30001/include',
|
||||
f'-I{builddir}/subprojects/NitroSDK-4.2.30001/gen',
|
||||
f'-I{homedir}/subprojects/NitroSystem-071126.1/include',
|
||||
f'-I{homedir}/subprojects/NitroWiFi-2.1.30003/include',
|
||||
f'-I{homedir}/subprojects/NitroDWC-2.2.30008/include',
|
||||
f'-I{homedir}/subprojects/libvct-1.3.1/include',
|
||||
f'-I{homedir}/subprojects/libcrypto/include',
|
||||
f'-I{homedir}/subprojects/ppwlobby/include',
|
||||
f'-I{homedir}/lib/gds/include',
|
||||
f'-I{homedir}/lib/spl/include',
|
||||
f'-iquote{homedir}',
|
||||
f'-iquote{homedir}/include',
|
||||
f'-include{homedir}/include/pch/global_pch.h',
|
||||
'-mthumb',
|
||||
'-o',
|
||||
file.with_suffix('.o'),
|
||||
file.resolve()
|
||||
],
|
||||
'file': file.resolve()
|
||||
} for file in (homedir / 'src').rglob('*.c')
|
||||
]
|
||||
|
||||
with open('compile_commands.json', 'w') as ofp:
|
||||
json.dump(
|
||||
asm_commands + nitrosdk_c_commands + nitrosystem_c_commands
|
||||
+ nitrowifi_c_commands + nitrodwc_c_commands + libvct_c_commands
|
||||
+ libcrypto_c_commands + ppwlobby_c_commands + c_commands,
|
||||
ofp,
|
||||
default=str,
|
||||
indent=4
|
||||
)
|
||||
|
|
@ -27,6 +27,16 @@ typedef _MSL_WCHAR_T_TYPE wchar_t;
|
|||
}
|
||||
#endif
|
||||
#endif
|
||||
#elif __GNUC__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef _MSL_WCHAR_T_TYPE wchar_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user