| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
local arg = {...} |
| 9 |
local FILE_ROLLING_H = arg[1] or "luajit_rolling.h" |
| 10 |
local FILE_RELVER_TXT = arg[2] or "luajit_relver.txt" |
| 11 |
local FILE_LUAJIT_H = arg[3] or "luajit.h" |
| 12 |
|
| 13 |
local function file_read(file) |
| 14 |
local fp = assert(io.open(file, "rb"), "run from the wrong directory") |
| 15 |
local data = assert(fp:read("*a")) |
| 16 |
fp:close() |
| 17 |
return data |
| 18 |
end |
| 19 |
|
| 20 |
local function file_write_mod(file, data) |
| 21 |
local fp = io.open(file, "rb") |
| 22 |
if fp then |
| 23 |
local odata = assert(fp:read("*a")) |
| 24 |
fp:close() |
| 25 |
if odata == data then return end |
| 26 |
end |
| 27 |
fp = assert(io.open(file, "wb")) |
| 28 |
assert(fp:write(data)) |
| 29 |
assert(fp:close()) |
| 30 |
end |
| 31 |
|
| 32 |
local text = file_read(FILE_ROLLING_H):gsub("#error.-\n", "") |
| 33 |
local relver = file_read(FILE_RELVER_TXT):match("(%d+)") |
| 34 |
|
| 35 |
if relver then |
| 36 |
text = text:gsub("ROLLING", relver) |
| 37 |
else |
| 38 |
io.stderr:write([[ |
| 39 |
**** WARNING Cannot determine rolling release version from git log. |
| 40 |
**** WARNING The 'git' command must be available during the build. |
| 41 |
]]) |
| 42 |
file_write_mod(FILE_RELVER_TXT, "ROLLING\n") |
| 43 |
end |
| 44 |
|
| 45 |
file_write_mod(FILE_LUAJIT_H, text) |