xS: parse project version from CMakeLists.txt

This commit is contained in:
Přemysl Eric Janouch 2022-09-27 23:39:53 +02:00
parent 7c74e6615d
commit 4d99690b89
Signed by: p
GPG Key ID: A0420B94F92B9493
5 changed files with 25 additions and 11 deletions

@ -1 +1 @@
Subproject commit 34460ca715b295cc73c3f2bba4156c7f072ce122
Subproject commit af2756ee01fa6b1921c6bcb581817e64c30beb48

View File

@ -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
}

View File

@ -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:

14
xS/xS-gen-version.awk Normal file
View File

@ -0,0 +1,14 @@
# xS-gen-version.awk: extract version information from the CMake script
#
# Copyright (c) 2022, Přemysl Eric Janouch <p@janouch.name>
# 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
}
}

View File

@ -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 -----------------------------------------------------------------