summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--real.make28
-rw-r--r--src/common/version.cpp28
-rw-r--r--src/common/version.hpp47
-rw-r--r--src/conf/version.hpp15
-rw-r--r--version.make17
6 files changed, 93 insertions, 43 deletions
diff --git a/.gitignore b/.gitignore
index 828661d..f3d4750 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
# files generated during make
+/conf-raw/
/obj/
/bin/
# Generated source files
diff --git a/real.make b/real.make
index a456a17..f880889 100644
--- a/real.make
+++ b/real.make
@@ -223,7 +223,7 @@ s: ${ASSEMBLED}
o: ${OBJECTS}
mostlyclean:
- rm -rf obj
+ rm -rf obj conf-raw
clean: mostlyclean
rm -rf bin
distclean: clean
@@ -235,12 +235,10 @@ distclean: clean
%.cpp %.hpp: %.ypp
$(MKDIR_FIRST)
${BISON} -d -o $*.cpp $<
-%.hpp: ;
-# hpp rule is needed for disappearing headers
obj/%.d: src/%.cpp
$(MKDIR_FIRST)
set -o pipefail; \
- ${CXX} ${CPPFLAGS} ${CXXFLAGS} -MM $< \
+ ${CXX} ${CPPFLAGS} ${CXXFLAGS} -MG -MP -MM $< \
-MT '$@ $(patsubst %.d,%.o,$@)' \
| sed -e ':again; s:/[^/ ]*/../:/:; t again' \
-e 's: ${SRC_DIR}/: :g' \
@@ -310,3 +308,25 @@ tags: ${SOURCES} ${HEADERS}
Makefile: ${SRC_DIR}/Makefile.in
@echo Makefile.in updated, you must rerun configure
@false
+
+include ${SRC_DIR}/version.make
+
+# TODO - fix pattern priority bug so I can make these .hpp
+#
+# This is complicated and still isn't optimal.
+conf-raw/int-%.h: FORCE
+ $(MKDIR_FIRST)
+ @grep -s -q '^$(value $*)$$' $@ \
+ || { \
+ echo "#define $* \\"; \
+ echo '$(value $*)'; \
+ } > $@
+conf-raw/str-%.h: FORCE
+ $(MKDIR_FIRST)
+ @grep -s -q '^"$(value $*)"$$' $@ \
+ || { \
+ echo "#define $* \\"; \
+ echo '"$(value $*)"'; \
+ } > $@
+FORCE: ;
+override CPPFLAGS += -I .
diff --git a/src/common/version.cpp b/src/common/version.cpp
new file mode 100644
index 0000000..7f4a0f2
--- /dev/null
+++ b/src/common/version.cpp
@@ -0,0 +1,28 @@
+#include "version.hpp"
+
+#include "../conf/version.hpp"
+
+Version CURRENT_LOGIN_SERVER_VERSION =
+{
+ VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH,
+ VERSION_DEVEL,
+
+ 0, TMWA_SERVER_LOGIN,
+ VENDOR_VERSION,
+};
+Version CURRENT_CHAR_SERVER_VERSION =
+{
+ VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH,
+ VERSION_DEVEL,
+
+ 0, TMWA_SERVER_CHAR | TMWA_SERVER_INTER,
+ VENDOR_VERSION,
+};
+Version CURRENT_MAP_SERVER_VERSION =
+{
+ VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH,
+ VERSION_DEVEL,
+
+ 0, TMWA_SERVER_MAP,
+ VENDOR_VERSION,
+};
diff --git a/src/common/version.hpp b/src/common/version.hpp
index 30c619c..e34ec50 100644
--- a/src/common/version.hpp
+++ b/src/common/version.hpp
@@ -1,14 +1,7 @@
-#ifndef VERSION_HPP
-#define VERSION_HPP
+#ifndef TMWA_COMMON_VERSION_HPP
+#define TMWA_COMMON_VERSION_HPP
-// TODO generate this from ./configure
-// Actually, it should be done from the Makefile
-// it should be possible to use a ./config.status for a long time
-
-# define TMWA_VERSION_MAJOR 13
-# define TMWA_VERSION_MINOR 9
-# define TMWA_VERSION_PATCH 29
-# define TMWA_DEVELOP_FLAG 1
+# include <cstdint>
// TODO make these bitwise enums
# define TMWA_FLAG_REGISTRATION 0x01
@@ -18,9 +11,6 @@
# define TMWA_SERVER_INTER 0x04
# define TMWA_SERVER_MAP 0x08
-# define TMWA_VENDOR "Vanilla"
-# define TMWA_VENDOR_VERSION 0
-
struct Version
{
uint8_t major;
@@ -33,31 +23,10 @@ struct Version
uint16_t vend;
// can't add vendor name yet
};
-static_assert(sizeof(Version) == 8, "this is send over the network, can't change");
-
-constexpr Version CURRENT_LOGIN_SERVER_VERSION =
-{
- TMWA_VERSION_MAJOR, TMWA_VERSION_MINOR, TMWA_VERSION_PATCH,
- TMWA_DEVELOP_FLAG,
+static_assert(sizeof(Version) == 8, "this is sent over the network, can't change");
- 0, TMWA_SERVER_LOGIN,
- TMWA_VENDOR_VERSION,
-};
-constexpr Version CURRENT_CHAR_SERVER_VERSION =
-{
- TMWA_VERSION_MAJOR, TMWA_VERSION_MINOR, TMWA_VERSION_PATCH,
- TMWA_DEVELOP_FLAG,
-
- 0, TMWA_SERVER_CHAR | TMWA_SERVER_INTER,
- TMWA_VENDOR_VERSION,
-};
-constexpr Version CURRENT_MAP_SERVER_VERSION =
-{
- TMWA_VERSION_MAJOR, TMWA_VERSION_MINOR, TMWA_VERSION_PATCH,
- TMWA_DEVELOP_FLAG,
-
- 0, TMWA_SERVER_MAP,
- TMWA_VENDOR_VERSION,
-};
+extern Version CURRENT_LOGIN_SERVER_VERSION;
+extern Version CURRENT_CHAR_SERVER_VERSION;
+extern Version CURRENT_MAP_SERVER_VERSION;
-#endif // VERSION_HPP
+#endif // TMWA_COMMON_VERSION_HPP
diff --git a/src/conf/version.hpp b/src/conf/version.hpp
new file mode 100644
index 0000000..1da6088
--- /dev/null
+++ b/src/conf/version.hpp
@@ -0,0 +1,15 @@
+#ifndef CONF_VERSION_HPP
+#define CONF_VERSION_HPP
+
+#include "conf-raw/str-VERSION_FULL.h"
+#include "conf-raw/str-VERSION_HASH.h"
+
+#include "conf-raw/int-VERSION_MAJOR.h"
+#include "conf-raw/int-VERSION_MINOR.h"
+#include "conf-raw/int-VERSION_PATCH.h"
+#include "conf-raw/int-VERSION_DEVEL.h"
+
+#include "conf-raw/str-VENDOR.h"
+#include "conf-raw/int-VENDOR_VERSION.h"
+
+#endif
diff --git a/version.make b/version.make
new file mode 100644
index 0000000..04ba9c3
--- /dev/null
+++ b/version.make
@@ -0,0 +1,17 @@
+# TODO replace this file in tarballs
+# for now, only git builds will work.
+VERSION_FULL := $(shell cd ${SRC_DIR}; git describe --tags HEAD)
+VERSION_HASH := $(shell cd ${SRC_DIR}; git rev-parse HEAD)
+
+version_bits := $(subst v, ,$(subst -, ,$(subst ., ,${VERSION_FULL})))
+VERSION_MAJOR := $(word 1,${version_bits})
+VERSION_MINOR := $(word 2,${version_bits})
+VERSION_PATCH := $(word 3,${version_bits})
+VERSION_DEVEL := $(word 4,${version_bits})
+ifeq "${VERSION_DEVEL}" ""
+ VERSION_DEVEL := 0
+endif
+VERSION_FULL += $(shell cd ${SRC_DIR}; git diff --quiet HEAD || echo dirty)
+
+VENDOR := Vanilla
+VENDOR_VERSION := 0