lib, eshi: move version string to evl_version

This commit is contained in:
Philippe Gerum 2019-11-13 10:00:39 +01:00
parent 154e577193
commit d9f26b70b0
11 changed files with 61 additions and 39 deletions

View File

@ -469,7 +469,7 @@ static void dump_gnuplot(time_t duration)
paste_file_in("/proc/version", NULL); paste_file_in("/proc/version", NULL);
paste_file_in("/proc/cmdline", NULL); paste_file_in("/proc/cmdline", NULL);
fprintf(plot_fp, "# libevl version: %s\n", libevl_version_string); fprintf(plot_fp, "# libevl version: %s\n", evl_get_version().version_string);
fprintf(plot_fp, "# sampling period: %u microseconds\n", period); fprintf(plot_fp, "# sampling period: %u microseconds\n", period);
paste_file_in("/sys/devices/virtual/clock/monotonic/gravity", paste_file_in("/sys/devices/virtual/clock/monotonic/gravity",
"clock gravity: "); "clock gravity: ");

View File

@ -14,10 +14,11 @@ PIC_OBJFILES = $(SRCFILES:%.c=$(O_DIR)/%-pic.o)
OBJFILES = $(SRCFILES:%.c=$(O_DIR)/%.o) OBJFILES = $(SRCFILES:%.c=$(O_DIR)/%.o)
DEPFILES = $(SRCFILES:%.c=$(O_DIR)/%.d) DEPFILES = $(SRCFILES:%.c=$(O_DIR)/%.d)
LIB_CPPFLAGS := $(BASE_CPPFLAGS) \ LIB_CPPFLAGS := $(BASE_CPPFLAGS) \
-I. \ -I. \
-I../include/eshi \ -I../include/eshi \
-I../include -I../include \
-I$(O_DIR)
LIB_CFLAGS := $(LIB_CPPFLAGS) $(BASE_CFLAGS) LIB_CFLAGS := $(LIB_CPPFLAGS) $(BASE_CFLAGS)
@ -34,7 +35,8 @@ install: all
$(call inst-cmd,$(ARLIBNAME),$(INSTALL) -D $(O_DIR)/$(ARLIBNAME) $(DESTDIR)/$(libdir)/$(ARLIBNAME)) $(call inst-cmd,$(ARLIBNAME),$(INSTALL) -D $(O_DIR)/$(ARLIBNAME) $(DESTDIR)/$(libdir)/$(ARLIBNAME))
clean clobber mrproper: output-Makefile clean clobber mrproper: output-Makefile
$(Q)$(RM) -f $(PIC_OBJFILES) $(OBJFILES) $(TARGETS) $(O_DIR)/$(DTSONAME) $(DEPFILES) $(Q)$(RM) -f $(O_DIR)/git-stamp.h $(PIC_OBJFILES) $(OBJFILES) \
$(TARGETS) $(O_DIR)/$(DTSONAME) $(DEPFILES)
$(O_DIR)/$(SOLIBNAME): $(PIC_OBJFILES) $(O_DIR)/$(SOLIBNAME): $(PIC_OBJFILES)
$(call ld-cmd,$@,$(CC) -shared -Wl$(comma)-soname$(comma)$(DTSONAME) -o $(@) \ $(call ld-cmd,$@,$(CC) -shared -Wl$(comma)-soname$(comma)$(DTSONAME) -o $(@) \
@ -44,6 +46,9 @@ $(O_DIR)/$(SOLIBNAME): $(PIC_OBJFILES)
$(O_DIR)/$(ARLIBNAME): $(OBJFILES) $(O_DIR)/$(ARLIBNAME): $(OBJFILES)
$(call ar-cmd,$@,$(AR) ru $@ $(OBJFILES)) $(call ar-cmd,$@,$(AR) ru $@ $(OBJFILES))
$(O_DIR)/version-pic.o $(O_DIR)/version.o: override CFLAGS := $(CFLAGS) -DLIBSERIAL=\"$(EVL_SERIAL)\"
version.c: $(O_DIR)/git-stamp.h
$(O_DIR)/%-pic.o: %.c $(O_DIR)/%-pic.o: %.c
$(call cc-pic-cmd,$@,$(CC) $(CFLAGS) -fPIC -c -o $@ $<) $(call cc-pic-cmd,$@,$(CC) $(CFLAGS) -fPIC -c -o $@ $<)

View File

@ -43,11 +43,3 @@ bool eshi_is_initialized(void)
{ {
return init_status == 0; return init_status == 0;
} }
struct evl_version evl_get_version(void)
{
return (struct evl_version){
.api_level = __EVL__,
.abi_level = -1,
};
}

23
eshi/version.c Normal file
View File

@ -0,0 +1,23 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org>
*/
#include <evl/evl.h>
#include "git-stamp.h"
#ifndef GIT_STAMP
#define git_hash ""
#else
#define git_hash " -- " GIT_STAMP
#endif
struct evl_version evl_get_version(void)
{
return (struct evl_version){
.api_level = __EVL__,
.abi_level = -1,
.version_string = "eshi." LIBSERIAL git_hash,
};
}

View File

@ -14,6 +14,7 @@
struct evl_version { struct evl_version {
int api_level; /* libevl.so: __EVL__ */ int api_level; /* libevl.so: __EVL__ */
int abi_level; /* core: EVL_ABI_LEVEL, -1 for ESHI */ int abi_level; /* core: EVL_ABI_LEVEL, -1 for ESHI */
const char *version_string;
}; };
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -25,6 +25,7 @@
struct evl_version { struct evl_version {
int api_level; /* libevl.so: __EVL__ */ int api_level; /* libevl.so: __EVL__ */
int abi_level; /* core: EVL_ABI_LEVEL, -1 for ESHI */ int abi_level; /* core: EVL_ABI_LEVEL, -1 for ESHI */
const char *version_string;
}; };
#ifdef __cplusplus #ifdef __cplusplus
@ -39,8 +40,6 @@ void evl_sigdebug_handler(int sig, siginfo_t *si, void *ctxt);
unsigned int evl_detect_fpu(void); unsigned int evl_detect_fpu(void);
extern const char *libevl_version_string;
struct evl_version evl_get_version(void); struct evl_version evl_get_version(void);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -52,19 +52,6 @@ $(O_DIR)/syscall-pic.o $(O_DIR)/syscall.o: override CFLAGS := $(CFLAGS) -fomit-f
$(O_DIR)/version-pic.o $(O_DIR)/version.o: override CFLAGS := $(CFLAGS) -DLIBSERIAL=\"$(EVL_SERIAL)\" $(O_DIR)/version-pic.o $(O_DIR)/version.o: override CFLAGS := $(CFLAGS) -DLIBSERIAL=\"$(EVL_SERIAL)\"
version.c: $(O_DIR)/git-stamp.h version.c: $(O_DIR)/git-stamp.h
$(O_DIR)/git-stamp.h: git-stamp
@if test -r ../.git; then \
stamp=`git --git-dir=../.git rev-list --abbrev-commit -1 HEAD`; \
if test \! -s $@ || grep -wvq $$stamp $@; then \
date=`git --git-dir=../.git log -1 $$stamp --pretty=format:%ci`; \
echo "#define GIT_STAMP \"#$$stamp ($$date)\"" > $@; \
fi; \
elif test \! -r $@ -o -s $@; then \
$(RM) -f $@ && touch $@; \
fi; true
.PHONY: git-stamp
$(O_DIR)/%-pic.o: %.c $(O_DIR)/%-pic.o: %.c
$(call cc-pic-cmd,$@,$(CC) $(CFLAGS) -fPIC -c -o $@ $<) $(call cc-pic-cmd,$@,$(CC) $(CFLAGS) -fPIC -c -o $@ $<)

View File

@ -251,11 +251,3 @@ unsigned int evl_detect_fpu(void)
return core_info.fpu_features; return core_info.fpu_features;
} }
struct evl_version evl_get_version(void)
{
return (struct evl_version){
.api_level = __EVL__,
.abi_level = EVL_ABI_LEVEL,
};
}

