49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import platform
|
|
import yaml
|
|
|
|
def write_clangd_file(flags):
|
|
clangd_config = {
|
|
"CompileFlags": {
|
|
"Add": flags
|
|
}
|
|
}
|
|
|
|
with open(".clangd", "w") as f:
|
|
yaml.dump(clangd_config, f, default_flow_style=False)
|
|
|
|
def main():
|
|
arduino_base_path = os.path.expanduser("~/AppData/Local") if platform.system() == "Windows" else os.path.expanduser('~')
|
|
|
|
flags = [
|
|
"-x", "c++",
|
|
"-std=gnu++11",
|
|
"-fpermissive",
|
|
"-fno-exceptions",
|
|
"-ffunction-sections",
|
|
"-fdata-sections",
|
|
"-fno-threadsafe-statics",
|
|
"-Wno-error=narrowing",
|
|
"-flto",
|
|
"-E",
|
|
"-CC",
|
|
"-D__AVR__",
|
|
"-D__AVR_ATmega328P__",
|
|
"-DF_CPU=16000000L",
|
|
"-DARDUINO=10607",
|
|
"-DARDUINO_AVR_UNO",
|
|
"-DARDUINO_ARCH_AVR",
|
|
"-I./include",
|
|
f"-I{arduino_base_path}/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino",
|
|
f"-I{arduino_base_path}/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/standard",
|
|
f"-I{arduino_base_path}/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/avr/include",
|
|
f"-I{arduino_base_path}/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0/include",
|
|
]
|
|
|
|
write_clangd_file(flags)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|