Last active
December 19, 2015 13:48
-
-
Save back2dos/5964415 to your computer and use it in GitHub Desktop.
Store build information in metadata.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
import haxe.rtti.Meta; | |
typedef BuildInfo = { | |
date: Date, | |
} | |
class Build { | |
static public var info(get, null):BuildInfo; | |
static function get_info() { | |
if (info == null) { | |
var meta = Meta.getType(Build); | |
info = { | |
date: Date.fromTime(meta.date[0]) | |
} | |
} | |
return info; | |
} | |
#if macro | |
static public function storeInfo() { | |
switch haxe.macro.Context.getType('Build') { | |
case TInst(cl, _): | |
var cl = cl.get(); | |
var m = cl.meta; | |
if (m.has('info')) | |
m.remove('info'); | |
m.add('date', [macro $v{Date.now().getTime()}], cl.pos); | |
default: throw 'assert'; | |
} | |
} | |
#end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment