1 // Copyright 2023 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 use std::env;
6 use std::path::PathBuf;
7
main()8 fn main() {
9 #[cfg(windows)]
10 main_windows();
11
12 #[cfg(any(target_os = "android", target_os = "linux"))]
13 main_unix();
14
15 // TODO: enable once Perfetto is in third_party/perfetto.
16 /*
17 let proto_files = vec![proto_path(&["config", "perfetto_config.proto"])];
18 let mut out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR env does not exist."));
19 out_dir.push("perfetto_protos");
20 proto_build_tools::build_protos(&out_dir, proto_files.as_slice());
21 */
22 }
23
24 #[cfg(windows)]
main_windows()25 fn main_windows() {
26 // TODO: enable once we have Perfetto libraries available on Windows,
27 // download them with prebuilts::download_prebuilts.
28 //
29 // Ideally paths will be identical in the long term and we
30 // can have a single version of this code.
31 /*
32 println!("cargo:rustc-link-lib=dylib=cperfetto");
33 #[cfg(debug_assertions)]
34 println!("cargo:rustc-link-search=..\\..\\libs\\debug");
35 #[cfg(all(windows, not(debug_assertions)))]
36 println!("cargo:rustc-link-search=..\\..\\libs\\release");
37 */
38 }
39
40 #[cfg(any(target_os = "android", target_os = "linux"))]
main_unix()41 fn main_unix() {
42 // TODO: enable once we have Perfetto libraries available on unix. We may
43 // want to use a prebuilt here too, in which case this would be identical
44 // to the Windows version above. The paths will need to be adjusted to
45 // wherever we make the Perfetto binary available.
46 /*
47 println!("cargo:rustc-link-lib=dylib=cperfetto");
48 #[cfg(debug_assertions)]
49 println!("cargo:rustc-link-search=../../libs/debug");
50 #[cfg(not(debug_assertions))]
51 println!("cargo:rustc-link-search=../../libs/release");
52 */
53 }
54
55 #[allow(dead_code)]
proto_path(path: &[&str]) -> PathBuf56 fn proto_path(path: &[&str]) -> PathBuf {
57 let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
58 let mut full_path = manifest_dir;
59 full_path.extend(["..", "third_party", "perfetto", "protos", "perfetto"]);
60 full_path.extend(path);
61 full_path
62 }
63