2023-08-28 19:03:29 +00:00
|
|
|
package source; // Yeah, I know...
|
|
|
|
|
2024-03-03 04:49:27 +00:00
|
|
|
import sys.FileSystem;
|
|
|
|
import sys.io.File;
|
|
|
|
|
2024-03-17 02:20:22 +00:00
|
|
|
/**
|
|
|
|
* A script which executes after the game is built.
|
|
|
|
*/
|
2023-08-28 19:03:29 +00:00
|
|
|
class Postbuild
|
|
|
|
{
|
2024-03-17 02:20:22 +00:00
|
|
|
static inline final BUILD_TIME_FILE:String = '.build_time';
|
2024-03-03 04:49:27 +00:00
|
|
|
|
2024-03-17 02:20:22 +00:00
|
|
|
static function main():Void
|
2023-08-28 19:03:29 +00:00
|
|
|
{
|
2024-03-03 04:49:27 +00:00
|
|
|
printBuildTime();
|
|
|
|
}
|
|
|
|
|
2024-03-17 02:20:22 +00:00
|
|
|
static function printBuildTime():Void
|
2024-03-03 04:49:27 +00:00
|
|
|
{
|
|
|
|
// 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-03 04:49:27 +00:00
|
|
|
{
|
2024-03-17 02:20:22 +00:00
|
|
|
var fi:sys.io.FileInput = File.read(BUILD_TIME_FILE);
|
2024-03-03 04:49:27 +00:00
|
|
|
var start:Float = fi.readDouble();
|
|
|
|
fi.close();
|
2023-08-28 19:03:29 +00:00
|
|
|
|
2024-03-17 02:20:22 +00:00
|
|
|
sys.FileSystem.deleteFile(BUILD_TIME_FILE);
|
2024-03-03 04:49:27 +00:00
|
|
|
|
2024-03-17 02:20:22 +00:00
|
|
|
var buildTime:Float = roundToTwoDecimals(end - start);
|
2024-03-03 04:49:27 +00:00
|
|
|
|
|
|
|
trace('Build took: ${buildTime} seconds');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-17 02:20:22 +00:00
|
|
|
static function roundToTwoDecimals(value:Float):Float
|
2024-03-03 04:49:27 +00:00
|
|
|
{
|
|
|
|
return Math.round(value * 100) / 100;
|
2023-08-28 19:03:29 +00:00
|
|
|
}
|
|
|
|
}
|