mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-04 15:52:24 -08:00
refactor(call): remove native lifecycle integration
This commit is contained in:
53 files changed
+37
-4737
No files matched your search
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
case "${1:-}" in
|
||||
-p|--print-path)
|
||||
printf '%s\n' "${DEVELOPER_DIR:-}"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
exec /usr/bin/xcode-select "$@"
|
||||
+3
-126
@@ -20,10 +20,8 @@
|
||||
*/
|
||||
|
||||
import { run } from '@tauri-apps/cli';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { delimiter, dirname, join, resolve } from 'path';
|
||||
import { dirname, join } from 'path';
|
||||
import process from 'node:process';
|
||||
import { PrefixedLogger, createTextHelpers } from './utils/console-style.js';
|
||||
|
||||
@@ -37,125 +35,6 @@ const cmdlineArgs = process.argv.slice(2);
|
||||
process.chdir(join(__dirname, '..'));
|
||||
|
||||
const DESKTOP = new Set(['wry', 'cef']);
|
||||
const DEFAULT_XCODE_DEVELOPER_DIR = '/Applications/Xcode.app/Contents/Developer';
|
||||
|
||||
function normalizeDeveloperDir(value) {
|
||||
const path = resolve(value);
|
||||
return path.endsWith('.app') ? join(path, 'Contents', 'Developer') : path;
|
||||
}
|
||||
|
||||
function isFullXcodeDeveloperDir(developerDir) {
|
||||
return (
|
||||
existsSync(join(developerDir, 'usr', 'bin', 'xcodebuild')) &&
|
||||
existsSync(join(developerDir, 'Platforms', 'MacOSX.platform', 'Developer', 'SDKs'))
|
||||
);
|
||||
}
|
||||
|
||||
function failMacOSToolchain(reason) {
|
||||
logger.error(
|
||||
`${reason} Install full Xcode or set DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer.`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function configureMacOSToolchain() {
|
||||
if (process.platform !== 'darwin') {
|
||||
return;
|
||||
}
|
||||
|
||||
const configuredDeveloperDir = process.env.DEVELOPER_DIR?.trim();
|
||||
let developerDir;
|
||||
if (configuredDeveloperDir) {
|
||||
developerDir = normalizeDeveloperDir(configuredDeveloperDir);
|
||||
if (!isFullXcodeDeveloperDir(developerDir)) {
|
||||
failMacOSToolchain(`Full Xcode was not found at DEVELOPER_DIR=${configuredDeveloperDir}.`);
|
||||
}
|
||||
} else {
|
||||
let selectedDeveloperDir;
|
||||
try {
|
||||
selectedDeveloperDir = execFileSync(
|
||||
'/usr/bin/xcode-select',
|
||||
['--print-path'],
|
||||
{ encoding: 'utf8' },
|
||||
).trim();
|
||||
} catch {
|
||||
selectedDeveloperDir = '';
|
||||
}
|
||||
|
||||
const candidates = [selectedDeveloperDir, DEFAULT_XCODE_DEVELOPER_DIR]
|
||||
.filter(Boolean)
|
||||
.map(normalizeDeveloperDir);
|
||||
developerDir = candidates.find(isFullXcodeDeveloperDir);
|
||||
if (!developerDir) {
|
||||
failMacOSToolchain(
|
||||
'Full Xcode was not found at the selected developer directory or /Applications/Xcode.app.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let sdkRoot;
|
||||
try {
|
||||
sdkRoot = execFileSync(
|
||||
'/usr/bin/xcrun',
|
||||
['--sdk', 'macosx', '--show-sdk-path'],
|
||||
{
|
||||
encoding: 'utf8',
|
||||
env: { ...process.env, DEVELOPER_DIR: developerDir },
|
||||
},
|
||||
).trim();
|
||||
} catch {
|
||||
failMacOSToolchain(`Unable to resolve the macOS SDK from DEVELOPER_DIR=${developerDir}.`);
|
||||
}
|
||||
if (!sdkRoot || !existsSync(sdkRoot)) {
|
||||
failMacOSToolchain(`The macOS SDK was not found from DEVELOPER_DIR=${developerDir}.`);
|
||||
}
|
||||
|
||||
process.env.DEVELOPER_DIR = developerDir;
|
||||
process.env.SDKROOT = sdkRoot;
|
||||
process.env.PATH = [join(__dirname, 'macos-bin'), process.env.PATH]
|
||||
.filter(Boolean)
|
||||
.join(delimiter);
|
||||
}
|
||||
|
||||
function injectMacOSDevFeature(args) {
|
||||
if (process.platform !== 'darwin' || args[0] !== 'dev') {
|
||||
return args;
|
||||
}
|
||||
|
||||
const feature = 'notifications-dev';
|
||||
const separatorIndex = args.indexOf('--');
|
||||
const featureArgsEnd = separatorIndex === -1 ? args.length : separatorIndex;
|
||||
const appendFeature = (value) =>
|
||||
value.split(',').includes(feature) ? value : value ? `${value},${feature}` : feature;
|
||||
|
||||
for (let index = 0; index < featureArgsEnd; index += 1) {
|
||||
if (args[index] === '--features' && index + 1 < featureArgsEnd) {
|
||||
const featureValue = args[index + 1];
|
||||
if (featureValue.split(',').includes(feature)) {
|
||||
return args;
|
||||
}
|
||||
return [...args.slice(0, index + 1), appendFeature(featureValue), ...args.slice(index + 2)];
|
||||
}
|
||||
if (args[index].startsWith('--features=')) {
|
||||
const featureValue = args[index].slice('--features='.length);
|
||||
if (featureValue.split(',').includes(feature)) {
|
||||
return args;
|
||||
}
|
||||
return [
|
||||
...args.slice(0, index),
|
||||
`--features=${appendFeature(featureValue)}`,
|
||||
...args.slice(index + 1),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
...args.slice(0, featureArgsEnd),
|
||||
'--features',
|
||||
feature,
|
||||
...args.slice(featureArgsEnd),
|
||||
];
|
||||
}
|
||||
|
||||
async function runTauri(args) {
|
||||
logger.info(`${dim('Running:')} tauri ${args.join(' ')}`);
|
||||
@@ -168,10 +47,8 @@ async function runTauri(args) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
configureMacOSToolchain();
|
||||
|
||||
if (cmdlineArgs.length === 0 || !DESKTOP.has(cmdlineArgs[0])) {
|
||||
return runTauri(injectMacOSDevFeature(cmdlineArgs));
|
||||
return runTauri(cmdlineArgs);
|
||||
}
|
||||
|
||||
const [platform, cmd, ...rawTauriArgs] = cmdlineArgs;
|
||||
@@ -207,7 +84,7 @@ async function main() {
|
||||
args.splice(1, 0, '--no-bundle');
|
||||
}
|
||||
|
||||
return runTauri(injectMacOSDevFeature(args));
|
||||
return runTauri(args);
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in new issue
Block a user