Skip to content

Commit c74c8ee

Browse files
committed
refactor+fix: trying to fix sqlite3mc cross compilation
1 parent d09ed82 commit c74c8ee

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

libsql-ffi/build.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,28 @@ fn build_multiple_ciphers(target: &str, out_path: &Path) {
474474
.unwrap();
475475

476476
if let Some(ref cc) = cross_cc {
477-
if cc.contains("aarch64") && cc.contains("linux") {
478-
cmake_opts.push(&cmake_toolchain_opt);
479-
writeln!(toolchain_file, "set(CMAKE_SYSTEM_NAME \"Linux\")").unwrap();
480-
writeln!(toolchain_file, "set(CMAKE_SYSTEM_PROCESSOR \"arm64\")").unwrap();
481-
} else if cc.contains("x86_64") && cc.contains("darwin") {
482-
cmake_opts.push(&cmake_toolchain_opt);
483-
writeln!(toolchain_file, "set(CMAKE_SYSTEM_NAME \"Darwin\")").unwrap();
484-
writeln!(toolchain_file, "set(CMAKE_SYSTEM_PROCESSOR \"x86_64\")").unwrap();
485-
}
486-
}
487-
if let Some(cc) = cross_cc {
477+
let system_name = if cc.contains("linux") {
478+
"Linux"
479+
} else if cc.contains("darwin") {
480+
"Darwin"
481+
} else {
482+
panic!("Unsupported cross target {}", cc)
483+
};
484+
485+
let system_processor = if cc.contains("x86_64") {
486+
"x86_64"
487+
} else if cc.contains("aarch64") {
488+
"arm64"
489+
} else {
490+
panic!("Unsupported cross target {}", cc)
491+
};
492+
493+
cmake_opts.push(&cmake_toolchain_opt);
494+
writeln!(toolchain_file, "set(CMAKE_SYSTEM_NAME \"{}\")", system_name).unwrap();
495+
writeln!(toolchain_file, "set(CMAKE_SYSTEM_PROCESSOR \"{}\")", system_processor).unwrap();
488496
writeln!(toolchain_file, "set(CMAKE_C_COMPILER {})", cc).unwrap();
489497
}
498+
490499
if let Some(cxx) = cross_cxx {
491500
writeln!(toolchain_file, "set(CMAKE_CXX_COMPILER {})", cxx).unwrap();
492501
}

0 commit comments

Comments
 (0)