2020-01-20 14:40:58 +03:00
|
|
|
// Copyright 2020 The Grin Developers
|
2018-03-23 13:28:15 +03:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
//! Build hooks to spit out version+build time info
|
|
|
|
|
2018-12-08 02:59:40 +03:00
|
|
|
use built;
|
|
|
|
|
2018-03-23 13:28:15 +03:00
|
|
|
use std::env;
|
2019-02-21 14:57:45 +03:00
|
|
|
use std::path::PathBuf;
|
2018-08-21 19:52:37 +03:00
|
|
|
use std::process::Command;
|
|
|
|
|
2018-03-23 13:28:15 +03:00
|
|
|
fn main() {
|
2018-08-21 19:52:37 +03:00
|
|
|
// Setting up git hooks in the project: rustfmt and so on.
|
|
|
|
let git_hooks = format!(
|
|
|
|
"git config core.hooksPath {}",
|
|
|
|
PathBuf::from("./.hooks").to_str().unwrap()
|
|
|
|
);
|
|
|
|
|
|
|
|
if cfg!(target_os = "windows") {
|
|
|
|
Command::new("cmd")
|
|
|
|
.args(&["/C", &git_hooks])
|
|
|
|
.output()
|
|
|
|
.expect("failed to execute git config for hooks");
|
|
|
|
} else {
|
|
|
|
Command::new("sh")
|
|
|
|
.args(&["-c", &git_hooks])
|
|
|
|
.output()
|
|
|
|
.expect("failed to execute git config for hooks");
|
|
|
|
}
|
|
|
|
|
2018-08-17 20:51:50 +03:00
|
|
|
// build and versioning information
|
2018-03-23 13:28:15 +03:00
|
|
|
let mut opts = built::Options::default();
|
|
|
|
opts.set_dependencies(true);
|
2018-10-26 03:44:50 +03:00
|
|
|
// don't fail the build if something's missing, may just be cargo release
|
|
|
|
let _ = built::write_built_file_with_opts(
|
2018-03-23 13:28:15 +03:00
|
|
|
&opts,
|
|
|
|
env!("CARGO_MANIFEST_DIR"),
|
|
|
|
format!("{}{}", env::var("OUT_DIR").unwrap(), "/built.rs"),
|
2018-10-26 03:44:50 +03:00
|
|
|
);
|
2018-03-23 13:28:15 +03:00
|
|
|
}
|