From 50e0fa03c48cb9af03c3efdc3100f12687651a2e Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 21 Aug 2023 03:06:26 +0200 Subject: Switch build system to rolling releases. --- src/host/buildvm.c | 1 + src/host/genversion.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/host/genversion.lua (limited to 'src/host') diff --git a/src/host/buildvm.c b/src/host/buildvm.c index ef393ff8..39c2bc24 100644 --- a/src/host/buildvm.c +++ b/src/host/buildvm.c @@ -320,6 +320,7 @@ static void emit_vmdef(BuildCtx *ctx) char buf[80]; int i; fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n"); + fprintf(ctx->fp, "assert(require(\"jit\").version == \"%s\", \"LuaJIT core/library version mismatch\")\n\n", LUAJIT_VERSION); fprintf(ctx->fp, "module(...)\n\n"); 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 @@ +---------------------------------------------------------------------------- +-- Lua script to embed the rolling release version in luajit.h. +---------------------------------------------------------------------------- +-- Copyright (C) 2005-2023 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- + +local FILE_INPUT_H = "luajit_rolling.h" +local FILE_INPUT_R = "luajit_relver.txt" +local FILE_OUTPUT_H = "luajit.h" + +local function file_read(file) + local fp = assert(io.open(file, "rb"), "run from the wrong directory") + local data = assert(fp:read("*a")) + fp:close() + return data +end + +local function file_write_mod(file, data) + local fp = io.open(file, "rb") + if fp then + local odata = assert(fp:read("*a")) + fp:close() + if odata == data then return end + end + fp = assert(io.open(file, "wb")) + assert(fp:write(data)) + assert(fp:close()) +end + +local text = file_read(FILE_INPUT_H) +local relver = file_read(FILE_INPUT_R):match("(%d+)") + +if relver then + text = text:gsub("ROLLING", relver) +else + io.stderr:write([[ +**** WARNING Cannot determine rolling release version from git log. +**** WARNING The 'git' command must be available during the build. +]]) +end + +file_write_mod(FILE_OUTPUT_H, text) -- cgit v1.2.3-55-g6feb