use new lib: compiletime
This commit is contained in:
parent
ec63a65ba3
commit
16b7db779f
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
--library cctweaked:git:https://git.kapelle.org/niklas/cctweaked-haxelib.git
|
--library cctweaked:git:https://git.kapelle.org/niklas/cctweaked-haxelib.git
|
||||||
--library tink_core
|
--library tink_core
|
||||||
|
--library compiletime
|
||||||
|
|
||||||
--dce full
|
--dce full
|
||||||
|
|
||||||
|
@ -7,36 +7,21 @@ class BuildInfo {
|
|||||||
/**
|
/**
|
||||||
Get the latest git commit.
|
Get the latest git commit.
|
||||||
**/
|
**/
|
||||||
public static macro function getGitCommitHash():haxe.macro.Expr.ExprOf<String> {
|
public static function getGitCommitHash():String {
|
||||||
#if !display
|
#if !display
|
||||||
var process = new sys.io.Process('git', ['rev-parse', 'HEAD']);
|
return CompileTime.buildGitCommitSha();
|
||||||
if (process.exitCode() != 0) {
|
|
||||||
var message = process.stderr.readAll().toString();
|
|
||||||
var pos = haxe.macro.Context.currentPos();
|
|
||||||
haxe.macro.Context.error("Cannot execute `git rev-parse HEAD`. " + message, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// read the output of the process
|
|
||||||
var commitHash:String = process.stdout.readLine();
|
|
||||||
|
|
||||||
// Generates a string expression
|
|
||||||
return macro $v{commitHash};
|
|
||||||
#else
|
|
||||||
// `#if display` is used for code completion. In this case returning an
|
|
||||||
// empty string is good enough; We don't want to call git on every hint.
|
|
||||||
var commitHash:String = "";
|
|
||||||
return macro $v{commitHash};
|
|
||||||
#end
|
#end
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the time the file was build.
|
Get the time the file was build.
|
||||||
**/
|
**/
|
||||||
public static macro function buildTime():haxe.macro.Expr.ExprOf<Int> {
|
public static function buildTime():Date {
|
||||||
#if !display
|
#if !display
|
||||||
return macro $v{Math.floor(Date.now().getTime())};
|
return CompileTime.buildDate();
|
||||||
#else
|
#else
|
||||||
return macro $v{0};
|
return 0;
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,7 @@ class Debug {
|
|||||||
public static function printBuildInfo() {
|
public static function printBuildInfo() {
|
||||||
Log.debug("Commit: " + BuildInfo.getGitCommitHash());
|
Log.debug("Commit: " + BuildInfo.getGitCommitHash());
|
||||||
|
|
||||||
var time:Date = Date.fromTime(BuildInfo.buildTime());
|
Log.debug("Build time: " + BuildInfo.buildTime().toString());
|
||||||
|
|
||||||
Log.debug("Build time: " + time.toString());
|
|
||||||
|
|
||||||
Log.debug("CC/MC version:" + ComputerCraft._HOST);
|
Log.debug("CC/MC version:" + ComputerCraft._HOST);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user