blob: 1ede7e3f40cc6d63ad1645b30eef85d2d83524aa [file] [log] [blame]
Brian Silvermancc09f182022-03-09 15:40:20 -08001// Copyright 2020 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14use std::env;
15use std::fs::File;
16use std::io::prelude::*;
17
18fn main() {
19 let bleh = env::var("CARGO_FEATURE_BLEH").unwrap();
20 let some_env = env::var("SOME_ENV").unwrap();
21 let out_dir = env::var("OUT_DIR").unwrap();
22 let data = std::fs::read("test.txt").unwrap();
23 assert!(!bleh.is_empty());
24 assert_eq!(some_env, "42");
25 println!(
26 r#"cargo:rustc-env=FOO=BAR
27cargo:rustc-env=BAR=FOO
28cargo:rustc-flags=--cfg=blah="bleh"
29cargo:rustc-flags=--cfg=data="{}"
30cargo:rustc-cfg=foobar"#,
31 std::str::from_utf8(&data).unwrap()
32 );
33 let mut file = File::create(format!("{}/hello.world.txt", out_dir)).unwrap();
34 file.write_all(b"Hello, world!").unwrap();
35}