From 4d99690b89bda2814b78f01b88b7833296d47717 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Tue, 27 Sep 2022 23:39:53 +0200 Subject: xS: parse project version from CMakeLists.txt --- liberty | 2 +- xC-gen-proto.awk | 4 ++-- xS/Makefile | 8 ++++++-- xS/xS-gen-version.awk | 14 ++++++++++++++ xS/xS.go | 8 ++------ 5 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 xS/xS-gen-version.awk diff --git a/liberty b/liberty index 34460ca..af2756e 160000 --- a/liberty +++ b/liberty @@ -1 +1 @@ -Subproject commit 34460ca715b295cc73c3f2bba4156c7f072ce122 +Subproject commit af2756ee01fa6b1921c6bcb581817e64c30beb48 diff --git a/xC-gen-proto.awk b/xC-gen-proto.awk index ad375af..9b65a74 100644 --- a/xC-gen-proto.awk +++ b/xC-gen-proto.awk @@ -100,12 +100,12 @@ function nexttoken() { Token = substr($0, 1, RLENGTH) $0 = substr($0, RLENGTH + 1) return Token - } else if (/./) { + } else if ($0) { Token = substr($0, 1, 1) $0 = substr($0, 2) return Token } - } while (/./ || getline > 0) + } while ($0 || getline > 0) Token = "" return Token } diff --git a/xS/Makefile b/xS/Makefile index 55ad4d2..f0f662d 100644 --- a/xS/Makefile +++ b/xS/Makefile @@ -2,11 +2,15 @@ .SUFFIXES: AWK = env LC_ALL=C awk -outputs = xS xS-replies.go +outputs = xS xS-version.go xS-replies.go all: $(outputs) -xS: xS.go xS-replies.go +xS: xS.go xS-version.go xS-replies.go go build -o $@ +xS-version.go: ../liberty/tools/cmake-parser.awk \ + xS-gen-version.awk ../CMakeLists.txt + $(AWK) -f ../liberty/tools/cmake-parser.awk \ + -f xS-gen-version.awk ../CMakeLists.txt > $@ xS-replies.go: xS-gen-replies.awk xS-replies $(AWK) -f xS-gen-replies.awk xS-replies > $@ clean: diff --git a/xS/xS-gen-version.awk b/xS/xS-gen-version.awk new file mode 100644 index 0000000..1312a63 --- /dev/null +++ b/xS/xS-gen-version.awk @@ -0,0 +1,14 @@ +# xS-gen-version.awk: extract version information from the CMake script +# +# Copyright (c) 2022, Přemysl Eric Janouch +# SPDX-License-Identifier: 0BSD + +Command == "project" { + for (i = 2; i in Args; i++) + if (Args[i] == "VERSION") { + print "package main" + print "" + print "const projectVersion = `" Args[++i] "`" + exit + } +} diff --git a/xS/xS.go b/xS/xS.go index e6c3b3c..feefb5c 100644 --- a/xS/xS.go +++ b/xS/xS.go @@ -40,13 +40,9 @@ import ( "time" ) -var debugMode = false +const projectName = "xS" -const ( - projectName = "xS" - // TODO: Consider using the same version number for all subprojects. - projectVersion = "0" -) +var debugMode = false // --- Logging ----------------------------------------------------------------- -- cgit v1.2.3-70-g09d2