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