]> Git Repo - pico-vscode.git/commitdiff
Improved home var usage in settings
authorpaulober <[email protected]>
Wed, 13 Dec 2023 23:58:51 +0000 (00:58 +0100)
committerpaulober <[email protected]>
Wed, 13 Dec 2023 23:58:51 +0000 (00:58 +0100)
Signed-off-by: paulober <[email protected]>
scripts/pico_project.py
src/utils/download.mts

index 4395e8d6713a99a96f227f45df7aba79a7773a8c..4cc05a1a6f109b8318c94fe0bc20fb241a75b225 100644 (file)
@@ -1178,6 +1178,10 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
     #cPath = f"${{env:PICO_TOOLCHAIN_PATH_{envSuffix}}}" + os.path.sep + os.path.basename(str(compilerPath).replace('\\', '\\\\' ))
     cPath = compilerPath.as_posix()
 
+    # if this is a path in the .pico-sdk homedir tell the settings to use the homevar
+    user_home = os.path.expanduser("~").replace("\\\\", "/")
+    use_home_var = f"{user_home}/.pico-sdk" in ninjaPath
+
     for p in projects :
         if p == 'vscode':
             launch = f'''{{
@@ -1281,8 +1285,8 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
     "cmake.generator": "Ninja",
     "cmake.cmakePath": "{cmakePath}",
     "raspberry-pi-pico.cmakeAutoConfigure": true,
-    "raspberry-pi-pico.cmakePath": "{cmakePath}",
-    "raspberry-pi-pico.ninjaPath": "{ninjaPath}"
+    "raspberry-pi-pico.cmakePath": "{cmakePath.replace(user_home, "${HOME}") if use_home_var else cmakePath}",
+    "raspberry-pi-pico.ninjaPath": "{ninjaPath.replace(user_home, "${HOME}") if use_home_var else ninjaPath}"
 }}
 '''
 
@@ -1303,7 +1307,7 @@ def generateProjectFiles(projectPath, projectName, sdkPath, projects, debugger,
         {{
             "label": "Compile Project",
             "type": "shell",
-            "command": "{ninjaPath}",
+            "command": "{ninjaPath.replace(user_home, "${userHome}") if use_home_var else ninjaPath}",
             "args": ["-C", "${{workspaceFolder}}/build"],
             "group": "build",
             "presentation": {{
index e3e90c4f51db7c1a434cbec95cb08ce4617af249..35a93213d780d333d69b5cbd4ee18b8402a60929 100644 (file)
@@ -168,8 +168,9 @@ export async function downloadAndInstallSDK(
   settings: Settings
 ): Promise<boolean> {
   const gitExecutable =
-    settings.getString(SettingsKey.gitPath)?.replace(HOME_VAR, homedir()) ||
-    "git";
+    settings
+      .getString(SettingsKey.gitPath)
+      ?.replace(HOME_VAR, homedir().replaceAll("\\", "/")) || "git";
 
   const requirementsCheck = await checkForInstallationRequirements(
     settings,
@@ -213,7 +214,8 @@ export async function downloadAndInstallSDK(
     const python3Exe: string =
       settings
         .getString(SettingsKey.python3Path)
-        ?.replace(HOME_VAR, homedir()) || process.platform === "win32"
+        ?.replace(HOME_VAR, homedir().replaceAll("\\", "/")) ||
+      process.platform === "win32"
         ? "python"
         : "python3";
     const python3: string | null = await which(python3Exe, { nothrow: true });
@@ -794,7 +796,9 @@ export async function downloadGit(): Promise<string | undefined> {
   if (existsSync(targetDirectory)) {
     Logger.log(`Git is already installed.`);
 
-    return `${settingsTargetDirectory}/git` + `/${GIT_MACOS_VERSION}/bin/git`;
+    return process.platform === "win32"
+      ? `${settingsTargetDirectory}/cmd/git.exe`
+      : `${settingsTargetDirectory}/bin/git`;
   }
 
   // Ensure the target directory exists
@@ -844,10 +848,7 @@ export async function downloadGit(): Promise<string | undefined> {
             .then(success => {
               unlinkSync(archiveFilePath);
               resolve(
-                success
-                  ? `${settingsTargetDirectory}/git` +
-                      `/${GIT_MACOS_VERSION}/bin/git`
-                  : undefined
+                success ? `${settingsTargetDirectory}/bin/git` : undefined
               );
             })
             .catch(() => {
This page took 0.034584 seconds and 4 git commands to generate.