diff options
Diffstat (limited to 'src/host')
| -rw-r--r-- | src/host/buildvm.c | 1 | ||||
| -rw-r--r-- | src/host/genversion.lua | 43 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/host/buildvm.c b/src/host/buildvm.c index 6e96bffa..ec99e501 100644 --- a/src/host/buildvm.c +++ b/src/host/buildvm.c | |||
| @@ -329,6 +329,7 @@ static void emit_vmdef(BuildCtx *ctx) | |||
| 329 | #endif | 329 | #endif |
| 330 | int i; | 330 | int i; |
| 331 | fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n"); | 331 | fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n"); |
| 332 | fprintf(ctx->fp, "assert(require(\"jit\").version == \"%s\", \"LuaJIT core/library version mismatch\")\n\n", LUAJIT_VERSION); | ||
| 332 | fprintf(ctx->fp, "return {\n\n"); | 333 | fprintf(ctx->fp, "return {\n\n"); |
| 333 | 334 | ||
| 334 | fprintf(ctx->fp, "bcnames = \""); | 335 | fprintf(ctx->fp, "bcnames = \""); |
diff --git a/src/host/genversion.lua b/src/host/genversion.lua new file mode 100644 index 00000000..a38cec56 --- /dev/null +++ b/src/host/genversion.lua | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | ---------------------------------------------------------------------------- | ||
| 2 | -- Lua script to embed the rolling release version in luajit.h. | ||
| 3 | ---------------------------------------------------------------------------- | ||
| 4 | -- Copyright (C) 2005-2023 Mike Pall. All rights reserved. | ||
| 5 | -- Released under the MIT license. See Copyright Notice in luajit.h | ||
| 6 | ---------------------------------------------------------------------------- | ||
| 7 | |||
| 8 | local FILE_INPUT_H = "luajit_rolling.h" | ||
| 9 | local FILE_INPUT_R = "luajit_relver.txt" | ||
| 10 | local FILE_OUTPUT_H = "luajit.h" | ||
| 11 | |||
| 12 | local function file_read(file) | ||
| 13 | local fp = assert(io.open(file, "rb"), "run from the wrong directory") | ||
| 14 | local data = assert(fp:read("*a")) | ||
| 15 | fp:close() | ||
| 16 | return data | ||
| 17 | end | ||
| 18 | |||
| 19 | local function file_write_mod(file, data) | ||
| 20 | local fp = io.open(file, "rb") | ||
| 21 | if fp then | ||
| 22 | local odata = assert(fp:read("*a")) | ||
| 23 | fp:close() | ||
| 24 | if odata == data then return end | ||
| 25 | end | ||
| 26 | fp = assert(io.open(file, "wb")) | ||
| 27 | assert(fp:write(data)) | ||
| 28 | assert(fp:close()) | ||
| 29 | end | ||
| 30 | |||
| 31 | local text = file_read(FILE_INPUT_H) | ||
| 32 | local relver = file_read(FILE_INPUT_R):match("(%d+)") | ||
| 33 | |||
| 34 | if relver then | ||
| 35 | text = text:gsub("ROLLING", relver) | ||
| 36 | else | ||
| 37 | io.stderr:write([[ | ||
| 38 | **** WARNING Cannot determine rolling release version from git log. | ||
| 39 | **** WARNING The 'git' command must be available during the build. | ||
| 40 | ]]) | ||
| 41 | end | ||
| 42 | |||
| 43 | file_write_mod(FILE_OUTPUT_H, text) | ||
