| 1 | // SPDX-License-Identifier: Apache-2.0 or MIT |
| 2 | // |
| 3 | // Copyright 2021 Sony Group Corporation |
| 4 | // |
| 5 | |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/; |
| 7 | |
| 8 | const LIBSECCOMP_LIB_PATHrust-analyzer cargo libseccomp-sys 0.3.0 LIBSECCOMP_LIB_PATH.: &str = "LIBSECCOMP_LIB_PATH"; |
| 9 | const LIBSECCOMP_LINK_TYPErust-analyzer cargo libseccomp-sys 0.3.0 LIBSECCOMP_LINK_TYPE.: &str = "LIBSECCOMP_LINK_TYPE"; |
| 10 | |
| 11 | fn mainrust-analyzer cargo libseccomp-sys 0.3.0 main().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> { |
| 12 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("cargo:rerun-if-env-changed={}", LIBSECCOMP_LIB_PATHrust-analyzer cargo libseccomp-sys 0.3.0 LIBSECCOMP_LIB_PATH.); |
| 13 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("cargo:rerun-if-env-changed={}", LIBSECCOMP_LINK_TYPErust-analyzer cargo libseccomp-sys 0.3.0 LIBSECCOMP_LINK_TYPE.); |
| 14 | |
| 15 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(path) = envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().(LIBSECCOMP_LIB_PATHrust-analyzer cargo libseccomp-sys 0.3.0 LIBSECCOMP_LIB_PATH.) { |
| 16 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("cargo:rustc-link-search=native={}", path); |
| 17 | } |
| 18 | |
| 19 | let link_type = match envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().(LIBSECCOMP_LINK_TYPErust-analyzer cargo libseccomp-sys 0.3.0 LIBSECCOMP_LINK_TYPE.) { |
| 20 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(link_type) if link_type rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]eq()."framework" => { |
| 21 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("Seccomp is a Linux specific technology".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 22 | } |
| 23 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(link_type) => link_type, // static or dylib |
| 24 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("dylib"), |
| 25 | }; |
| 26 | |
| 27 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("cargo:rustc-link-lib={}=seccomp", link_type); |
| 28 | |
| 29 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 30 | } |