Skip to content

Commit bc9c943

Browse files
committed
Proper support for platform specific extensions
1 parent 5bb239f commit bc9c943

5 files changed

+48
-22
lines changed

Diff for: extensions-schema.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@
4141
"description": "A property to set a different lookup ID when querying the Microsoft Marketplace. Please do not ever use if not absolutely necessary."
4242
},
4343
"target": {
44-
"type": "array",
45-
"description": "A list of platforms to target. If unspecified, a universal extension will be published in case of building from source and if the vsix is resolved from GitHub Releases, all of the attached platform-specific assets will be published.",
46-
"uniqueItems": true,
47-
"minItems": 1
44+
"type": "object",
45+
"description": "An object containing the ids of platforms to target while publishing. If unspecified, a universal extension will be published in case of building from source and if the vsix is resolved from GitHub Releases, all of the attached platform-specific assets will be published. The value of the key should be either `true` or an object specifying environment variables to be applied while packaging inside of `env`."
4846
}
4947
},
5048
"required": ["repository"],

Diff for: extensions.json

+23-13
Original file line numberDiff line numberDiff line change
@@ -805,19 +805,29 @@
805805
},
806806
"ms-python.debugpy": {
807807
"repository": "https://github.com/microsoft/vscode-python-debugger",
808-
"custom": [
809-
"python -m pip install -U pip pipx wheel",
810-
"npm ci --prefer-offline",
811-
"VSCETARGET=linux-x64 python -m pipx run nox --session install_bundled_libs",
812-
"vsce package --target=linux-x64",
813-
"VSCETARGET=linux-arm64 python -m pipx run nox --session install_bundled_libs",
814-
"vsce package --target=linux-arm64",
815-
"VSCETARGET=darwin-arm64 python -m pipx run nox --session install_bundled_libs",
816-
"vsce package --target=darwin-arm64",
817-
"VSCETARGET=win32-x64 python -m pipx run nox --session install_bundled_libs",
818-
"vsce package --target=win32-x64"
819-
],
820-
"target": ["linux-x64", "linux-arm64", "darwin-arm64", "win32-x64"]
808+
"prepublish": "python -m pip install -U pip pipx wheel && npm ci --prefer-offline && python -m pipx run nox --session install_bundled_libs",
809+
"target": {
810+
"linux-x64": {
811+
"env": {
812+
"VSCETARGET": "linux-x64"
813+
}
814+
},
815+
"linux-arm64": {
816+
"env": {
817+
"VSCETARGET": "linux-arm64"
818+
}
819+
},
820+
"darwin-arm64": {
821+
"env": {
822+
"VSCETARGET": "darwin-arm64"
823+
}
824+
},
825+
"win32-x64": {
826+
"env": {
827+
"VSCETARGET": "win32-x64"
828+
}
829+
}
830+
}
821831
},
822832
"ms-python.flake8": {
823833
"repository": "https://github.com/microsoft/vscode-flake8",

Diff for: publish-extension.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ openGalleryApi.post = (url, data, additionalHeaders) =>
8282
{ cwd: path.join(context.repo, extension.location ?? "."), quiet: false },
8383
);
8484
}
85-
} catch { }
85+
} catch {}
8686

8787
if (extension.custom) {
8888
try {

Diff for: publish-extensions.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,21 @@ const ensureBuildPrerequisites = async () => {
291291
let timeout;
292292

293293
const publishVersion = async (extension, context) => {
294+
const env = {
295+
...process.env,
296+
...context.environmentVariables,
297+
};
298+
299+
console.debug(`Publishing ${extension.id} for ${context.target || "universal"}...`);
300+
294301
await new Promise((resolve, reject) => {
295302
const p = cp.spawn(
296303
process.execPath,
297304
["publish-extension.js", JSON.stringify({ extension, context, extensions })],
298305
{
299306
stdio: ["ignore", "inherit", "inherit"],
300307
cwd: process.cwd(),
301-
env: process.env,
308+
env,
302309
},
303310
);
304311
p.on("error", reject);
@@ -326,7 +333,7 @@ const ensureBuildPrerequisites = async () => {
326333
if (context.files) {
327334
// Publish all targets of extension from GitHub Release assets
328335
for (const [target, file] of Object.entries(context.files)) {
329-
if (!extension.target || extension.target.includes(target)) {
336+
if (!extension.target || Object.keys(extension.target).includes(target)) {
330337
context.file = file;
331338
context.target = target;
332339
await publishVersion(extension, context);
@@ -336,8 +343,11 @@ const ensureBuildPrerequisites = async () => {
336343
}
337344
} else if (extension.target) {
338345
// Publish all specified targets of extension from sources
339-
for (const target of extension.target) {
346+
for (const [target, targetData] of Object.entries(extension.target)) {
340347
context.target = target;
348+
if (targetData !== true) {
349+
context.environmentVariables = targetData.env;
350+
}
341351
await publishVersion(extension, context);
342352
}
343353
} else {

Diff for: types.d.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ export interface Extension {
8888
extensionFile?: string;
8989
custom?: string[];
9090
timeout?: number;
91-
target?: string[];
91+
target?: {
92+
[key: string]:
93+
| true
94+
| {
95+
env: { [key: string]: string };
96+
};
97+
};
9298
msMarketplaceIdOverride?: string;
9399
pythonVersion?: string;
94100
}
@@ -124,6 +130,8 @@ export interface PublishContext {
124130
file?: string;
125131
repo?: string;
126132
ref?: string;
133+
134+
environmentVariables?: { [key: string]: string };
127135
}
128136

129137
interface IRawGalleryExtensionProperty {

0 commit comments

Comments
 (0)