View File

@ -4,6 +4,8 @@
* Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org> * Copyright (C) 2018 Philippe Gerum <rpm@xenomai.org>
*/ */
#include <evl/evl.h>
#include <uapi/evl/control.h>
#include "git-stamp.h" #include "git-stamp.h"
#ifndef GIT_STAMP #ifndef GIT_STAMP
@ -12,4 +14,11 @@
#define git_hash " -- " GIT_STAMP #define git_hash " -- " GIT_STAMP
#endif #endif
const char *libevl_version_string = "evl." LIBSERIAL git_hash; struct evl_version evl_get_version(void)
{
return (struct evl_version){
.api_level = __EVL__,
.abi_level = EVL_ABI_LEVEL,
.version_string = "evl." LIBSERIAL git_hash,
};
}

View File

@ -2,3 +2,16 @@
EVL_SERIAL := 0 EVL_SERIAL := 0
EVL_IVERSION := 0 EVL_IVERSION := 0
$(O_DIR)/git-stamp.h: git-stamp
@if test -r ../.git; then \
stamp=`git --git-dir=../.git rev-list --abbrev-commit -1 HEAD`; \
if test \! -s $@ || grep -wvq $$stamp $@; then \
date=`git --git-dir=../.git log -1 $$stamp --pretty=format:%ci`; \
echo "#define GIT_STAMP \"#$$stamp ($$date)\"" > $@; \
fi; \
elif test \! -r $@ -o -s $@; then \
$(RM) -f $@ && touch $@; \
fi; true
.PHONY: git-stamp

View File

@ -77,7 +77,8 @@ int main(int argc, char *const argv[])
cmddir = optarg; cmddir = optarg;
break; break;
case 'V': case 'V':
printf("%s [ABI %d]\n", libevl_version_string, printf("%s [ABI %d]\n",
evl_get_version().version_string,
EVL_ABI_LEVEL); EVL_ABI_LEVEL);
exit(0); exit(0);
case '?': case '?':