|
1 | 1 | use std::path::PathBuf;
|
2 | 2 |
|
| 3 | +<<<<<<< HEAD |
3 | 4 | use super::cygpath::get_windows_path;
|
4 | 5 | use crate::artifact_names::{dynamic_lib_name, static_lib_name};
|
5 | 6 | use crate::external_deps::cc::cc;
|
| 7 | +======= |
| 8 | +use crate::artifact_names::static_lib_name; |
| 9 | +use crate::external_deps::cc::{cc, cxx}; |
| 10 | +>>>>>>> e3cf7e53339 (rewrite foreign-double-unwind to rmake) |
6 | 11 | use crate::external_deps::llvm::llvm_ar;
|
7 | 12 | use crate::path_helpers::path;
|
8 | 13 | use crate::targets::{is_darwin, is_msvc, is_windows};
|
9 | 14 |
|
10 | 15 | // FIXME(Oneirical): These native build functions should take a Path-based generic.
|
11 | 16 |
|
12 | 17 | /// Builds a static lib (`.lib` on Windows MSVC and `.a` for the rest) with the given name.
|
| 18 | +/// Built from a C file. |
13 | 19 | #[track_caller]
|
14 | 20 | pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
|
15 | 21 | let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
|
@@ -58,3 +64,24 @@ pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf {
|
58 | 64 | }
|
59 | 65 | path(lib_path)
|
60 | 66 | }
|
| 67 | + |
| 68 | +/// Builds a static lib (`.lib` on Windows MSVC and `.a` for the rest) with the given name. |
| 69 | +/// Built from a C++ file. |
| 70 | +#[track_caller] |
| 71 | +pub fn build_native_static_lib_cxx(lib_name: &str) -> PathBuf { |
| 72 | + let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") }; |
| 73 | + let src = format!("{lib_name}.cpp"); |
| 74 | + let lib_path = static_lib_name(lib_name); |
| 75 | + if is_msvc() { |
| 76 | + cxx().arg("-EHs").arg("-c").out_exe(&obj_file).input(src).run(); |
| 77 | + } else { |
| 78 | + cxx().arg("-c").out_exe(&obj_file).input(src).run(); |
| 79 | + }; |
| 80 | + let obj_file = if is_msvc() { |
| 81 | + PathBuf::from(format!("{lib_name}.obj")) |
| 82 | + } else { |
| 83 | + PathBuf::from(format!("{lib_name}.o")) |
| 84 | + }; |
| 85 | + llvm_ar().obj_to_ar().output_input(&lib_path, &obj_file).run(); |
| 86 | + path(lib_path) |
| 87 | +} |
0 commit comments