1 Star 0 Fork 4

master-gitee/tikv

forked from goroutine/tikv 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
build.rs 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
overvenus 提交于 2016-08-23 18:31 . *: add version information (#952)
// Copyright 2016 PingCAP, Inc.
//
// 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,
// See the License for the specific language governing permissions and
// limitations under the License.
extern crate time;
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use std::process::Command;
fn main() {
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out_dir.join("build-info.txt"))
.unwrap()
.write_all(build_info().as_bytes())
.unwrap();
}
// build_info returns a string of commit hash and utc time.
fn build_info() -> String {
// explicit separates outputs by '\n'.
format!("{}\n{}", commit_hash().trim_right(), utc_time())
}
fn utc_time() -> String {
let utc = time::now_utc();
format!("{}", utc.strftime("%Y-%m-%d %I:%M:%S").unwrap())
}
fn commit_hash() -> String {
let mut cmd = Command::new("git");
cmd.args(&["rev-parse", "HEAD"]);
cmd.output().ok().and_then(|o| String::from_utf8(o.stdout).ok()).unwrap_or("None".to_owned())
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Rust
1
https://gitee.com/master-gitee/tikv.git
git@gitee.com:master-gitee/tikv.git
master-gitee
tikv
tikv
master

搜索帮助