|
1 | 1 | // Copyright © SixtyFPS GmbH <[email protected]>
|
2 | 2 | // SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
3 | 3 |
|
| 4 | +use std::fmt::Write; |
4 | 5 | use std::path::Path;
|
5 | 6 |
|
6 | 7 | fn main() {
|
@@ -28,8 +29,38 @@ fn main() {
|
28 | 29 | // out_dir is something like
|
29 | 30 | // <target_dir>/build/sixtyfps-rendering-backend-default-1fe5c4ab61eb0584/out
|
30 | 31 | // and we want to write to a common directory, so write in the build/ dir
|
31 |
| - let target_path = |
| 32 | + let style_target_path = |
32 | 33 | Path::new(&out_dir).parent().unwrap().parent().unwrap().join("SIXTYFPS_DEFAULT_STYLE.txt");
|
33 |
| - std::fs::write(target_path, if has_native_style { b"native\n" as &[u8] } else { b"fluent\n" }) |
34 |
| - .unwrap(); |
| 34 | + std::fs::write( |
| 35 | + style_target_path, |
| 36 | + if has_native_style { b"native\n" as &[u8] } else { b"fluent\n" }, |
| 37 | + ) |
| 38 | + .unwrap(); |
| 39 | + |
| 40 | + let mut link_flags = String::new(); |
| 41 | + |
| 42 | + for backend in ["GL", "QT"] { |
| 43 | + if let Ok(args) = |
| 44 | + std::env::var(format!("DEP_SIXTYFPS_RENDERING_BACKEND_{}_LINK_ARGS", backend)) |
| 45 | + { |
| 46 | + for arg in args.split('|') { |
| 47 | + write!(&mut link_flags, "cargo:rustc-link-arg={}\n", arg).unwrap(); |
| 48 | + } |
| 49 | + } |
| 50 | + if let Ok(args) = |
| 51 | + std::env::var(format!("DEP_SIXTYFPS_RENDERING_BACKEND_{}_LINK_SEARCH_PATHS", backend)) |
| 52 | + { |
| 53 | + for arg in args.split('|') { |
| 54 | + write!(&mut link_flags, "cargo:rustc-link-search={}\n", arg).unwrap(); |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + let link_flags_target_path = std::path::Path::new(&out_dir) |
| 60 | + .parent() |
| 61 | + .unwrap() |
| 62 | + .parent() |
| 63 | + .unwrap() |
| 64 | + .join("SIXTYFPS_BACKEND_LINK_FLAGS.txt"); |
| 65 | + std::fs::write(link_flags_target_path, link_flags).unwrap(); |
35 | 66 | }
|
0 commit comments