mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-31 02:21:57 +03:00
Link Swift stdlib
This commit is contained in:
parent
46abb1cbf6
commit
5fec784580
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -770,6 +770,8 @@ dependencies = [
|
||||
"objc",
|
||||
"parking_lot 0.11.2",
|
||||
"postage",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"simplelog",
|
||||
]
|
||||
|
||||
|
@ -243,11 +243,8 @@
|
||||
AFA4DBD228C0F7F5001AD7BE /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEFINES_MODULE = NO;
|
||||
EXECUTABLE_PREFIX = lib;
|
||||
KEEP_PRIVATE_EXTERNS = NO;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
@ -256,7 +253,6 @@
|
||||
"@loader_path/../Frameworks",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "LiveKitObjC-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
@ -266,11 +262,8 @@
|
||||
AFA4DBD328C0F7F5001AD7BE /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEFINES_MODULE = NO;
|
||||
EXECUTABLE_PREFIX = lib;
|
||||
KEEP_PRIVATE_EXTERNS = NO;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
@ -279,7 +272,6 @@
|
||||
"@loader_path/../Frameworks",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "LiveKitObjC-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
|
@ -25,3 +25,5 @@ simplelog = "0.9"
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.59.2"
|
||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
@ -1,6 +1,62 @@
|
||||
use serde::Deserialize;
|
||||
use std::{env, path::PathBuf, process::Command};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SwiftTargetInfo {
|
||||
pub triple: String,
|
||||
pub unversioned_triple: String,
|
||||
pub module_triple: String,
|
||||
pub swift_runtime_compatibility_version: String,
|
||||
#[serde(rename = "librariesRequireRPath")]
|
||||
pub libraries_require_rpath: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SwiftPaths {
|
||||
pub runtime_library_paths: Vec<String>,
|
||||
pub runtime_library_import_paths: Vec<String>,
|
||||
pub runtime_resource_path: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct SwiftTarget {
|
||||
pub target: SwiftTargetInfo,
|
||||
pub paths: SwiftPaths,
|
||||
}
|
||||
|
||||
const MACOS_TARGET_VERSION: &str = "12";
|
||||
|
||||
pub fn link_swift_libs() {
|
||||
let mut arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
if arch == "aarch64" {
|
||||
arch = "arm64".into();
|
||||
}
|
||||
let target = format!("{}-apple-macosx{}", arch, MACOS_TARGET_VERSION);
|
||||
|
||||
let swift_target_info_str = Command::new("swift")
|
||||
.args(&["-target", &target, "-print-target-info"])
|
||||
.output()
|
||||
.unwrap()
|
||||
.stdout;
|
||||
|
||||
let swift_target_info: SwiftTarget = serde_json::from_slice(&swift_target_info_str).unwrap();
|
||||
if swift_target_info.target.libraries_require_rpath {
|
||||
panic!("Libraries require RPath! Change minimum MacOS value to fix.")
|
||||
}
|
||||
|
||||
swift_target_info
|
||||
.paths
|
||||
.runtime_library_paths
|
||||
.iter()
|
||||
.for_each(|path| {
|
||||
println!("cargo:rustc-link-search=native={}", path);
|
||||
});
|
||||
}
|
||||
|
||||
fn main() {
|
||||
link_swift_libs();
|
||||
println!("cargo:rerun-if-changed=/Users/as-cii/Library/Developer/Xcode/DerivedData/LiveKitObjC-ftgpxknhsgkrocbhhgjkyyvkgkbj/Build/Products/Debug/libLiveKitObjC.a");
|
||||
println!("cargo:rustc-link-search=/Users/as-cii/Library/Developer/Xcode/DerivedData/LiveKitObjC-ftgpxknhsgkrocbhhgjkyyvkgkbj/Build/Products/Debug");
|
||||
println!("cargo:rustc-link-lib=static=LiveKitObjC");
|
||||
|
Loading…
Reference in New Issue
Block a user