From fb5a321dd7c2848128b04b306f3e1e59c87a3f70 Mon Sep 17 00:00:00 2001 From: Stijn Kuipers Date: Thu, 29 Jun 2023 16:26:07 +0200 Subject: Initial Filedump Tadaaa!! --- sw/ideScripts/templateStrings.py | 204 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100755 sw/ideScripts/templateStrings.py (limited to 'sw/ideScripts/templateStrings.py') diff --git a/sw/ideScripts/templateStrings.py b/sw/ideScripts/templateStrings.py new file mode 100755 index 0000000..623ab1c --- /dev/null +++ b/sw/ideScripts/templateStrings.py @@ -0,0 +1,204 @@ +""" +Template scripts for generating workspace files: + - c_cpp_properties.json + - tasks.json + - makefile strings/functions + - buildData.json +""" +import os + +launchName_Debug = "Cortex debug" +launchName_Python = "Debug current Python file" + +taskName_build = "Build project" +taskName_compile = "Compile current file" +taskName_clean = "Delete build folder" + +taskName_CPU_buildDownloadRun = "CPU: Build, Download and run" +taskName_CPU_downloadRun = "CPU: Download and run" +taskName_CPU_resetRun = "CPU: Reset and run" +taskName_CPU_halt = "CPU: Halt" +taskName_CPU_run = "CPU: Run" + +taskName_Python = "Run Python file" +taskName_OpenCubeMX = "Open CubeMX project" +taskName_updateWorkspace = "Update workspace" + +######################################################################################################### +c_cpp_template = """{ + "env" : { + "____________________USER_FIELDS_CAN_BE_MODIFIED____________________": "", + "user_cSources": [], + "user_asmSources": [], + "user_ldSources": [], + "user_cIncludes": [], + "user_asmIncludes": [], + "user_ldIncludes": [], + "user_cDefines": [], + "user_asmDefines": [], + "user_cFlags": [], + "user_asmFlags": [], + "user_ldFlags": [], + + "____________________DO_NOT_MODIFY_FIELDS_BELOW____________________": "", + "cubemx_sourceFiles": [], + "cubemx_includes": [], + "cubemx_defines": [], + "gccExePath": "", + "gccIncludePath": "" + }, + "configurations": [ + { + "name": "devTestBoard name of the project?", + "intelliSenseMode": "msvc-x64", + "includePath": [ + "${workspaceFolder}", + "${cubemx_includes}", + "${gccIncludePath}", + "${user_cIncludes}", + "${user_asmIncludes}", + "${user_ldIncludes}" + ], + "browse": { + "path": [ + "${workspaceFolder}", + "${cubemx_includes}", + "${gccIncludePath}", + "${user_cIncludes}", + "${user_asmIncludes}", + "${user_ldIncludes}" + ], + "limitSymbolsToIncludedHeaders": true + }, + "defines": [ + "${cubemx_defines}", + "${user_cDefines}", + "${user_asmDefines}" + ], + "forcedInclude": [ + ], + "compilerPath": "${gccExePath}", + "cStandard": "c11", + "cppStandard": "c++17" + } + ], + "version": 4 +} +""" +######################################################################################################### +versionString = "Version ***" +lastRunString = "Last run: ***" + +######################################################################################################### +makefileHeader = ('#' * 100) + "\n" +makefileHeader += "# Makefile generated by updateMakefile.py\n" +makefileHeader += "# " + versionString + " \n" +makefileHeader += "# " + lastRunString + " \n" +makefileHeader += ('#' * 100) + "\n" + +######################################################################################################### +printMakefileVariableFunction = "print-%:" +printMakefileDefaultString = "VARIABLE=" +printMakefileVariable = "#######################################\n" +printMakefileVariable += "# Print makefile variables\n" +printMakefileVariable += "#######################################\n" +printMakefileVariable += printMakefileVariableFunction + "\n" +printMakefileVariable += "\t@echo " + printMakefileDefaultString + "$($*)\n" + +######################################################################################################### +cleanFunctionNameSearchString = "clean:" +cleanBuildDirFunctionName = "clean-build-dir" +cleanBuildDirFunction = "#######################################\n" +cleanBuildDirFunction += "# Clean build directory content \n" +cleanBuildDirFunction += "#######################################\n" +cleanBuildDirFunction += cleanBuildDirFunctionName + ":\n" +cleanBuildDirFunction += "\t@echo Build folder: '$(BUILD_DIR)' clean request (files with spaces and folders will not be removed):\n" +cleanBuildDirFunction += "\t@$(foreach file, $(wildcard $(BUILD_DIR)/*), rm -f $(file))\n" +cleanBuildDirFunction += "\t@echo OK.\n" + +######################################################################################################### +taskTemplate = """{ + "label": "Update workspace", + "type": "shell", + "command": "python", + "args": [ + "${workspaceFolder}\\\\test.py" + ], + "group": "none", + "presentation": { + "reveal": "always", + "panel": "shared" + }, + "problemMatcher": { + } + } +""" + +tasksFileTemplate = """{ + "version": "2.0.0", + "tasks": [""" +tasksFileTemplate += """ + ] +} +""" + +######################################################################################################### +# buildData.json has template with all keys listed, since it is needed for sorting purposes. There +# might be a better way to handle sorting (TODO) +buildDataTemplate = """{ + "ABOUT1": "This file holds combined user and CubeMX generated Makefile workspace dependecies.", + "ABOUT2": "User should not edit this fields, instead it should edit 'c_cpp_properties.json'", + "ABOUT3": "This file is regenerated on 'Update workspace' task.", + "VERSION": "", + "LAST_RUN": "", + "cSources": [], + "asmSources": [], + "ldSources": [], + "cIncludes": [], + "asmIncludes": [], + "ldIncludes": [], + "cDefines": [], + "asmDefines": [], + "cFlags" : [], + "asmFlags" : [], + "ldFlags" : [], + "buildDir": "", + "targetExecutablePath": "", + "cubeMxProjectPath": "", + "openOcdConfig": [], + "stm32SvdPath": "", + "ABOUT4": "---- Paths below are fetched from user-specific 'toolsPaths.json'. ----", + "gccExePath": "", + "gccInludePath": "", + "buildToolsPath": "", + "pythonExec": "", + "openOcdPath": "", + "openOcdInterfacePath": "" +} +""" + +######################################################################################################### +toolsPathsTemplate = """{ + "ABOUT1": "This file store common tools paths, shared by all VS Code ideScripts-based projects.", + "ABOUT2": "Delete/correct this file if paths/folder structure change on system.", + "VERSION": "", + "LAST_RUN": "" +} +""" + +######################################################################################################### +launchFileTemplate = """{ + "version": "0.2.0", + "configurations": [ + ] +} +""" + +######################################################################################################### +cubeMxTmpFolderName = '_tmpCubeMx' +cubeMxTmpFileName = 'tmpCubeMx.txt' + +######################################################################################################### +defaultVsCodeSettingsFolder_WIN = os.path.expandvars("%APPDATA%/Code/User/") +defaultVsCodeSettingsFolder_UNIX = os.path.expandvars("$HOME/.config/Code/User/") +defaultVsCodeSettingsFolder_OSX = os.path.expandvars("$HOME/Library/Application Support/Code/User/") -- cgit v1.2.3