1 //
2 //  Copyright 2023 Google, Inc.
3 //
4 //  Licensed under the Apache License, Version 2.0 (the "License");
5 //  you may not use this file except in compliance with the License.
6 //  You may obtain a copy of the License at:
7 //
8 //  http://www.apache.org/licenses/LICENSE-2.0
9 //
10 //  Unless required by applicable law or agreed to in writing, software
11 //  distributed under the License is distributed on an "AS IS" BASIS,
12 //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 //  See the License for the specific language governing permissions and
14 //  limitations under the License.
15 
16 use std::env;
17 use std::path::PathBuf;
18 
main()19 fn main() {
20     let _build = cxx_build::bridge("src/ffi.rs");
21     println!("cargo:rerun-if-changed=src/ffi.rs");
22 
23     let prebuilts: [[&str; 2]; 4] = [
24         ["LINK_LAYER_PACKETS_PREBUILT", "link_layer_packets.rs"],
25         ["MAC80211_HWSIM_PACKETS_PREBUILT", "mac80211_hwsim_packets.rs"],
26         ["IEEE80211_PACKETS_PREBUILT", "ieee80211_packets.rs"],
27         ["NETLINK_PACKETS_PREBUILT", "netlink_packets.rs"],
28     ];
29 
30     for [var, name] in prebuilts {
31         let prebuilt = env::var(var).unwrap();
32         println!("cargo:rerun-if-changed={}", prebuilt);
33         let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
34         std::fs::copy(prebuilt.as_str(), out_dir.join(name).as_os_str().to_str().unwrap()).unwrap();
35     }
36 }
37