1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-15 19:33:36 +00:00
Funkin/source/Postbuild.hx

41 lines
874 B
Haxe
Raw Normal View History

package source; // Yeah, I know...
import sys.FileSystem;
import sys.io.File;
2024-03-17 02:20:22 +00:00
/**
* A script which executes after the game is built.
*/
class Postbuild
{
2024-03-17 02:20:22 +00:00
static inline final BUILD_TIME_FILE:String = '.build_time';
2024-03-17 02:20:22 +00:00
static function main():Void
{
printBuildTime();
}
2024-03-17 02:20:22 +00:00
static function printBuildTime():Void
{
// get buildEnd before fs operations since they are blocking
var end:Float = Sys.time();
2024-03-17 02:20:22 +00:00
if (FileSystem.exists(BUILD_TIME_FILE))
{
2024-03-17 02:20:22 +00:00
var fi:sys.io.FileInput = File.read(BUILD_TIME_FILE);
var start:Float = fi.readDouble();
fi.close();
2024-03-17 02:20:22 +00:00
sys.FileSystem.deleteFile(BUILD_TIME_FILE);
2024-03-17 02:20:22 +00:00
var buildTime:Float = roundToTwoDecimals(end - start);
trace('Build took: ${buildTime} seconds');
}
}
2024-03-17 02:20:22 +00:00
static function roundToTwoDecimals(value:Float):Float
{
return Math.round(value * 100) / 100;
}
}