Skip to content

Instantly share code, notes, and snippets.

@funlw65
Created April 12, 2018 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funlw65/c851b5d37c79a5efe0b41b994f57304e to your computer and use it in GitHub Desktop.
Save funlw65/c851b5d37c79a5efe0b41b994f57304e to your computer and use it in GitHub Desktop.
Snippet for a pascal program that generates json files for Visual Studio Code
{lets look a little at the toolchain folder structure - we need something
from there.}
chdir(getenvironmentvariable('HOME'));
chdir(v_toolchain_folder+'/lib/gcc/arm-none-eabi');
{good, now lets see the name of the subfolder in here which is composed of
numbers and dots, in this format "x.x.x"}
if(FindFirst('*',faDirectory, _fsearch) <> 0) then begin
writeln('Error! We are not in the folder we should be...');
halt(1);
end;
sf := _fsearch.Name;
writeln('Ok, the gcc-arm subfolder is: '+sf);
{Now that we have done gazing into gcc-arm subfolders, lets go back to our
project folder ...}
chdir(getenvironmentvariable('HOME'));
chdir(v_workspace+'/'+v_prj_name);
{... and lets use the "sf" in the constructed gcc-arm path:}
{create c_cpp_properties.json file in .vscode folder}
assign(F, getenvironmentvariable('HOME')+'/'+v_workspace+'/'+v_prj_name+'/.vscode/'+v_vsc_c_prop_file);
rewrite(F);
writeln(F, '{');
writeln(F, ' "configurations": [');
writeln(F, ' {');
writeln(F, ' "name": "Linux",');
writeln(F, ' "intelliSenseMode": "clang-x64",');
writeln(F, ' "defines":[');
writeln(F, ' "STM32L152xE",');
writeln(F, ' "USE_FULL_LL_DRIVER"');
writeln(F, ' ],');
writeln(F, ' "includePath": [');
writeln(F, ' "${workspaceRoot}/Inc",');
writeln(F, ' "${workspaceRoot}/Drivers/CMSIS/Include",');
writeln(F, ' "${workspaceRoot}/Drivers/CMSIS/Device/ST/STM32L1xx/Include",');
writeln(F, ' "${workspaceRoot}/Drivers/STM32L1xx_HAL_Driver/Inc",');
writeln(F, ' "${env:HOME}/'+v_toolchain_folder+'/arm-none-eabi/include",');
writeln(F, ' "${env:HOME}/'+v_toolchain_folder+'/lib/gcc/arm-none-eabi/'+sf+'/include",');
writeln(F, ' "${env:HOME}/'+v_toolchain_folder+'/lib/gcc/arm-none-eabi/'+sf+'/include-fixed",');
writeln(F, ' "${env:HOME}/'+v_workspace+'/'+v_user_lib_folder+'"');
writeln(F, ' ],');
writeln(F, ' "browse": {');
writeln(F, ' "path": [');
writeln(F, ' "${workspaceRoot}/Inc",');
writeln(F, ' "${workspaceRoot}/Drivers/CMSIS/Include",');
writeln(F, ' "${workspaceRoot}/Drivers/CMSIS/Device/ST/STM32L1xx/Include",');
writeln(F, ' "${workspaceRoot}/Drivers/STM32L1xx_HAL_Driver/Inc",');
writeln(F, ' "${env:HOME}/'+v_toolchain_folder+'/arm-none-eabi/include",');
writeln(F, ' "${env:HOME}/'+v_toolchain_folder+'/lib/gcc/arm-none-eabi/'+sf+'/include",');
writeln(F, ' "${env:HOME}/'+v_toolchain_folder+'/lib/gcc/arm-none-eabi/'+sf+'/include-fixed",');
writeln(F, ' "${env:HOME}/'+v_workspace+'/'+v_user_lib_folder+'"');
writeln(F, ' ],');
writeln(F, ' "limitSymbolsToIncludedHeaders": false,');
writeln(F, ' "databaseFilename": ""');
writeln(F, ' }');
writeln(F, ' }');
writeln(F, ' ],');
writeln(F, ' "version": 3');
writeln(F, '}');
writeln(F, ' ');
close(F);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment