From c4ba3bd6510434b15b54134a513b618432e09c5a Mon Sep 17 00:00:00 2001 From: Peter M. Groen Date: Mon, 24 Jan 2022 22:41:39 +0100 Subject: [PATCH] Added versioning --- CMakeLists.txt | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.org | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ cmake/osdevversion.cmake | 6 ++++++ osdev_config/customer_config.txt | 26 ++++++++++++++++++++++++++ osdev_config/osdev_config.txt | 19 +++++++++++++++++++ osdev_config/product_config.txt | 28 ++++++++++++++++++++++++++++ osdev_create_version_include.sh | 492 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 826 insertions(+), 0 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 README.org create mode 100644 cmake/osdevversion.cmake create mode 100755 osdev_config/customer_config.txt create mode 100644 osdev_config/osdev_config.txt create mode 100644 osdev_config/product_config.txt create mode 100755 osdev_create_version_include.sh diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..aa2fa33 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,76 @@ +# -*- mode:cmake -*- +# Project to make a simple OSDEV versioned binary +cmake_minimum_required(VERSION 3.0) +project(osdevversion) + +# get the directory containing this cmake script. +set( OSDEV_CURRENT_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR} ) + +# find python +find_package(PythonInterp REQUIRED) +if(NOT PYTHONINTERP_FOUND) + message(FATAL_ERROR "-- Python interpreter not found.") +endif() + +# build option to test OSDEV Version generation +option(OPTION_BUILD_TESTS "Build Caelus Version tests ." OFF) + +# check environment for locations of configurations if not default. +if(NOT OSDEV_PRODUCT_SRC_DIR) + message(FATAL_ERROR "-- ${OSDEV_PRODUCT_SRC_DIR} is not specified.") +endif() + +# set OSDEV_CURRENT_CMAKE_DIR to point to product configuration folder +set(OSDEV_CONFIG_DIR ${OSDEV_CURRENT_CMAKE_DIR}/osdev_config/) + +# Check HSOA Version DIR not overridden by existing environment path +if(EXISTS $ENV{OSDEV_CONFIG_DIR}) + set(OSDEV_CONFIG_DIR $ENV{OSDEV_CONFIG_DIR}) +endif() + +if(EXISTS ${OSDEV_CONFIG_DIR}) + message(STATUS "++ OSDEV_CONFIG_DIR=${OSDEV_CONFIG_DIR}") +else() + message(FATAL_ERROR "-- ${OSDEV_CONFIG_DIR} does not exist") +endif() + +# check for product configuration in environment, otherwise set to default +if(ENV{OSDEV_VERSION_PRODUCT_CONFIG}) + set(OSDEV_VERSION_PRODUCT_CONFIG $ENV{OSDEV_VERSION_PRODUCT_CONFIG}) +elseif(OSDEV_VERSION_PRODUCT_CONFIG) + set(ENV{OSDEV_VERSION_PRODUCT_CONFIG} ${OSDEV_VERSION_PRODUCT_CONFIG}) +else() + set(ENV{OSDEV_VERSION_PRODUCT_CONFIG} ${OSDEV_CONFIG_DIR}/product_config.txt) + set(OSDEV_VERSION_PRODUCT_CONFIG $ENV{OSDEV_VERSION_PRODUCT_CONFIG}) +endif() + +# check product configuration file exists. +if(EXISTS ${OSDEV_VERSION_PRODUCT_CONFIG}) + message(STATUS "++ OSDEV_VERSION_PRODUCT_CONFIG=${OSDEV_VERSION_PRODUCT_CONFIG}") +else() + message(FATAL_ERROR "-- ${OSDEV_VERSION_PRODUCT_CONFIG} does not exist") +endif() + +# set default target paths for header file +set(OSDEV_VERSION_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/osdev_version/) +set(OSDEV_VERSION_HEADER_DIR ${CMAKE_CURRENT_BINARY_DIR}/osdev_version/) +set(OSDEV_VERSION_GENSCRIPT ${OSDEV_CURRENT_CMAKE_DIR}/osdev_create_version_include.sh) + +if(NOT EXISTS ${OSDEV_VERSION_HEADER_FILE}) + message(STATUS "Creating dir ${OSDEV_VERSION_HEADER_DIR}") + FILE(MAKE_DIRECTORY ${OSDEV_VERSION_HEADER_DIR}) + EXECUTE_PROCESS( + COMMAND ${VERSION_GENSCRIPT} ${OSDEV_VERSION_CUSTOMER} ${OSDEV_VERSION_HEADER_DIR} + WORKING_DIRECORY ${OSDEV_PRODUCT_SRC_DIR} + COMMENT "First run of version header generator") +endif() + +execute_process( + COMMAND ${OSDEV_VERSION_GENSCRIPT} ${OSDEV_PRODUCT_SRC_DIR} ${OSDEV_VERSION_HEADER_DIR} + WORKING_DIRECORY ${OSDEV_PRODUCT_SRC_DIR} +) + +include( ${OSDEV_VERSION_HEADER_DIR}/osdev_version.cmake ) + +set(OSDEV_VERSION_INCLUDE_DIR ${OSDEV_VERSION_HEADER_DIR} CACHE STRING "osdev version include dir" FORCE) +set(OSDEV_VERSION_SRC_FILE ${OSDEV_VERSION_HEADER_DIR}/osdev_version.cpp CACHE STRING "osdev version src file" FORCE) diff --git a/README.org b/README.org new file mode 100644 index 0000000..35c8f43 --- /dev/null +++ b/README.org @@ -0,0 +1,179 @@ +# -*- mode: org; mode:auto-revert; -*- +* OSDEV Versioning Tool + +This tool will create the OSDEV version information to embed into the +mLogic products, based on the "OSDEV Component Lifecycle Management v1.x" +specifications + +The core of this approach is based on the DMX versioning tool for +C/C++. The script osdev_create_version_include.sh uses environmental +variables such as OSDEV_SRC_DIR to point to the git repository tree +and configuration files for the component to be versioned. + +There has to be three valid configuration files supplied to the tool to +create a valid component version. + +- mlogic_config.txt + Managed in this repository. This defines the Architecture and Mlogic + release information + +- product_config.txt + Managed in the component repository. This defines the + product/component specific information + +- customer_config.txt + Manage in the build environment. This (if available) defines the + customer specific information for the component. + +See the example configuration files in the osdev_config directory for +more information on the contents. + +* General Usage + This repository should be added as a submodule, or similar to the main + repository. + + Where possible the script defaults to using the configuration files + found in the ${OSDEV_SRC_DIR}/osdev_config folder. + +| Variable | Default if undefined in environment | Description | +|-----------------------+----------------------------------------+------------------------------------------------| +| OSDEV_SRC_DIR | Arg 1 (No Default) | path to component git repository root | +| OSDEV_VERSION_HDR_DIR | Arg 2 (No Default) | output directory for osdev_version file | +| OSDEV_CONFIG_DIR | ${OSDEV_SRC_DIR}/osdev_config | path to component configuration file directory | +| OSDEV_VERSION_PRODUCT | ${OSDEV_CONFIG_DIR}/product_config.txt | product configuration filename | +| OSDEV_VERSION_CUSTOMER | ${OSDEV_CONFIG_DIR}/customer_config.txt | path to customer configuration file | + +- For debugging purposes only: +| OSDEV_GIT_DIR | Directory where script exists (pwd) | path to this git repository | +| OSDEV_VERSION_MLOGIC | ${OSDEV_GIT_DIR}/osdev_config/mlogic_config.txt | Architecture version filename | + +Note for Yocto/McGraw Environment: +$OSDEV_VERSION_CUSTOMER should be set to ${MEYN_CUSTOMER_CONFIG_ROOT}/customer_config.txt + +The script creates an include file that contains constants that should +be used to identify a component. The generated source is the best +reference for the various defined elements. + +There are two elements that are required. They are: + +- _VER_OSDEV_IDENTIFIER_ + The full OSDEV component identifier. Visible to the external world, via + IU or service version. +- _VER_BUILD_EMBED_SHA_ + The full embedded build fingerprint. Visible to developers/R&D with + the command "grep -e ":git:.*:tig:" + +* Defining the Product Identifier + This tool uses the folder osdev_version in the root of the git + repository to contain the default product and customer + identifiers. + + To start using this tool you must: + - copy the osdev_version folder from this repository to the root of the + product git repository. + + - remove the example mlogic_config.txt from the copied folder + - if required - remove the example customer_config.txt from the copied folder + + - edit the product identification file. + + Once this is done, you can use the appropriate mechanism to use this + tool to identify your product. + +* C/C++ + + +include the "osdev_verison.h" in the source, and define < +- How a build fingerprint is embedded into a binary. +#+BEGIN_SRC c++ +#include "osdev_version.h" +/* OSDEV Component identifier define build fingerprint */ +_static const char *build_id=_VER_BUILD_EMBED_SHA_ +#+END_SRC + +*** PyUAF + +*** QT + An example of using the Component Identifier used in QT User + interfaces. +#+BEGIN_SRC c++ Qt Gui +#include "osdev_version.h" + +/* OSDEV Component identifier */ +a.setProperty("VersionString", QString("%1") + .arg(_VER_OSDEV_IDENTIFIER_) + ); + #+END_SRC + +*** Cmake as git submodule + One mechanism to relate repositories is to use the "git submodule + add" command, and add the appropriate version of the + osdev_create_version_include as a submodule in the project folder. + + These dependencies are tightly coupled, and have to be adjusted when + moving from development to release. + + Add it to the projects CMakeLists.txt as below, and The project should build + as usual. + +#+BEGIN_SRC cmake + +# point the tool to this repository to create version from. +set (ENV{OSDEV_SRC_DIR} ${CMAKE_SOURCE_DIR}) + +# To override default source for product or source information. +# see the Cmakelists in the osdev_create_version_include folder. + +# Add Version control to the Cmake source tree +ADD_SUBDIRECTORY(osdev_create_version_include) + +# add version directory to included directories +INCLUDE_DIRECTORIES(${OSDEV_VERSION_HEADER_DIR}) + +#+END_SRC +*** Cmake as external source + This is another approach to managing the architecture dependency, + using the external source mechanism to add the tool to the source + tree as a parameter of the Cmake file, or as an environmental + variable defined by the build system. + + copy the ExternalHsoaVersion into a local cmake include folder. if + one does not exist then create it, and add this to your CMakelists.txt + +#+BEGIN_SRC cmake +# include cmake modules +LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ) +MESSAGE("CMAKE MODULE PATH:${CMAKE_MODULE_PATH}") +#+END_SRC + + Then you need to include the External resource in your project. You + can do this with the following: + +#+BEGIN_SRC cmake + +# define extra git repository Version parameters +SET(OSDEV_VERSION_TAG "R1_XD1.0.0E0.0.0") +SET(OSDEV_VERSION_REPO "git@gitlab.osdev.nl:OpenSystemsDevelopment/osdev_versioning.git") + +# include OSDEV Version tool as external asset +INCLUDE( ExternalHsoaVersion ) + +# add version directory to included directories +INCLUDE_DIRECTORIES(${OSDEV_VERSION_HEADER_DIR}) + +#+END_SRC + +*Note* Defining the variable in the CMake file, overrides any +environmental settings in the external version approach. + + +* Python + + +* JavaScript + + +* Ansible + + + diff --git a/cmake/osdevversion.cmake b/cmake/osdevversion.cmake new file mode 100644 index 0000000..52e1f90 --- /dev/null +++ b/cmake/osdevversion.cmake @@ -0,0 +1,6 @@ +# @brief Configures the hsoa_create_version_include versioning information variables +# and adds the submodule directory. + +set(OSDEV_PRODUCT_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(OSDEV_VERSION_PRODUCT_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/osdev_versioning/osdev_config/product_config.txt) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/osdev_versioning) diff --git a/osdev_config/customer_config.txt b/osdev_config/customer_config.txt new file mode 100755 index 0000000..74f6ab5 --- /dev/null +++ b/osdev_config/customer_config.txt @@ -0,0 +1,26 @@ +# Configuration file Template HSOA/Mlogic for the +# "HSOA Component Lifecycle Management v1.5" component versioning standard. +# +# - any lines starting with # are considered comments +# - the comment line "....." above a value specifies the maximum size. +# - all values may not contain spaces unless specifically noted. +# - If the comment is "12..." then the value is alphanumeric without spaces. +# - If the comment is "xx..." then the value is numeric only +# +# +# Customer name (was MC_KLANT in mc_conf.h) +# TEMPLATE: "12345678901234567890123456789" +CUSTOMER_NAME="12345678901234567890123456789" + +# Customer number (was MC_KLANT in mc_conf.h) +# The customer number from BAAN +# TEMPLATE: "xxxxx" +CUSTOMER_NUMBER="xxxxx" + +# Customer release (was MC_KLANT_VERSIE in mc_conf.h) +# TEMPLATE: "xx" +CUSTOMER_VERSION="xx" + +# Customer build flags (extra customer product specific settings) +# +CUSTOMER_BUILD_FLAGS="" diff --git a/osdev_config/osdev_config.txt b/osdev_config/osdev_config.txt new file mode 100644 index 0000000..386c652 --- /dev/null +++ b/osdev_config/osdev_config.txt @@ -0,0 +1,19 @@ +# Configuration file Template HSOA/Mlogic for the +# "HSOA Component Lifecycle Management v1.5" component versioning standard. +# +# Configuration file. +# +# - any lines starting with # are considered comments +# - the comment line "....." above a value specifies the maximum size. +# - all values may not contain spaces unless specifically noted. +# - If the comment is "12..." then the value is alphanumeric without spaces. +# - If the comment is "xx..." then the value is numeric only +# +# + +# HSOA Architecture version identifier +# +OSDEV_IDENTIFIER="XD1.0.0E0.0.0" + +# OsDev release code +OSDEV_RELEASE_NAME="R1" diff --git a/osdev_config/product_config.txt b/osdev_config/product_config.txt new file mode 100644 index 0000000..55934f7 --- /dev/null +++ b/osdev_config/product_config.txt @@ -0,0 +1,28 @@ +# Configuration file Template HSOA/Mlogic for the +# "HSOA Component Lifecycle Management v1.5" component versioning standard. +# +# +# - any lines starting with # are considered comments +# - the comment line "....." above a value specifies the maximum size. +# - all values may not contain spaces unless specifically noted. +# - If the comment is "12..." then the value is alphanumeric without spaces. +# - If the comment is "xx..." then the value is numeric only +# +# + +# Manufacturer code +# +PRODUCT_MANUFACTURER_CODE="OSDEV" + +# Manufacturer url +# +PRODUCT_MANUFACTURER_URL="http://www.osdev.nl" + +# Product release name (was MC_RELEASE in mc_config.h) +# +PRODUCT_RELEASE_NAME="" + +# Product build flags (extra product variant specific settings) +# +PRODUCT_BUILD_FLAGS="" + diff --git a/osdev_create_version_include.sh b/osdev_create_version_include.sh new file mode 100755 index 0000000..a396168 --- /dev/null +++ b/osdev_create_version_include.sh @@ -0,0 +1,492 @@ +#!/bin/bash + +# Set this to y to turn on debugging in this script. +#DEBUG=y + +############################################### +# _test_config_var +# pass in +# $1 - config variable to check +# $2 - Current parse state, 0 = OK, 1 = Failed +# return parse state on absence or presence of $1. + +function _test_config_var () { + local CONFIG_VAR="${1}" + local CONFIG_ERR=${2} + + # debug test + if [[ ! -z "${DEBUG}" ]] ; then + echo "+=+ ${CONFIG_ERR} - Checking ${CONFIG_VAR}" + fi + + # perform test + if [[ -z $(eval "echo \"\$${CONFIG_VAR}\"") ]] ; then + CONFIG_ERR=1 + fi + return ${CONFIG_ERR} +} + +# Directory of this script, hence the directory of the hsoa_create_version_include repository +OSDEV_GIT_DIR="$(cd $(dirname ${0}); pwd)" + +# What language to generate for +OSDEV_VERSION_TYPE="C++" + +# Where the component/product git repository is, default to where this script is. +OSDEV_PRODUCT_SRC_DIR="${OSDEV_PRODUCT_SRC_DIR:=$1}" + +# configuration file directory (default to current environment) +OSDEV_CONFIG_DIR="${OSDEV_CONFIG_DIR:=${OSDEV_PRODUCT_SRC_DIR}/osdev_config}" + +# path to customer configuration file +OSDEV_VERSION_CUSTOMER_CONFIG="${OSDEV_VERSION_CUSTOMER_CONFIG:=${OSDEV_GIT_DIR}/osdev_config/customer_config.txt}" + +# Architecture version filename +OSDEV_VERSION_OSDEV_CONFIG="${OSDEV_VERSION_OSDEV_CONFIG:=${OSDEV_GIT_DIR}/osdev_config/osdev_config.txt}" + +# product configuration filename +OSDEV_VERSION_PRODUCT_CONFIG="${OSDEV_VERSION_PRODUCT_CONFIG:=${OSDEV_CONFIG_DIR}/product_config.txt}" + +# output header directory (default to environment) +OSDEV_VERSION_HEADER_DIR="${OSDEV_VERSION_HEADER_DIR:=$2}" + +# filename to create +OSDEV_VERSION_FILE_PREFIX=${OSDEV_VERSION_HEADER_DIR}/osdev_version + +if [[ ! -z "${DEBUG}" ]] ; then + echo "OSDEV_GIT_DIR=${OSDEV_GIT_DIR}" + echo "OSDEV_CONFIG_DIR=${OSDEV_CONFIG_DIR}" + echo "OSDEV_PRODUCT_SRC_DIR=${OSDEV_PRODUCT_SRC_DIR}" + echo "OSDEV_VERSION_CUSTOMER_CONFIG=${OSDEV_VERSION_CUSTOMER_CONFIG}" + echo "OSDEV_VERSION_PRODUCT_CONFIG=${OSDEV_VERSION_PRODUCT_CONFIG}" + echo "OSDEV_VERSION_OSDEV_CONFIG=${OSDEV_VERSION_OSDEV_CONFIG}" + echo "OSDEV_VERSION_HEADER_DIR=${OSDEV_VERSION_HEADER_DIR}" + echo "OSDEV_VERSION_FILE_PREFIX=${OSDEV_VERSION_FILE_PREFIX}" +fi + +# find local C compiler to test header file +if [[ -z "${CC}" ]] ; then + CC="$(which cc)" +fi + +# no error found yet +CONFIG_ERR=0 + +# check osdev_config.txt for architecture configuration +if [[ ! -e ${OSDEV_VERSION_OSDEV_CONFIG} ]] ; then + CONFIG_ERR=1 +else + if [[ ! -z "${DEBUG}" ]] ; then + echo "+=+ Debug - parse for ${OSDEV_VERSION_OSDEV_CONFIG}" + fi + source ${OSDEV_VERSION_OSDEV_CONFIG} + CONFIG_ERR= _test_config_var "OSDEV_IDENTIFIER" "${CONFIG_ERR}" + CONFIG_ERR= _test_config_var "OSDEV_RELEASE_NAME" "${CONFIG_ERR}" +fi + +if [[ 0 -ne ${CONFIG_ERR} ]] ; then + echo "-- FATAL: osdev_config.txt ${OSDEV_VERSION_OSDEV_CONFIG} does not exist or is corrupt" + exit 1 +else + echo "++ osdev_hsoa:${OSDEV_RELEASE_NAME}_${OSDEV_IDENTIFIER}" +fi + +# check for a product configuration +if [[ ! -e ${OSDEV_VERSION_PRODUCT_CONFIG} ]] ; then + CONFIG_ERR=1 +else + if [[ ! -z "${DEBUG}" ]] ; then + echo "+=+ Debug - parse for ${OSDEV_VERSION_PRODUCT_CONFIG}" + fi + source ${OSDEV_VERSION_PRODUCT_CONFIG} + # check required parameters are there + CONFIG_ERR= _test_config_var "PRODUCT_RELEASE_NAME" "${CONFIG_ERR}" + CONFIG_ERR= _test_config_var "PRODUCT_MANUFACTURER_CODE" "${CONFIG_ERR}" +fi + +if [[ 0 -ne ${CONFIG_ERR} ]] ; then + echo "-- FATAL: product_config.txt ${OSDEV_VERSION_PRODUCT_CONFIG} does not exist or is corrupt" + exit 1 +else + echo "++ product:${PRODUCT_MANUFACTURER_CODE}-${PRODUCT_RELEASE_NAME}" +fi + +CUSTOMER_ID="" +if [[ ! -e ${OSDEV_VERSION_CUSTOMER_CONFIG} ]] ; then + CONFIG_ERR=1 +else + if [[ ! -z "${DEBUG}" ]] ; then + echo "+=+ Debug - parse for ${OSDEV_VERSION_CUSTOMER_CONFIG}" + fi + source ${OSDEV_VERSION_CUSTOMER_CONFIG} + # check required parameters are there + CONFIG_ERR= _test_config_var "CUSTOMER_NAME" "${CONFIG_ERR}" + CONFIG_ERR= _test_config_var "CUSTOMER_NUMBER" "${CONFIG_ERR}" + CONFIG_ERR= _test_config_var "CUSTOMER_VERSION" "${CONFIG_ERR}" + +# do not put customer name in here, because when a plant is sold a name can be changed but +# customer number and version will not change, they are linked to the location +# CUSTOMER_ID="${CUSTOMER_NUMBER}.${CUSTOMER_VERSION}_${CUSTOMER_NAME}" + CUSTOMER_ID="${CUSTOMER_NUMBER}.${CUSTOMER_VERSION}" +fi + +if [[ 0 -ne ${CONFIG_ERR} ]] ; then + echo "-- FATAL: customer_config.txt ${OSDEV_VERSION_CUSTOMER_CONFIG} does not exist or is corrupt" + exit 1 +else + echo "++ customer: ${CUSTOMER_ID}" +fi + +VER_BUILD_ID_LONG_SHA="$(cd ${OSDEV_PRODUCT_SRC_DIR}; git rev-list HEAD | sed -e 's/\(.*\)/\1/;q;d')" +VER_BUILD_ID_SHORT_SHA="$(cd ${OSDEV_PRODUCT_SRC_DIR}; git rev-list HEAD | sed -e 's/\(........\).*/\1/;q;d')" +VER_BUILD_BRANCH="$(cd ${OSDEV_PRODUCT_SRC_DIR}; git name-rev --name-only HEAD)" +VER_BUILD_DATE="$(cd ${OSDEV_PRODUCT_SRC_DIR}; date +'%Y.%m.%d')" +VER_BUILD_DATETIME="$(cd ${OSDEV_PRODUCT_SRC_DIR}; date +'%Y.%m.%d.%T')" +VER_BUILD_TAG="$(cd ${OSDEV_PRODUCT_SRC_DIR}; git describe --abbrev=0 --tags)" +VER_BUILD_HOST="$(hostname -s)" + +# in case version of McGraw+yocto is not defined set it to 1.0 +if [ -z "$OSDEV_DISTRO_VERSION" ]; then + OSDEV_DISTRO_VERSION="1.0" +fi + +# split out tag information +IFS='.' read -ra VER_BUILD_VERSION <<< "$VER_BUILD_TAG" + +VER_BUILD_MAJOR="${VER_BUILD_VERSION[0]}" +VER_BUILD_MINOR="${VER_BUILD_VERSION[1]}" +VER_BUILD_PATCH="${VER_BUILD_VERSION[2]}" +VER_BUILD_LETTER="${VER_BUILD_VERSION[3]}" +VER_BUILD_RELEASENR="1" + +# set some defaults if git tag information is not available. +if [ -z "$VER_BUILD_MAJOR" ] ; then + VER_BUILD_MAJOR="0" +fi +if [ -z "$VER_BUILD_MINOR" ] ; then + VER_BUILD_MINOR="0" +fi +if [ -z "$VER_BUILD_PATCH" ] ; then + VER_BUILD_PATCH="0" +fi +if [ -z "$VER_BUILD_LETTER" ] ; then + # must be X,T,H,F,S or R, + VER_BUILD_LETTER="X" +fi + +# short version number +PRODUCT_RELEASE_SHORT_VERSION="${VER_BUILD_MAJOR}.${VER_BUILD_MINOR}" + +# full version number +PRODUCT_RELEASE_VERSION="${VER_BUILD_MAJOR}.${VER_BUILD_MINOR}.${VER_BUILD_PATCH}.${VER_BUILD_LETTER}" + +# full product version for product support, version number template: +PRODUCT_FULL_VERSION="${OSDEV_RELEASE_NAME}_${OSDEV_IDENTIFIER}_${PRODUCT_MANUFACTURER_CODE}-${PRODUCT_RELEASE_NAME}_${PRODUCT_RELEASE_VERSION}_${CUSTOMER_ID}_${VER_BUILD_ID_SHORT_SHA}_${VER_BUILD_DATETIME}" + +# Replace spaces in customer name +CUSTOMER_NAME_STR=$(echo "${CUSTOMER_NAME}" | tr ' ' '_') + +# Customer Configuration SHA +CUSTOMER_BUILD_FLAGS=$(echo $OSDEV_IMAGE_CONFIG_GITSHA) + +VER_BUILD_EMBED_SHA=":git:${VER_BUILD_BRANCH}:${VER_BUILD_TAG}:${VER_BUILD_HOST}:${VER_BUILD_ID_LONG_SHA}:${PRODUCT_FULL_VERSION}:${PRODUCT_BUILD_FLAGS}:${CUSTOMER_BUILD_FLAGS}:tig:" + +# echo extended version information to log/console +while read -r ECHO_LINE +do + echo "${ECHO_LINE}" +done < ${OSDEV_VERSION_FILE_PREFIX}.cmake + +# DO NOT EDIT THIS FILE! + +# this file is auto-generated by create_version_include. The script that +# implements the "HSOA Component Lifecycle Management v1.x" +# component versioning standard. + +# Set in parent scope because of add_subdirectory in hsoaversion.cmake. +set( OSDEV_VERSION_INCLUDE_DIR "${OSDEV_VERSION_HEADER_DIR}" PARENT_SCOPE ) +set( OSDEV_VERSION_SRC_FILE "${OSDEV_VERSION_FILE_PREFIX}.cpp" PARENT_SCOPE ) +set( CURRENT_PROJECT_MANUFACTURER_CODE "${PRODUCT_MANUFACTURER_CODE}" PARENT_SCOPE ) +set( CURRENT_PROJECT_VERSION_MAJOR "${VER_BUILD_MAJOR}" PARENT_SCOPE ) +set( CURRENT_PROJECT_VERSION_MINOR "${VER_BUILD_MINOR}" PARENT_SCOPE ) +set( CURRENT_PROJECT_VERSION_PATCH "${VER_BUILD_PATCH}" PARENT_SCOPE ) +set( CURRENT_PROJECT_VERSION_LETTER "${VER_BUILD_LETTER}" PARENT_SCOPE ) +set( CURRENT_PROJECT_VERSION_RELEASENR "${VER_BUILD_RELEASENR}" PARENT_SCOPE ) +set( CURRENT_PROJECT_VERSION "${VER_BUILD_MAJOR}.${VER_BUILD_MINOR}.${VER_BUILD_PATCH}" PARENT_SCOPE ) + +EOF + +if [[ ! -z "${DEBUG}" ]] ; then + cat ${OSDEV_VERSION_FILE_PREFIX}.cmake +fi + +# generate a hsoa_version header file for c/c++ +while read -r ECHO_HFILE +do + echo "${ECHO_HFILE}" +done < ${OSDEV_VERSION_FILE_PREFIX}.h + +/* +DO NOT EDIT THIS FILE! + +this file is auto-generated by create_version_include. The script that +implements the "HSOA Component Lifecycle Management v1.x" +component versioning standard. + +*/ + +#ifndef OSDEV_VERSION_DEFINES_H_ +#define OSDEV_VERSION_DEFINES_H_ + +namespace mlogic { +namespace hsoaversion { +namespace PRODUCT_${PRODUCT_RELEASE_NAME} { + +#if !defined(OSDEV_GNUC_USED) && (defined(__GNUC__) && !defined(__clang__)) + #define OSDEV_GNUC_USED [[gnu::used]] +#else + #define OSDEV_GNUC_USED +#endif + +struct HsoaVersionInfo +{ +/* mlogic specific information */ +OSDEV_GNUC_USED static const char* VER_OSDEV_RELEASE_NAME_; +OSDEV_GNUC_USED static const char* VER_OSDEV_IDENTIFIER_; + +/* customer specific information */ +OSDEV_GNUC_USED static const char* VER_CUSTOMER_NAME_; +OSDEV_GNUC_USED static const char* VER_CUSTOMER_NUMBER_; +OSDEV_GNUC_USED static const char* VER_CUSTOMER_OSDEV_VERSION_; +OSDEV_GNUC_USED static const char* VER_CUSTOMER_ID_; + +/* product specific information */ +OSDEV_GNUC_USED static const char* VER_PRODUCT_RELEASE_NAME_; +OSDEV_GNUC_USED static const char* VER_PRODUCT_RELEASE_VSHORT_; +OSDEV_GNUC_USED static const char* VER_PRODUCT_RELEASE_VFULL_; +OSDEV_GNUC_USED static const char* VER_PRODUCT_OSDEV_VERSION_; +OSDEV_GNUC_USED static const char* VER_PRODUCT_MANUFACTURER_CODE_; +OSDEV_GNUC_USED static const char* VER_PRODUCT_MANUFACTURER_URL_; + +/* version major, minor, sub and letter. */ +OSDEV_GNUC_USED static const char* VER_BUILD_MAJOR_; +OSDEV_GNUC_USED static const char* VER_BUILD_MINOR_; +OSDEV_GNUC_USED static const char* VER_BUILD_PATCH_; +OSDEV_GNUC_USED static const char* VER_BUILD_RELEASENR_; +OSDEV_GNUC_USED static const char* VER_BUILD_LETTER_; + +/* Git build specific information to embed into the program */ +OSDEV_GNUC_USED static const char* VER_BUILD_ID_SHORT_SHA_; +OSDEV_GNUC_USED static const char* VER_BUILD_ID_LONG_SHA_; +OSDEV_GNUC_USED static const char* VER_BUILD_DATE_; +OSDEV_GNUC_USED static const char* VER_BUILD_DATETIME_; +OSDEV_GNUC_USED static const char* VER_BUILD_EMBED_SHA_; +OSDEV_GNUC_USED static const char* VER_BUILD_CUSTOMER_FLAGS_; +OSDEV_GNUC_USED static const char* VER_BUILD_PRODUCT_FLAGS_; +}; + +} // namespace PRODUCT_... +} // namespace hsoaversion +} // namespace mlogic + +#endif /* OSDEV_VERSION_DEFINES_H_ */ + +EOF + +if [[ ! -z "${DEBUG}" ]] ; then + cat ${OSDEV_VERSION_FILE_PREFIX}.h +fi + +# generate a hsoa_version source file for c/c++ +while read -r ECHO_CPPFILE +do + echo "${ECHO_CPPFILE}" +done < ${OSDEV_VERSION_FILE_PREFIX}.cpp + +/* +DO NOT EDIT THIS FILE! + +this file is auto-generated by create_version_include. The script that +implements the "HSOA Component Lifecycle Management v1.x" +component versioning standard. + +*/ + +#include "hsoa_version.h" + +using namespace mlogic::hsoaversion::PRODUCT_${PRODUCT_RELEASE_NAME}; + +/* mlogic specific information */ +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_OSDEV_RELEASE_NAME_= "${OSDEV_RELEASE_NAME}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_OSDEV_IDENTIFIER_ = "${OSDEV_IDENTIFIER}"; + +/* customer specific information */ +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_CUSTOMER_NAME_ = "${CUSTOMER_NAME_STR}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_CUSTOMER_NUMBER_ = "${CUSTOMER_NUMBER}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_CUSTOMER_OSDEV_VERSION_= "${CUSTOMER_VERSION}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_CUSTOMER_ID_ = "${CUSTOMER_ID}"; + +/* product specific information */ +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_PRODUCT_RELEASE_NAME_ = "${PRODUCT_RELEASE_NAME}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_PRODUCT_RELEASE_VSHORT_= "${PRODUCT_RELEASE_SHORT_VERSION}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_PRODUCT_RELEASE_VFULL_ = "${PRODUCT_RELEASE_VERSION}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_PRODUCT_OSDEV_VERSION_ = "${PRODUCT_FULL_VERSION}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_PRODUCT_MANUFACTURER_CODE_ = "${PRODUCT_MANUFACTURER_CODE}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_PRODUCT_MANUFACTURER_URL_ = "${PRODUCT_MANUFACTURER_URL}"; + +/* version major, minor, sub and letter. */ +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_MAJOR_ = "${VER_BUILD_MAJOR}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_MINOR_ = "${VER_BUILD_MINOR}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_PATCH_ = "${VER_BUILD_PATCH}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_RELEASENR_ = "${VER_BUILD_RELEASENR}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_LETTER_ = "${VER_BUILD_LETTER}"; + +/* Git build specific information to embed into the program */ +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_ID_SHORT_SHA_ = "${VER_BUILD_ID_SHORT_SHA}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_ID_LONG_SHA_ = "${VER_BUILD_ID_LONG_SHA}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_DATE_ = "${VER_BUILD_DATE}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_DATETIME_ = "${VER_BUILD_DATETIME}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_EMBED_SHA_ = "${VER_BUILD_EMBED_SHA}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_CUSTOMER_FLAGS_= "${CUSTOMER_BUILD_FLAGS}"; +OSDEV_GNUC_USED const char* HsoaVersionInfo::VER_BUILD_PRODUCT_FLAGS_ = "${PRODUCT_BUILD_FLAGS}"; + +EOF + +if [[ ! -z "${DEBUG}" ]] ; then + cat ${OSDEV_VERSION_FILE_PREFIX}.h +fi + +# generate a hsoa_version for python +while read -r ECHO_HFILE +do + echo "${ECHO_HFILE}" +done < ${OSDEV_VERSION_FILE_PREFIX}.py + +# +# DO NOT EDIT THIS FILE! +# +# this file is auto-generated by create_version_include. The script that +# implements the "HSOA Component Lifecycle Management v1.x" +# component versioning standard. +# +# + +# mlogic specific information +VER_OSDEV_RELEASE_NAME_ = "${OSDEV_RELEASE_NAME}" +VER_OSDEV_IDENTIFIER_ = "${OSDEV_IDENTIFIER}" + +# customer specific information +VER_CUSTOMER_NAME_ = "${CUSTOMER_NAME_STR}" +VER_CUSTOMER_NUMBER_ = "${CUSTOMER_NUMBER}" +VER_CUSTOMER_OSDEV_VERSION_ = "${CUSTOMER_VERSION}" +VER_CUSTOMER_ID_ = "${CUSTOMER_ID}" + +# product specific information +VER_PRODUCT_RELEASE_NAME_ = "${PRODUCT_RELEASE_NAME}" +VER_PRODUCT_RELEASE_VSHORT_ = "${PRODUCT_RELEASE_SHORT_VERSION}" +VER_PRODUCT_RELEASE_VFULL_ = "${PRODUCT_RELEASE_VERSION}" +VER_PRODUCT_OSDEV_VERSION_ = "${PRODUCT_FULL_VERSION}" +VER_PRODUCT_MANUFACTURER_CODE_ = "${PRODUCT_MANUFACTURER_CODE}" + +# version major, minor, sub and letter. +VER_BUILD_MAJOR_ = "${VER_BUILD_MAJOR}" +VER_BUILD_MINOR_ = "${VER_BUILD_MINOR}" +VER_BUILD_PATCH_ = "${VER_BUILD_PATCH}" +VER_BUILD_LETTER_ = "${VER_BUILD_LETTER}" + +# Git build specific information to embed into the program +VER_BUILD_ID_SHORT_SHA_ = "${VER_BUILD_ID_SHORT_SHA}" +VER_BUILD_ID_LONG_SHA_ = "${VER_BUILD_ID_LONG_SHA}" +VER_BUILD_DATE_ = "${VER_BUILD_DATE}" +VER_BUILD_DATETIME_ = "${VER_BUILD_DATETIME}" +VER_BUILD_EMBED_SHA_ = "${VER_BUILD_EMBED_SHA}" +VER_BUILD_CUSTOMER_FLAGS_ = "${CUSTOMER_BUILD_FLAGS}" +VER_BUILD_PRODUCT_FLAGS_ = "${PRODUCT_BUILD_FLAGS}" + +EOF + +if [[ ! -z "${DEBUG}" ]] ; then + cat ${OSDEV_VERSION_FILE_PREFIX}.py +fi + +# test python output +if [[ ! -z "$(which pylint)" ]] ; then + echo "++ testing ${OSDEV_VERSION_FILE_PREFIX}.py" + pylint -E ${OSDEV_VERSION_FILE_PREFIX}.py +else + echo "++ pylint not available to test ${OSDEV_VERSION_FILE_PREFIX}.py" +fi + +# generate a hsoa_version for JavaScript +while read -r ECHO_HFILE +do + echo "${ECHO_HFILE}" +done < ${OSDEV_VERSION_FILE_PREFIX}.js + +/* +DO NOT EDIT THIS FILE! + +this file is auto-generated by create_version_include. The script that +implements the "HSOA Component Lifecycle Management v1.x" +component versioning standard. + +*/ + +/* mlogic specific information */ +const VER_OSDEV_RELEASE_NAME_ = "${OSDEV_RELEASE_NAME}" +const VER_OSDEV_IDENTIFIER_ = "${OSDEV_IDENTIFIER}" + +/* customer specific information */ +const VER_CUSTOMER_NAME_ = "${CUSTOMER_NAME_STR}" +const VER_CUSTOMER_NUMBER_ = "${CUSTOMER_NUMBER}" +const VER_CUSTOMER_OSDEV_VERSION_ = "${CUSTOMER_VERSION}" +const VER_CUSTOMER_ID_ = "${CUSTOMER_ID}" + +/* product specific information */ +const VER_PRODUCT_RELEASE_NAME_ = "${PRODUCT_RELEASE_NAME}" +const VER_PRODUCT_RELEASE_VSHORT_ = "${PRODUCT_RELEASE_SHORT_VERSION}" +const VER_PRODUCT_RELEASE_VFULL_ = "${PRODUCT_RELEASE_VERSION}" +const VER_PRODUCT_OSDEV_VERSION_ = "${PRODUCT_FULL_VERSION}" +const VER_PRODUCT_MANUFACTURER_CODE_ = "${PRODUCT_MANUFACTURER_CODE}" + +/* version major, minor, sub and letter. */ +const VER_BUILD_MAJOR_ = "${VER_BUILD_MAJOR}" +const VER_BUILD_MINOR_ = "${VER_BUILD_MINOR}" +const VER_BUILD_PATCH_ = "${VER_BUILD_PATCH}" +const VER_BUILD_LETTER_ = "${VER_BUILD_LETTER}" + +/* Git build specific information to embed into the program */ +const VER_BUILD_ID_SHORT_SHA_ = "${VER_BUILD_ID_SHORT_SHA}" +const VER_BUILD_ID_LONG_SHA_ = "${VER_BUILD_ID_LONG_SHA}" +const VER_BUILD_DATE_ = "${VER_BUILD_DATE}" +const VER_BUILD_DATETIME_ = "${VER_BUILD_DATETIME}" +const VER_BUILD_EMBED_SHA_ = "${VER_BUILD_EMBED_SHA}" +const VER_BUILD_CUSTOMER_FLAGS_ = "${CUSTOMER_BUILD_FLAGS}" +const VER_BUILD_PRODUCT_FLAGS_ = "${PRODUCT_BUILD_FLAGS}" + +EOF + +if [[ ! -z "${DEBUG}" ]] ; then + cat ${OSDEV_VERSION_FILE_PREFIX}.js +fi + +# test JavaScript output with node +if [[ ! -z "$(which node)" ]] ; then + echo "++ testing ${OSDEV_VERSION_FILE_PREFIX}.js" + node ${OSDEV_VERSION_FILE_PREFIX}.js +else + echo "++ node not available to test ${OSDEV_VERSION_FILE_PREFIX}.js" +fi -- libgit2 0.21.4