4cade/bin/buildokvs.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-10-07 00:26:23 +00:00
a = new ActiveXObject("scripting.filesystemobject")
2021-10-12 23:37:45 +00:00
if (!a.fileexists(WScript.Arguments(1)) || a.getfile(WScript.Arguments(1)).datelastmodified < a.getFile(WScript.Arguments(0)).datelastmodified)
2021-10-07 00:26:23 +00:00
{
2021-10-12 23:37:45 +00:00
b = a.opentextfile(WScript.Arguments(0))
2021-10-07 00:26:23 +00:00
2021-10-12 23:37:45 +00:00
entries = []
2021-10-07 00:26:23 +00:00
2021-10-12 23:37:45 +00:00
while (!b.atendofstream)
2021-10-07 00:26:23 +00:00
{
2021-10-12 23:37:45 +00:00
c = b.readline()
d = c.indexOf("#")
if (d >= 0)
{
c = c.substr(0, d)
}
2021-10-25 00:09:29 +00:00
if (c.indexOf("[eof]") >= 0)
2021-10-12 23:37:45 +00:00
{
break
}
if (c.length > 0)
{
entries.push(c)
}
2021-10-07 00:26:23 +00:00
}
2021-10-12 23:37:45 +00:00
source = a.createtextfile("build\\okvs.tmp")
source.writeline("*=0")
source.writeline("!le16 " + entries.length + ", 0")
for (i = 0; i < entries.length; i++)
2021-10-07 00:26:23 +00:00
{
2021-10-12 23:37:45 +00:00
val = entries[i].indexOf("=")
source.writeline("!byte " + (entries[i].length - ((val >= 0) ? 1 : 0) + 3).toString())
source.writeline("!byte " + ((val >= 0) ? val : entries[i].length).toString())
source.writeline("!text \"" + ((val >= 0) ? entries[i].substr(0, val) : entries[i]) + "\"")
source.writeline("!byte " + ((val >= 0) ? (entries[i].length - (val + 1)) : 0).toString())
source.writeline("!text \"" + ((val >= 0) ? (entries[i].substr(val + 1)) : "") + "\"")
2021-10-07 00:26:23 +00:00
}
2021-10-22 06:17:04 +00:00
source.close()
2021-10-15 20:00:40 +00:00
new ActiveXObject("wscript.shell").run('cmd /c %acme% -o ' + WScript.Arguments(1) + ' build\\okvs.tmp', 0, 1)
2021-10-07 00:26:23 +00:00
}