mirror of https://github.com/oxen-io/lokinet
Put version info into a compiled file
This rewrites the version info using lokid's approach of compiling it into a .cpp file that gets generated as part of the build (*not* during the configure stage). Among other things, this means that changing the version no longer invalidates ccache or cmake dependencies, and because it depends on `.git/index` git commits will cause the version to be regenerated, making the commit tag more reliable (currently if you rebuild without running cmake your git commit tag doesn't update).pull/965/head
parent
99d27a4886
commit
638fb25b47
@ -0,0 +1,61 @@
|
||||
# Copyright (c) 2014-2019, The Monero Project
|
||||
# Copyright (c) 2019, The Loki Project
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are
|
||||
# permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other
|
||||
# materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software without specific
|
||||
# prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
# Check what commit we're on
|
||||
execute_process(COMMAND "${GIT}" rev-parse --short=9 HEAD RESULT_VARIABLE RET OUTPUT_VARIABLE COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(RET)
|
||||
# Something went wrong, set the version tag to -unknown
|
||||
message(WARNING "Cannot determine current commit. Make sure that you are building either from a Git working tree or from a source archive.")
|
||||
set(VERSIONTAG "unknown")
|
||||
else()
|
||||
string(SUBSTRING ${COMMIT} 0 9 COMMIT)
|
||||
message(STATUS "You are currently on commit ${COMMIT}")
|
||||
|
||||
# Get all the tags
|
||||
execute_process(COMMAND "${GIT}" rev-list --tags --max-count=1 --abbrev-commit RESULT_VARIABLE RET OUTPUT_VARIABLE TAGGEDCOMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(NOT TAGGEDCOMMIT)
|
||||
message(WARNING "Cannot determine most recent tag. Make sure that you are building either from a Git working tree or from a source archive.")
|
||||
set(VERSIONTAG "${COMMIT}")
|
||||
else()
|
||||
# Check if we're building that tagged commit or a different one
|
||||
if(COMMIT STREQUAL TAGGEDCOMMIT)
|
||||
message(STATUS "${COMMIT} is a tagged release; setting version tag to 'release'")
|
||||
set(VERSIONTAG "release")
|
||||
else()
|
||||
message(STATUS "You are not building a tagged release; setting version tag to '${COMMIT}'")
|
||||
set(VERSIONTAG "${COMMIT}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
configure_file("${SRC}" "${DEST}")
|
@ -0,0 +1,21 @@
|
||||
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND OR Git_FOUND)
|
||||
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
"-D" "GIT=${GIT_EXECUTABLE}"
|
||||
"-D" "SRC=${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in"
|
||||
"-D" "DEST=${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp"
|
||||
"-P" "${CMAKE_CURRENT_LIST_DIR}/GenVersion.cmake"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../.git/index")
|
||||
else()
|
||||
message(WARNING "Git was not found! Setting version to to nogit")
|
||||
set(VERSIONTAG "nogit")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/constants/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp")
|
||||
endif()
|
||||
|
||||
add_custom_target(genversion DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/constants/version.cpp")
|
@ -1,6 +0,0 @@
|
||||
#include <constants/version.hpp>
|
||||
|
||||
#ifndef LLARP_DEFAULT_NETID
|
||||
#define LLARP_DEFAULT_NETID "gamma"
|
||||
#endif
|
||||
const char Version::LLARP_NET_ID[] = LLARP_DEFAULT_NETID;
|
@ -0,0 +1,19 @@
|
||||
#include <constants/version.hpp>
|
||||
#include <constants/version.h>
|
||||
|
||||
#define LLARP_STRINGIFY2(val) #val
|
||||
#define LLARP_STRINGIFY(val) LLARP_STRINGIFY2(val)
|
||||
|
||||
#define LLARP_VERSION_STR LLARP_STRINGIFY(LLARP_VERSION_MAJ) "." LLARP_STRINGIFY(LLARP_VERSION_MIN) "." LLARP_STRINGIFY(LLARP_VERSION_PATCH)
|
||||
#define LLARP_VERSION_FULL LLARP_VERSION_STR "-@VERSIONTAG@"
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
const std::array<uint16_t, 3> VERSION{{LLARP_VERSION_MAJ, LLARP_VERSION_MIN, LLARP_VERSION_PATCH}};
|
||||
const char* const VERSION_STR = LLARP_VERSION_STR;
|
||||
const char* const VERSION_TAG = "@VERSIONTAG@";
|
||||
const char* const VERSION_FULL = LLARP_NAME "-" LLARP_VERSION_STR "-@VERSIONTAG@";
|
||||
|
||||
const char* const RELEASE_MOTTO = LLARP_RELEASE_MOTTO;
|
||||
const char* const DEFAULT_NETID = LLARP_DEFAULT_NETID;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
// Don't include this file directly but rather go through version.hpp instead. This is only here so
|
||||
// version.cpp.in and the weird archaic windows build recipies can use the version.
|
||||
|
||||
#define LLARP_NAME "lokinet"
|
||||
|
||||
#define LLARP_VERSION_MAJ 0
|
||||
#define LLARP_VERSION_MIN 6
|
||||
#define LLARP_VERSION_PATCH 0
|
||||
|
||||
#define LLARP_DEFAULT_NETID "gamma"
|
||||
|
||||
#ifndef LLARP_RELEASE_MOTTO
|
||||
#define LLARP_RELEASE_MOTTO "(dev build)"
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && defined(RC_INVOKED)
|
||||
#define LLARP_VERSION \
|
||||
LLARP_VERSION_MAJ, LLARP_VERSION_MIN, LLARP_VERSION_PATCH, 0
|
||||
|
||||
#define MAKE_TRIPLET(X,Y,Z) TRIPLET_CAT(X,.,Y,.,Z)
|
||||
#define TRIPLET_CAT(X,D1,Y,D2,Z) X##D1##Y##D2##Z
|
||||
|
||||
#define LLARP_VERSION_TRIPLET MAKE_TRIPLET(LLARP_VERSION_MAJ, LLARP_VERSION_MIN, LLARP_VERSION_PATCH)
|
||||
|
||||
#endif
|
@ -1,42 +1,16 @@
|
||||
#ifndef LLARP_VERSION_HPP
|
||||
#define LLARP_VERSION_HPP
|
||||
#pragma once
|
||||
|
||||
#ifndef LLARP_VERSION_MAJ
|
||||
#define LLARP_VERSION_MAJ 0
|
||||
#endif
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
|
||||
#ifndef LLARP_VERSION_MIN
|
||||
#define LLARP_VERSION_MIN 6
|
||||
#endif
|
||||
|
||||
#ifndef LLARP_VERSION_PATCH
|
||||
#define LLARP_VERSION_PATCH 0
|
||||
#endif
|
||||
|
||||
#ifndef LLARP_VERSION_NUM
|
||||
#ifdef GIT_REV
|
||||
#define LLARP_VERSION_NUM \
|
||||
"-LLARP_VERSION_MAJ.LLARP_VERSION_MIN.LLARP_VERSION_PATCH" \
|
||||
"-" GIT_REV
|
||||
#else
|
||||
#define LLARP_VERSION_NUM \
|
||||
"-LLARP_VERSION_MAJ.LLARP_VERSION_MIN.LLARP_VERSION_PATCH"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && defined(RC_INVOKED)
|
||||
#define LLARP_VERSION \
|
||||
LLARP_VERSION_MAJ, LLARP_VERSION_MIN, LLARP_VERSION_PATCH, 0
|
||||
#else
|
||||
#define LLARP_VERSION "lokinet" LLARP_VERSION_NUM
|
||||
#endif
|
||||
|
||||
#ifndef LLARP_RELEASE_MOTTO
|
||||
#define LLARP_RELEASE_MOTTO "(dev build)"
|
||||
#endif
|
||||
|
||||
struct Version
|
||||
namespace llarp
|
||||
{
|
||||
static const char LLARP_NET_ID[];
|
||||
};
|
||||
#endif
|
||||
// Given a full lokinet version of: lokinet-1.2.3-abc these are:
|
||||
extern const std::array<uint16_t, 3> VERSION; // [1, 2, 3]
|
||||
extern const char* const VERSION_STR; // "1.2.3"
|
||||
extern const char* const VERSION_TAG; // "abc"
|
||||
extern const char* const VERSION_FULL; // "lokinet-1.2.3-abc"
|
||||
|
||||
extern const char* const RELEASE_MOTTO;
|
||||
extern const char* const DEFAULT_NETID;
|
||||
}
|
||||
|
@ -1,126 +0,0 @@
|
||||
// WARNING: for the love of all that is good and holy
|
||||
// please DO NOT convert this file to UTF-8, much less
|
||||
// UTF-16 - the UNIX cross-rc does not understand UTF-16,
|
||||
// and UTF-8 chews up the copyright symbols.
|
||||
// -rick
|
||||
//
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
#include <constants/version.hpp>
|
||||
#ifdef __GNUC__
|
||||
#include <winresrc.h>
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#define STRINGIZER(version) #version
|
||||
|
||||
#ifdef LLARP_RELEASE_MOTTO
|
||||
#define VERSION_STRING(version, codename, revision) \
|
||||
STRINGIZER(version) "-release [" STRINGIZER(codename) "] (rev-" STRINGIZER(revision) ")"
|
||||
#else
|
||||
#define VERSION_STRING(version, revision) \
|
||||
STRINGIZER(version) STRINGIZER(revision)
|
||||
#endif
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE 1033,1
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION LLARP_VERSION
|
||||
PRODUCTVERSION LLARP_VERSION
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x3L
|
||||
#else
|
||||
FILEFLAGS 0x2L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", "libabyss JSON-RPC daemon demo"
|
||||
VALUE "CompanyName", "Loki Foundation"
|
||||
VALUE "FileDescription", "LokiNET for Microsoft® Windows® NT™"
|
||||
#ifdef LLARP_RELEASE_MOTTO
|
||||
VALUE "FileVersion", VERSION_STRING(0.5.2, RELEASE_MOTTO, GIT_REV)
|
||||
#else
|
||||
VALUE "FileVersion", VERSION_STRING(0.5.2-dev-, GIT_REV)
|
||||
#endif
|
||||
VALUE "InternalName", "llarpd"
|
||||
VALUE "LegalCopyright", "Copyright ©2018-2019 Jeff Becker, Rick V for the Loki Foundation. All rights reserved. This software is provided under the terms of the zlib-libpng licence; see the file LICENSE for details."
|
||||
VALUE "OriginalFilename", "abyss-main.exe"
|
||||
VALUE "ProductName", "LokiNET for Windows"
|
||||
#ifdef LLARP_RELEASE_MOTTO
|
||||
VALUE "ProductVersion", VERSION_STRING(0.5.2, RELEASE_MOTTO, GIT_REV)
|
||||
#else
|
||||
VALUE "ProductVersion", VERSION_STRING(0.5.2-dev-, GIT_REV)
|
||||
#endif
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RT_MANIFEST
|
||||
//
|
||||
|
||||
2 RT_MANIFEST "app.xml"
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
Loading…
Reference in New Issue