This repository was archived by the owner on Nov 25, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 75
Switch to using target triple like prefix for installed exes #429
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ import which from "which"; | |
| import semver from "semver"; | ||
|
|
||
| import * as minisign from "./minisign"; | ||
| import { getVersion, getZigArchName, getZigOSName } from "./zigUtil"; | ||
| import { getHostZigName, getVersion, getZigArchName, getZigOSName } from "./zigUtil"; | ||
|
|
||
| const execFile = util.promisify(childProcess.execFile); | ||
| const chmod = util.promisify(fs.chmod); | ||
|
|
@@ -68,7 +68,14 @@ export async function install(config: Config, version: semver.SemVer): Promise<s | |
|
|
||
| async function installGuarded(config: Config, version: semver.SemVer): Promise<string> { | ||
| const exeName = config.exeName + (process.platform === "win32" ? ".exe" : ""); | ||
| const subDirName = `${getZigOSName()}-${getZigArchName()}-${version.raw}`; | ||
| // After version 0.14.1/0.15.0-dev.631+9a3540d61 Zig tarballs put | ||
| // the architecture first like it is in target triples. | ||
| const subDirName = | ||
| config.exeName === "zig" && | ||
| ((version.prerelease.length === 0 && semver.gte(version, "0.14.1")) || | ||
| semver.gte(version, "0.15.0-dev.631+9a3540d61")) | ||
| ? `${getZigArchName()}-${getZigOSName()}-${version.raw}` | ||
| : `${getZigOSName()}-${getZigArchName()}-${version.raw}`; | ||
| const exeUri = vscode.Uri.joinPath(config.context.globalStorageUri, config.exeName, subDirName, exeName); | ||
|
|
||
| await setLastAccessTime(config, version); | ||
|
|
@@ -124,7 +131,7 @@ async function installFromMirror( | |
| const isWindows = process.platform === "win32"; | ||
| const fileExtension = isWindows ? "zip" : "tar.xz"; | ||
| const exeName = config.exeName + (isWindows ? ".exe" : ""); | ||
| const subDirName = `${getZigOSName()}-${getZigArchName()}-${version.raw}`; | ||
| const subDirName = `${getHostZigName()}-${version.raw}`; | ||
| const fileName = `${config.exeName}-${subDirName}.${fileExtension}`; | ||
|
|
||
| const installDir = vscode.Uri.joinPath(config.context.globalStorageUri, config.exeName, subDirName); | ||
|
|
@@ -271,13 +278,24 @@ async function installFromMirror( | |
| /** Returns all locally installed versions */ | ||
| export async function query(config: Config): Promise<semver.SemVer[]> { | ||
| const available: semver.SemVer[] = []; | ||
| const prefix = `${getZigOSName()}-${getZigArchName()}`; | ||
| const prefix = getHostZigName(); | ||
|
|
||
| // Remove after some time has passed from the prefix change. | ||
| const prefixOld = `${getZigOSName()}-${getZigArchName()}`; | ||
|
|
||
| const storageDir = vscode.Uri.joinPath(config.context.globalStorageUri, config.exeName); | ||
| try { | ||
| for (const [name] of await vscode.workspace.fs.readDirectory(storageDir)) { | ||
| if (name.startsWith(prefix)) { | ||
| available.push(new semver.SemVer(name.substring(prefix.length + 1))); | ||
| } else if (name.startsWith(prefixOld)) { | ||
| const version = name.substring(prefixOld.length + 1); | ||
| await vscode.workspace.fs.rename( | ||
| vscode.Uri.joinPath(storageDir, name), | ||
| vscode.Uri.joinPath(storageDir, `${prefix}-${version}`), | ||
| ); | ||
| await setLastAccessTime(config, new semver.SemVer(version)); | ||
| available.push(new semver.SemVer(version)); | ||
|
Comment on lines
+291
to
+298
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This converts all installed Zig and ZLS versions from |
||
| } | ||
| } | ||
| } catch (e) { | ||
|
|
@@ -293,7 +311,7 @@ export async function query(config: Config): Promise<semver.SemVer[]> { | |
| /** Set the last access time of the (installed) version. */ | ||
| async function setLastAccessTime(config: Config, version: semver.SemVer): Promise<void> { | ||
| await config.context.globalState.update( | ||
| `${config.exeName}-last-access-time-${getZigOSName()}-${getZigArchName()}-${version.raw}`, | ||
| `${config.exeName}-last-access-time-${getHostZigName()}-${version.raw}`, | ||
| Date.now(), | ||
| ); | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail for older Zig versions like
0.13.0.subDirNameis also used to resolve the file name that should be downloaded.