mirror of
https://github.com/jht5945/buildj.git
synced 2025-12-27 09:20:03 +08:00
fix: fix github
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -87,7 +87,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "buildj"
|
name = "buildj"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs 3.0.1",
|
"dirs 3.0.1",
|
||||||
"json",
|
"json",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "buildj"
|
name = "buildj"
|
||||||
version = "0.1.6"
|
version = "0.1.7"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
homepage = "https://buildj.ruststack.org/"
|
homepage = "https://buildj.ruststack.org/"
|
||||||
|
|||||||
5
build.rs
5
build.rs
@@ -2,10 +2,7 @@ use std::process::Command;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
|
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
|
||||||
let mut git_hash = String::from_utf8(output.stdout).unwrap();
|
let git_hash = String::from_utf8(output.stdout).unwrap();
|
||||||
if git_hash.is_empty() {
|
|
||||||
git_hash = "0000000000000000000000000000000000000000".to_string();
|
|
||||||
}
|
|
||||||
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
|
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
|
||||||
let date_output = Command::new("date").args(&["+%Y-%m-%dT%H:%M:%S%z"]).output().unwrap();
|
let date_output = Command::new("date").args(&["+%Y-%m-%dT%H:%M:%S%z"]).output().unwrap();
|
||||||
let date = String::from_utf8(date_output.stdout).unwrap();
|
let date = String::from_utf8(date_output.stdout).unwrap();
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
use std::{env, fs::{self, File}, io::{Read, ErrorKind}, path::Path, process::Command};
|
use std::env;
|
||||||
use rust_util::{XResult, new_box_ioerror, util_io::{self, DEFAULT_BUF_SIZE, PrintStatusContext}};
|
use std::path::Path;
|
||||||
|
use std::process::Command;
|
||||||
|
use std::fs::{self, File};
|
||||||
|
use std::io::{Read, ErrorKind};
|
||||||
|
use rust_util::{XResult, new_box_ioerror};
|
||||||
|
use rust_util::util_io::{self, DEFAULT_BUF_SIZE, PrintStatusContext};
|
||||||
use crypto::{digest::Digest, md5::Md5, sha1::Sha1, sha2::{Sha256, Sha512}};
|
use crypto::{digest::Digest, md5::Md5, sha1::Sha1, sha2::{Sha256, Sha512}};
|
||||||
|
|
||||||
pub fn get_args_as_vec() -> Vec<String> {
|
pub fn get_args_as_vec() -> Vec<String> {
|
||||||
@@ -40,7 +45,7 @@ pub fn calc_sha256(d: &[u8]) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn calc_file_digest(digest: &mut dyn Digest, digest_alg: &str, file_name: &str) -> XResult<String> {
|
pub fn calc_file_digest(digest: &mut dyn Digest, digest_alg: &str, file_name: &str) -> XResult<String> {
|
||||||
let mut buf: [u8; DEFAULT_BUF_SIZE] = [0u8; DEFAULT_BUF_SIZE];
|
let mut buf = [0u8; DEFAULT_BUF_SIZE];
|
||||||
let mut f = File::open(file_name)?;
|
let mut f = File::open(file_name)?;
|
||||||
let file_len = f.metadata().map(|md| md.len() as i64).unwrap_or(-1_i64);
|
let file_len = f.metadata().map(|md| md.len() as i64).unwrap_or(-1_i64);
|
||||||
let mut print_status_context = PrintStatusContext::default();
|
let mut print_status_context = PrintStatusContext::default();
|
||||||
|
|||||||
33
src/main.rs
33
src/main.rs
@@ -1,9 +1,6 @@
|
|||||||
#[macro_use]
|
#[macro_use] extern crate json;
|
||||||
extern crate json;
|
#[macro_use] extern crate lazy_static;
|
||||||
#[macro_use]
|
#[macro_use] extern crate rust_util;
|
||||||
extern crate lazy_static;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate rust_util;
|
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@@ -16,17 +13,12 @@ pub mod tool;
|
|||||||
pub mod build_json;
|
pub mod build_json;
|
||||||
pub mod misc;
|
pub mod misc;
|
||||||
|
|
||||||
use rust_util::util_cmd::run_command_and_wait;
|
use rust_util::util_cmd;
|
||||||
use tool::*;
|
use tool::*;
|
||||||
use jdk::*;
|
use jdk::*;
|
||||||
use build_json::*;
|
use build_json::*;
|
||||||
use misc::*;
|
use misc::*;
|
||||||
|
|
||||||
const BUILDJ: &str = "buildj";
|
|
||||||
const BUDERJ_VER: &str = env!("CARGO_PKG_VERSION");
|
|
||||||
const GIT_HASH: &str = env!("GIT_HASH");
|
|
||||||
const BUILD_DATE: &str = env!("BUILD_DATE");
|
|
||||||
|
|
||||||
|
|
||||||
fn do_with_buildin_arg_java(first_arg: &str, args: &[String]) {
|
fn do_with_buildin_arg_java(first_arg: &str, args: &[String]) {
|
||||||
let ver = &first_arg[7..];
|
let ver = &first_arg[7..];
|
||||||
@@ -44,7 +36,7 @@ fn do_with_buildin_arg_java(first_arg: &str, args: &[String]) {
|
|||||||
if args.len() > 2 {
|
if args.len() > 2 {
|
||||||
cmd.args(&args[2..]);
|
cmd.args(&args[2..]);
|
||||||
}
|
}
|
||||||
if let Err(err) = run_command_and_wait(&mut cmd) {
|
if let Err(err) = util_cmd::run_command_and_wait(&mut cmd) {
|
||||||
failure!("Exec java failed: {}", err);
|
failure!("Exec java failed: {}", err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -125,7 +117,7 @@ fn do_with_buildin_arg_builder(first_arg: &str, args: &[String], builder_name: &
|
|||||||
for arg in args.iter().skip(from_index) {
|
for arg in args.iter().skip(from_index) {
|
||||||
cmd.arg(&arg);
|
cmd.arg(&arg);
|
||||||
}
|
}
|
||||||
if let Err(err) = run_command_and_wait(&mut cmd) {
|
if let Err(err) = util_cmd::run_command_and_wait(&mut cmd) {
|
||||||
failure!("Run build command failed: {}", err);
|
failure!("Run build command failed: {}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,7 +150,7 @@ fn do_with_buildin_arg_ddd(first_arg: &str, args: &[String]) {
|
|||||||
if *VERBOSE {
|
if *VERBOSE {
|
||||||
debugging!("Running cmd: {}, args: {:?}", &cmd_name, cmd_args);
|
debugging!("Running cmd: {}, args: {:?}", &cmd_name, cmd_args);
|
||||||
}
|
}
|
||||||
if let Err(err) = run_command_and_wait(&mut cmd) {
|
if let Err(err) = util_cmd::run_command_and_wait(&mut cmd) {
|
||||||
failure!("Run xRun command failed: {}", err);
|
failure!("Run xRun command failed: {}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,10 +307,15 @@ fn read_build_json_object() -> Option<json::JsonValue> {
|
|||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
information!("{} - version {} - {}", BUILDJ, BUDERJ_VER, &GIT_HASH[0..7]);
|
match get_short_git_hash() {
|
||||||
|
None => information!("{} - version {}", BUILDJ, BUDERJ_VER),
|
||||||
|
Some(shot_git_hash) => information!("{} - version {} - {}", BUILDJ, BUDERJ_VER, &shot_git_hash),
|
||||||
|
}
|
||||||
|
|
||||||
if *VERBOSE {
|
if *VERBOSE {
|
||||||
debugging!("Full GIT_HASH: {}", GIT_HASH);
|
if let Some(full_git_hash) = get_full_git_hash() {
|
||||||
|
debugging!("Full GIT_HASH: {}", full_git_hash);
|
||||||
|
}
|
||||||
debugging!("Build date: {}", BUILD_DATE);
|
debugging!("Build date: {}", BUILD_DATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +371,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
debugging!("-----END ENVIRONMENT VARIABLES-----");
|
debugging!("-----END ENVIRONMENT VARIABLES-----");
|
||||||
}
|
}
|
||||||
let exit_status = run_command_and_wait(&mut cmd).unwrap_or_else(|err| {
|
let exit_status = util_cmd::run_command_and_wait(&mut cmd).unwrap_or_else(|err| {
|
||||||
failure!("Run build command failed: {}", err);
|
failure!("Run build command failed: {}", err);
|
||||||
process::exit(-1);
|
process::exit(-1);
|
||||||
});
|
});
|
||||||
|
|||||||
24
src/misc.rs
24
src/misc.rs
@@ -2,6 +2,12 @@ use std::env;
|
|||||||
use rust_util::util_env;
|
use rust_util::util_env;
|
||||||
use rust_util::util_term;
|
use rust_util::util_term;
|
||||||
|
|
||||||
|
pub const BUILDJ: &str = "buildj";
|
||||||
|
pub const BUDERJ_VER: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
pub const BUILD_DATE: &str = env!("BUILD_DATE");
|
||||||
|
const GIT_HASH: &str = env!("GIT_HASH");
|
||||||
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref VERBOSE: bool = util_env::is_env_on("BUILDJ_VERBOSE");
|
pub static ref VERBOSE: bool = util_env::is_env_on("BUILDJ_VERBOSE");
|
||||||
pub static ref NOAUTH: bool = util_env::is_env_on("BUILDJ_NOAUTH");
|
pub static ref NOAUTH: bool = util_env::is_env_on("BUILDJ_NOAUTH");
|
||||||
@@ -17,18 +23,26 @@ pub fn print_usage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_version() {
|
pub fn print_version() {
|
||||||
println!(r#"buildj {} - {}
|
println!(r#"buildj {}{}{}
|
||||||
Full git commit hash: {}{}{}
|
Build date: {}
|
||||||
|
|
||||||
Copyright (C) 2019-{} Hatter Jiang.
|
Copyright (C) 2019-{} Hatter Jiang.
|
||||||
License MIT <{}https://opensource.org/licenses/MIT{}>
|
License MIT <{}https://opensource.org/licenses/MIT{}>
|
||||||
|
|
||||||
Official website: {}https://buildj.ruststack.org/{}
|
Official website: {}https://buildj.ruststack.org/{}
|
||||||
"#, super::BUDERJ_VER,
|
"#, BUDERJ_VER,
|
||||||
&super::GIT_HASH[0..7],
|
get_short_git_hash().map(|h| format!(" - {}", h)).unwrap_or("".into()),
|
||||||
util_term::BOLD, &super::GIT_HASH, util_term::END,
|
get_full_git_hash().map(|h| format!("\nFull git commit hash: {}{}{}", util_term::BOLD, h, util_term::END)).unwrap_or("".into()),
|
||||||
|
BUILD_DATE,
|
||||||
*BUILD_YEAR,
|
*BUILD_YEAR,
|
||||||
util_term::UNDER, util_term::END,
|
util_term::UNDER, util_term::END,
|
||||||
util_term::UNDER, util_term::END);
|
util_term::UNDER, util_term::END);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_full_git_hash() -> Option<&'static str> {
|
||||||
|
iff!(GIT_HASH.is_empty(), None, Some(GIT_HASH))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_short_git_hash() -> Option<&'static str> {
|
||||||
|
get_full_git_hash().map(|h| &h[0..7])
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user