mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-12 10:39:57 +00:00
Limit macOS builds to macOS hosts
This commit is contained in:
@@ -79,6 +79,9 @@ const spawnOptions = {
|
|||||||
, stdio: [ process.stdin, process.stdout, process.stderr ]
|
, stdio: [ process.stdin, process.stdout, process.stderr ]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isBuildingForMac = argv.platform === "darwin";
|
||||||
|
const isBuildingForMacOnMac = isBuildingForMac && process.platform === "darwin";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shouldn't exist, but cleanup and re-create any existing
|
* Shouldn't exist, but cleanup and re-create any existing
|
||||||
* build directories, just in case.
|
* build directories, just in case.
|
||||||
@@ -90,6 +93,18 @@ fs.ensureDirSync(DIST_PATH, { recursive: true });
|
|||||||
|
|
||||||
|
|
||||||
async function build () {
|
async function build () {
|
||||||
|
/**
|
||||||
|
* Because the native receiver selector can only be built on
|
||||||
|
* systems with the capacity to link to the native AppKit
|
||||||
|
* libraries, and the pkg installer can only be built on
|
||||||
|
* platforms with the requisite pkgbuild/productbuild binaries,
|
||||||
|
* there's no point in trying to build from other platforms.
|
||||||
|
*/
|
||||||
|
if (isBuildingForMac && !isBuildingForMacOnMac) {
|
||||||
|
console.error("macOS version must be built on macOS");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Run tsc
|
// Run tsc
|
||||||
spawnSync(`tsc --project ${ROOT_PATH} \
|
spawnSync(`tsc --project ${ROOT_PATH} \
|
||||||
--outDir ${BUILD_PATH}`
|
--outDir ${BUILD_PATH}`
|
||||||
@@ -167,7 +182,7 @@ async function build () {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Build NativeMacReceiverSelector
|
// Build NativeMacReceiverSelector
|
||||||
if (argv.platform === "darwin") {
|
if (isBuildingForMacOnMac) {
|
||||||
const sourceFiles = glob.sync("*.swift", {
|
const sourceFiles = glob.sync("*.swift", {
|
||||||
cwd: path.join(__dirname, "../NativeMacReceiverSelector")
|
cwd: path.join(__dirname, "../NativeMacReceiverSelector")
|
||||||
, absolute: true
|
, absolute: true
|
||||||
@@ -177,9 +192,16 @@ async function build () {
|
|||||||
.map(fileName => `"${fileName}"`)
|
.map(fileName => `"${fileName}"`)
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
|
||||||
spawnSync(`swiftc -o "${path.join(BUILD_PATH, selectorExecutableName)}" \
|
const buildCommand = `
|
||||||
${formattedSourceFiles}`
|
swiftc -o "${path.join(BUILD_PATH, selectorExecutableName)}" \
|
||||||
, spawnOptions);
|
${formattedSourceFiles}`;
|
||||||
|
|
||||||
|
// Build with optimizations if packaging
|
||||||
|
if (argv.package) {
|
||||||
|
buildCommand += " -0size";
|
||||||
|
}
|
||||||
|
|
||||||
|
spawnSync(buildCommand, spawnOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -210,7 +232,7 @@ async function build () {
|
|||||||
, path.join(DIST_PATH, builtExecutableName)
|
, path.join(DIST_PATH, builtExecutableName)
|
||||||
, { overwrite: true });
|
, { overwrite: true });
|
||||||
|
|
||||||
if (argv.platform === "darwin") {
|
if (isBuildingForMacOnMac) {
|
||||||
fs.moveSync(
|
fs.moveSync(
|
||||||
path.join(BUILD_PATH, selectorExecutableName)
|
path.join(BUILD_PATH, selectorExecutableName)
|
||||||
, path.join(DIST_PATH, selectorExecutableName)
|
, path.join(DIST_PATH, selectorExecutableName)
|
||||||
@@ -235,10 +257,10 @@ function packageApp (platform, arch) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case "win32": return packageWin32(...packageFunctionArgs);
|
case "win32": return packageWin32(...packageFunctionArgs);
|
||||||
case "darwin": return packageDarwin(...packageFunctionArgs);
|
case "darwin": return packageDarwin(...packageFunctionArgs);
|
||||||
|
|
||||||
case "linux":
|
case "linux": {
|
||||||
/**
|
/**
|
||||||
* Get manifest path from package type sub key for Linux
|
* Get manifest path from package type sub key for Linux
|
||||||
* platforms.
|
* platforms.
|
||||||
@@ -252,11 +274,13 @@ function packageApp (platform, arch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
default:
|
default: {
|
||||||
console.error("Unsupported target platform");
|
console.error("Unsupported target platform");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -510,16 +510,16 @@ async function onConnectShim (port: browser.runtime.Port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "main:/sessionCreated": {
|
case "main:/sessionCreated": {
|
||||||
NativeMacReceiverSelectorManager.close();
|
PopupReceiverSelectorManager.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "main:/selectReceiverBegin": {
|
case "main:/selectReceiverBegin": {
|
||||||
NativeMacReceiverSelectorManager.open(
|
PopupReceiverSelectorManager.open(
|
||||||
Array.from(statusBridgeReceivers.values())
|
Array.from(statusBridgeReceivers.values())
|
||||||
, message.data.defaultMediaType);
|
, message.data.defaultMediaType);
|
||||||
|
|
||||||
NativeMacReceiverSelectorManager.addEventListener("selected"
|
PopupReceiverSelectorManager.addEventListener("selected"
|
||||||
, (ev: ReceiverSelectorSelectedEvent) => {
|
, (ev: ReceiverSelectorSelectedEvent) => {
|
||||||
|
|
||||||
port.postMessage({
|
port.postMessage({
|
||||||
@@ -530,13 +530,13 @@ async function onConnectShim (port: browser.runtime.Port) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
NativeMacReceiverSelectorManager.addEventListener("cancelled", () => {
|
PopupReceiverSelectorManager.addEventListener("cancelled", () => {
|
||||||
port.postMessage({
|
port.postMessage({
|
||||||
subject: "shim:/selectReceiverCancelled"
|
subject: "shim:/selectReceiverCancelled"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
NativeMacReceiverSelectorManager.addEventListener("error", () => {
|
PopupReceiverSelectorManager.addEventListener("error", () => {
|
||||||
// TODO: Report errors properly
|
// TODO: Report errors properly
|
||||||
port.postMessage({
|
port.postMessage({
|
||||||
subject: "shim:/selectReceiverCancelled"
|
subject: "shim:/selectReceiverCancelled"
|
||||||
|
|||||||
Reference in New Issue
Block a user