Lines Matching +full:generate +full:- +full:env
9 use std::env;
18 #[path = "../../bindgen-cli/options.rs"]
25 fn rustfmt(source: String) -> (String, String) { in rustfmt()
29 if env::var_os("RUSTFMT").is_some() { in rustfmt()
35 p.args(["run", "nightly", "rustfmt", "--version"]); in rustfmt()
53 $ rustup component add rustfmt --toolchain nightly in rustfmt()
59 let mut child = match env::var_os("RUSTFMT") { in rustfmt()
70 "--config-path", in rustfmt()
71 concat!(env!("CARGO_MANIFEST_DIR"), "/tests/rustfmt.toml"), in rustfmt()
99 // Ignore actual rustfmt status because it is often non-zero for trivial in rustfmt()
109 .expect("rustfmt should only emit valid utf-8"); in rustfmt()
119 fn should_overwrite_expected() -> bool { in should_overwrite_expected()
120 if let Some(var) = env::var_os("BINDGEN_OVERWRITE_EXPECTED") { in should_overwrite_expected()
136 ) -> Result<(), Error> { in error_diff_mismatch()
138 println!("--- expected: {:?}", filename); in error_diff_mismatch()
145 diff::Result::Left(l) => println!("-{}", l), in error_diff_mismatch()
157 if let Some(var) = env::var_os("BINDGEN_TESTS_DIFFTOOL") { in error_diff_mismatch()
158 //usecase: var = "meld" -> You can hand check differences in error_diff_mismatch()
164 PathBuf::from(env::var("OUT_DIR").unwrap()).join(name); in error_diff_mismatch()
179 ) -> Result<(), Error> { in compare_generated_header()
198 expectation.push("libclang-9"); in compare_generated_header()
200 expectation.push("libclang-5"); in compare_generated_header()
203 None => expectation.push("libclang-9"), in compare_generated_header()
215 expectation.push(format!("libclang-{}", version_str)); in compare_generated_header()
249 // We skip the generate() error here so we get a full diff below in compare_generated_header()
250 let (actual, rustfmt_stderr) = match builder.generate() { in compare_generated_header()
290 fn builder() -> Builder { in builder()
306 ) -> Result<(Builder, Option<BuilderState>), Error> { in into_builder()
326 fn create_bindgen_builder(header: &Path) -> Result<BuilderState, Error> { in create_bindgen_builder()
333 // Scoop up bindgen-flags from test header in create_bindgen_builder()
343 if line.contains("bindgen-flags: ") { in create_bindgen_builder()
345 .split("bindgen-flags: ") in create_bindgen_builder()
350 } else if line.contains("bindgen-osx-only") { in create_bindgen_builder()
351 let prepend_flags = ["--raw-line", "#![cfg(target_os=\"macos\")]"]; in create_bindgen_builder()
357 } else if line.contains("bindgen-parse-callbacks: ") { in create_bindgen_builder()
359 line.split("bindgen-parse-callbacks: ").last().unwrap(); in create_bindgen_builder()
365 // We make the default target as x86_64-unknown-linux in create_bindgen_builder()
366 if flags.iter().all(|flag| !flag.starts_with("--target=")) { in create_bindgen_builder()
367 if !flags.iter().any(|flag| flag == "--") { in create_bindgen_builder()
368 flags.push("--".into()); in create_bindgen_builder()
370 flags.push("--target=x86_64-unknown-linux".into()); in create_bindgen_builder()
373 // Fool builder_from_flags() into believing it has real env::args_os... in create_bindgen_builder()
374 // - add "bindgen" as executable name 0th element in create_bindgen_builder()
375 // - add header filename as 1st element in create_bindgen_builder()
376 // - prepend raw lines so they're in the right order for expected output in create_bindgen_builder()
377 // - append the test header's bindgen flags in create_bindgen_builder()
386 "--no-rustfmt-bindings", in create_bindgen_builder()
387 "--with-derive-default", in create_bindgen_builder()
388 "--disable-header-comment", in create_bindgen_builder()
389 "--vtable-generation", in create_bindgen_builder()
391 "--raw-line", in create_bindgen_builder()
393 "--raw-line", in create_bindgen_builder()
395 "--raw-line", in create_bindgen_builder()
421 env::var_os("BINDGEN_DISABLE_ROUNDTRIP_TEST").is_none();
433 include!(concat!(env!("OUT_DIR"), "/tests.rs"));
438 std::env::set_var( in test_clang_env_args()
440 "-D_ENV_ONE=1 -D_ENV_TWO=\"2 -DNOT_THREE=1\"", in test_clang_env_args()
450 .generate() in test_clang_env_args()
476 .clang_arg("--target=x86_64-unknown-linux") in test_header_contents()
477 .generate() in test_header_contents()
486 pub fn foo(a: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; in test_header_contents()
499 env!("CARGO_MANIFEST_DIR"), in test_multiple_header_calls_in_builder()
502 .header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/char.h")) in test_multiple_header_calls_in_builder()
503 .clang_arg("--target=x86_64-unknown-linux") in test_multiple_header_calls_in_builder()
504 .generate() in test_multiple_header_calls_in_builder()
512 env!("CARGO_MANIFEST_DIR"), in test_multiple_header_calls_in_builder()
516 env!("CARGO_MANIFEST_DIR"), in test_multiple_header_calls_in_builder()
538 .clang_arg("--target=x86_64-unknown-linux") in test_multiple_header_contents()
539 .generate() in test_multiple_header_contents()
548 pub fn foo2(b: *const ::std::os::raw::c_char) -> f32; in test_multiple_header_contents()
551 pub fn foo(a: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; in test_multiple_header_contents()
564 env!("CARGO_MANIFEST_DIR"), in test_mixed_header_and_header_contents()
567 .header(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/char.h")) in test_mixed_header_and_header_contents()
570 .clang_arg("--target=x86_64-unknown-linux") in test_mixed_header_and_header_contents()
571 .generate() in test_mixed_header_and_header_contents()
579 env!("CARGO_MANIFEST_DIR"), in test_mixed_header_and_header_contents()
583 env!("CARGO_MANIFEST_DIR"), in test_mixed_header_and_header_contents()
604 assert!(Command::new("../ci/no-includes.sh") in no_system_header_includes()
605 .current_dir(env!("CARGO_MANIFEST_DIR")) in no_system_header_includes()
607 .expect("should spawn ../ci/no-includes.sh OK") in no_system_header_includes()
609 .expect("should wait for ../ci/no-includes OK") in no_system_header_includes()
615 let header = PathBuf::from("tests/headers/enum-default-rust.h"); in emit_depfile()
616 let expected_depfile = PathBuf::from(env!("CARGO_MANIFEST_DIR")) in emit_depfile()
620 .join("enum-default-rust.d"); in emit_depfile()
624 "tests/expectations/tests/enum-default-rust.rs", in emit_depfile()
629 env::var_os("BINDGEN_DISABLE_ROUNDTRIP_TEST").is_none(); in emit_depfile()
632 let _bindings = builder.generate().unwrap(); in emit_depfile()
642 concat!(env!("CARGO_MANIFEST_DIR"), "/tests/headers/arg_keyword.hpp"); in dump_preprocessed_input()
644 env!("CARGO_MANIFEST_DIR"), in dump_preprocessed_input()
645 "/tests/headers/cpp-empty-layout.hpp" in dump_preprocessed_input()
654 fn slurp(p: &str) -> String { in dump_preprocessed_input()
671 "cpp-empty-layout.hpp is in the preprocessed file" in dump_preprocessed_input()
678 env!("CARGO_MANIFEST_DIR"), in allowlist_warnings()
685 .generate() in allowlist_warnings()
686 .expect("unable to generate bindings"); in allowlist_warnings()
705 builder.generate().expect("failed to generate bindings"); in build_flags_output_helper()
713 .header("tests/headers/16-byte-alignment.h"); in commandline_multiple_headers()
727 PathBuf::from(env::var("OUT_DIR").unwrap()).join("wrap_static_fns"); in test_wrap_static_fns()
731 .header("tests/headers/wrap-static-fns.h") in test_wrap_static_fns()
734 .generate() in test_wrap_static_fns()
735 .expect("Failed to generate bindings"); in test_wrap_static_fns()