forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
51
Kha/Backends/Kinc-hxcpp/khacpp/tools/version/Write.hx
Normal file
51
Kha/Backends/Kinc-hxcpp/khacpp/tools/version/Write.hx
Normal file
@ -0,0 +1,51 @@
|
||||
import sys.io.File;
|
||||
|
||||
class Write
|
||||
{
|
||||
public static function main()
|
||||
{
|
||||
var args = Sys.args();
|
||||
var buildNumber = Std.parseInt(args[0]);
|
||||
if (buildNumber<1 || buildNumber==null)
|
||||
throw "Usage: Write buildNumber";
|
||||
|
||||
|
||||
var jsonFile = "haxelib.json";
|
||||
var lines = File.getContent(jsonFile).split("\n");
|
||||
var idx = 0;
|
||||
var versionMatch = ~/(.*"version"\s*:\s*")(.*)(".*)/;
|
||||
var found = false;
|
||||
var newVersion = "";
|
||||
while(idx<lines.length)
|
||||
{
|
||||
if (versionMatch.match(lines[idx]))
|
||||
{
|
||||
var parts = versionMatch.matched(2).split(".");
|
||||
if (parts.length==3)
|
||||
parts[2] = buildNumber+"";
|
||||
else
|
||||
parts.push(buildNumber+"");
|
||||
newVersion = parts.join(".");
|
||||
lines[idx]=versionMatch.matched(1) + newVersion + versionMatch.matched(3);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
if (!found)
|
||||
throw "Could not find version in " + jsonFile;
|
||||
|
||||
File.saveContent(jsonFile, lines.join("\n") );
|
||||
|
||||
var writeVersionFilename = "include/HxcppVersion.h";
|
||||
var define = "HXCPP_VERSION";
|
||||
var lines = [
|
||||
'#ifndef $define',
|
||||
'#define $define "$newVersion"',
|
||||
'#endif'
|
||||
];
|
||||
File.saveContent( writeVersionFilename, lines.join("\n") );
|
||||
|
||||
Sys.println("hxcpp_release=" + newVersion );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user