Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
parent
157a2c7a4a
commit
68062afc4f
@@ -413,70 +413,90 @@ export async function startBuildProcess(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasWinres) {
|
if (hasWinres) {
|
||||||
sendToStream({ type: "output", text: `Using go-winres: ${winresBin}\n`, level: "info" });
|
const agentDir = path.join(clientDir, "cmd", "agent");
|
||||||
winresTempDir = path.join(outDir, `.winres-${buildId.substring(0, 8)}`);
|
const winresLockPath = path.join(agentDir, ".winres.lock");
|
||||||
fs.mkdirSync(winresTempDir, { recursive: true });
|
|
||||||
|
|
||||||
const winresConfig: any = {};
|
if (fs.existsSync(winresLockPath)) {
|
||||||
|
sendToStream({
|
||||||
if (config.iconBase64) {
|
type: "output",
|
||||||
|
text: "WARNING: Another build is currently generating Windows resources for this client. Skipping winres for this build.\n",
|
||||||
|
level: "warn",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Acquire a simple lock so only one build at a time touches cmd/agent/*.syso
|
||||||
|
fs.writeFileSync(winresLockPath, String(process.pid));
|
||||||
try {
|
try {
|
||||||
const iconBuffer = Buffer.from(config.iconBase64, "base64");
|
sendToStream({ type: "output", text: `Using go-winres: ${winresBin}\n`, level: "info" });
|
||||||
const iconPath = path.join(winresTempDir, "icon.ico");
|
winresTempDir = path.join(outDir, `.winres-${buildId.substring(0, 8)}`);
|
||||||
fs.writeFileSync(iconPath, iconBuffer);
|
fs.mkdirSync(winresTempDir, { recursive: true });
|
||||||
winresConfig["RT_GROUP_ICON"] = { "#1": { "0000": "icon.ico" } };
|
|
||||||
sendToStream({ type: "output", text: `Icon embedded (${iconBuffer.length} bytes)\n`, level: "info" });
|
|
||||||
} catch (iconErr: any) {
|
|
||||||
sendToStream({ type: "output", text: `WARNING: Failed to process icon: ${iconErr.message}. Skipping icon.\n`, level: "warn" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const versionStr = config.assemblyVersion || "0.0.0.0";
|
const winresConfig: any = {};
|
||||||
const versionInfo: any = {
|
|
||||||
"0409": {
|
|
||||||
"FileDescription": config.assemblyTitle || "",
|
|
||||||
"ProductName": config.assemblyProduct || "",
|
|
||||||
"CompanyName": config.assemblyCompany || "",
|
|
||||||
"FileVersion": versionStr,
|
|
||||||
"ProductVersion": versionStr,
|
|
||||||
"LegalCopyright": config.assemblyCopyright || "",
|
|
||||||
"OriginalFilename": config.outputName ? (config.outputName + ".exe") : "",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
winresConfig["RT_VERSION"] = {
|
if (config.iconBase64) {
|
||||||
"#1": {
|
try {
|
||||||
"0000": {
|
const iconBuffer = Buffer.from(config.iconBase64, "base64");
|
||||||
"fixed": {
|
const iconPath = path.join(winresTempDir, "icon.ico");
|
||||||
"file_version": versionStr,
|
fs.writeFileSync(iconPath, iconBuffer);
|
||||||
"product_version": versionStr,
|
winresConfig["RT_GROUP_ICON"] = { "#1": { "0000": "icon.ico" } };
|
||||||
},
|
sendToStream({ type: "output", text: `Icon embedded (${iconBuffer.length} bytes)\n`, level: "info" });
|
||||||
"info": versionInfo,
|
} catch (iconErr: any) {
|
||||||
},
|
sendToStream({ type: "output", text: `WARNING: Failed to process icon: ${iconErr.message}. Skipping icon.\n`, level: "warn" });
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const winresJsonPath = path.join(winresTempDir, "winres.json");
|
|
||||||
fs.writeFileSync(winresJsonPath, JSON.stringify(winresConfig, null, 2));
|
|
||||||
sendToStream({ type: "output", text: `Winres config: ${winresJsonPath}\n`, level: "info" });
|
|
||||||
|
|
||||||
const sysoOutPrefix = path.join(clientDir, "cmd", "agent", "rsrc");
|
|
||||||
try {
|
|
||||||
const winresResult = await $`${winresBin} make --in ${winresJsonPath} --out ${sysoOutPrefix}`.cwd(winresTempDir).nothrow().quiet();
|
|
||||||
if (winresResult.exitCode !== 0) {
|
|
||||||
const stderr = winresResult.stderr.toString().trim();
|
|
||||||
sendToStream({ type: "output", text: `WARNING: go-winres failed (exit ${winresResult.exitCode}): ${stderr}\nBuilding without assembly data.\n`, level: "warn" });
|
|
||||||
} else {
|
|
||||||
const agentDir = path.join(clientDir, "cmd", "agent");
|
|
||||||
for (const f of fs.readdirSync(agentDir)) {
|
|
||||||
if (f.startsWith("rsrc") && f.endsWith(".syso")) {
|
|
||||||
generatedSysoFiles.push(path.join(agentDir, f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendToStream({ type: "output", text: `Windows resources generated (${generatedSysoFiles.length} .syso files)\n`, level: "info" });
|
|
||||||
|
const versionStr = config.assemblyVersion || "0.0.0.0";
|
||||||
|
const versionInfo: any = {
|
||||||
|
"0409": {
|
||||||
|
"FileDescription": config.assemblyTitle || "",
|
||||||
|
"ProductName": config.assemblyProduct || "",
|
||||||
|
"CompanyName": config.assemblyCompany || "",
|
||||||
|
"FileVersion": versionStr,
|
||||||
|
"ProductVersion": versionStr,
|
||||||
|
"LegalCopyright": config.assemblyCopyright || "",
|
||||||
|
"OriginalFilename": config.outputName ? (config.outputName + ".exe") : "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
winresConfig["RT_VERSION"] = {
|
||||||
|
"#1": {
|
||||||
|
"0000": {
|
||||||
|
"fixed": {
|
||||||
|
"file_version": versionStr,
|
||||||
|
"product_version": versionStr,
|
||||||
|
},
|
||||||
|
"info": versionInfo,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const winresJsonPath = path.join(winresTempDir, "winres.json");
|
||||||
|
fs.writeFileSync(winresJsonPath, JSON.stringify(winresConfig, null, 2));
|
||||||
|
sendToStream({ type: "output", text: `Winres config: ${winresJsonPath}\n`, level: "info" });
|
||||||
|
|
||||||
|
const sysoOutPrefix = path.join(agentDir, "rsrc");
|
||||||
|
try {
|
||||||
|
const winresResult = await $`${winresBin} make --in ${winresJsonPath} --out ${sysoOutPrefix}`.cwd(winresTempDir).nothrow().quiet();
|
||||||
|
if (winresResult.exitCode !== 0) {
|
||||||
|
const stderr = winresResult.stderr.toString().trim();
|
||||||
|
sendToStream({ type: "output", text: `WARNING: go-winres failed (exit ${winresResult.exitCode}): ${stderr}\nBuilding without assembly data.\n`, level: "warn" });
|
||||||
|
} else {
|
||||||
|
for (const f of fs.readdirSync(agentDir)) {
|
||||||
|
if (f.startsWith("rsrc") && f.endsWith(".syso")) {
|
||||||
|
generatedSysoFiles.push(path.join(agentDir, f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sendToStream({ type: "output", text: `Windows resources generated (${generatedSysoFiles.length} .syso files)\n`, level: "info" });
|
||||||
|
}
|
||||||
|
} catch (winresErr: any) {
|
||||||
|
sendToStream({ type: "output", text: `WARNING: go-winres failed: ${winresErr.message || winresErr}. Building without assembly data.\n`, level: "warn" });
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(winresLockPath);
|
||||||
|
} catch {
|
||||||
|
// ignore errors removing the lock
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (winresErr: any) {
|
|
||||||
sendToStream({ type: "output", text: `WARNING: go-winres failed: ${winresErr.message || winresErr}. Building without assembly data.\n`, level: "warn" });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user