From d3831c8b1d9e99a8fca3445c8c9dd55a1ffcff39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 21 Jul 2015 20:08:53 +0200 Subject: [PATCH] Set EVM JIT version in cmake script. --- CMakeLists.txt | 5 +++-- libevmjit/BuildInfo.h.in | 2 -- libevmjit/CMakeLists.txt | 37 +++---------------------------------- libevmjit/Cache.cpp | 17 ++++++----------- libevmjit/JIT.cpp | 6 +++--- 5 files changed, 15 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f0044b63..055d66002 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.0) +cmake_policy(SET CMP0048 NEW) # allow VERSION argument in project() -project(evmjit) +project(EVMJIT VERSION 0.9.0 LANGUAGES CXX) set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(CMAKE_AUTOMOC OFF) diff --git a/libevmjit/BuildInfo.h.in b/libevmjit/BuildInfo.h.in index 4b72144ed..bca9d0624 100644 --- a/libevmjit/BuildInfo.h.in +++ b/libevmjit/BuildInfo.h.in @@ -3,8 +3,6 @@ #define EVMJIT_VERSION_MAJOR ${EVMJIT_VERSION_MAJOR} #define EVMJIT_VERSION_MINOR ${EVMJIT_VERSION_MINOR} #define EVMJIT_VERSION_PATCH ${EVMJIT_VERSION_PATCH} -#define EVMJIT_VERSION_PRERELEASE "${EVMJIT_VERSION_PRERELEASE}" -#define EVMJIT_VERSION_FULL "${EVMJIT_VERSION_FULL}" #define LLVM_VERSION "${LLVM_PACKAGE_VERSION}" #define LLVM_ASSERTIONS "${LLVM_ENABLE_ASSERTIONS}" diff --git a/libevmjit/CMakeLists.txt b/libevmjit/CMakeLists.txt index 80108e15b..bad3aa2c6 100644 --- a/libevmjit/CMakeLists.txt +++ b/libevmjit/CMakeLists.txt @@ -29,40 +29,9 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") endif() - -set(EVMJIT_VERSION "0.0.0") -set(EVMJIT_VERSION_MAJOR 0) -set(EVMJIT_VERSION_MINOR 0) -set(EVMJIT_VERSION_PATCH 0) -set(EVMJIT_VERSION_FULL "v0.0.0-nogit") - -find_package(Git) -if(GIT_FOUND) - execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR} describe --dirty --always --match v* - OUTPUT_VARIABLE EVMJIT_VERSION_FULL OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() - -if(${EVMJIT_VERSION_FULL} MATCHES "^v[0-9]+\\.[0-9]+") - string(SUBSTRING ${EVMJIT_VERSION_FULL} 1 -1 EVMJIT_VERSION_FULL) # skip "v" - string(REPLACE "-" ";" VERSION_COMPONENTS ${EVMJIT_VERSION_FULL}) - list(LENGTH VERSION_COMPONENTS NUM_VERSION_COMPONENTS) - list(GET VERSION_COMPONENTS 0 EVMJIT_VERSION) - string(REPLACE "." ";" VERSION_NUMBERS ${EVMJIT_VERSION}) - list(LENGTH VERSION_NUMBERS NUM_VERSION_NUMBERS) - list(GET VERSION_NUMBERS 0 EVMJIT_VERSION_MAJOR) - list(GET VERSION_NUMBERS 1 EVMJIT_VERSION_MINOR) - if(${NUM_VERSION_NUMBERS} GREATER 2) - list(GET VERSION_NUMBERS 2 EVMJIT_VERSION_PATCH) # patch number is optional - endif() - if(${NUM_VERSION_COMPONENTS} GREATER 1) - list(GET VERSION_COMPONENTS 1 VERSION_PRERELEASE_CANDIDATE) - string(REGEX MATCH "^[a-zA-Z]+.*" EVMJIT_VERSION_PRERELEASE ${VERSION_PRERELEASE_CANDIDATE}) # prerelease starts with letter - endif() -endif() - if(${EVMJIT_VERSION_MAJOR} EQUAL 0) set(EVMJIT_SOVERSION "0.${EVMJIT_VERSION_MINOR}") -else() +else() set(EVMJIT_SOVERSION ${EVMJIT_VERSION_MAJOR}) endif() @@ -70,10 +39,10 @@ endif() string(COMPARE EQUAL "${LLVM_ENABLE_ASSERTIONS}" "ON" LLVM_DEBUG) configure_file(BuildInfo.h.in ${CMAKE_CURRENT_BINARY_DIR}/gen/BuildInfo.gen.h) -message(STATUS "EVM JIT version: ${EVMJIT_VERSION_MAJOR}.${EVMJIT_VERSION_MINOR}.${EVMJIT_VERSION_PATCH} ${EVMJIT_VERSION_PRERELEASE} (${EVMJIT_VERSION_FULL})") +message(STATUS "EVM JIT version: ${EVMJIT_VERSION_MAJOR}.${EVMJIT_VERSION_MINOR}.${EVMJIT_VERSION_PATCH}") add_library(${TARGET_NAME} SHARED ${SOURCES} gen/BuildInfo.gen.h) -set_target_properties(${TARGET_NAME} PROPERTIES +set_target_properties(${TARGET_NAME} PROPERTIES VERSION ${EVMJIT_VERSION} SOVERSION ${EVMJIT_SOVERSION} FOLDER "libs") diff --git a/libevmjit/Cache.cpp b/libevmjit/Cache.cpp index 01b1c8766..f32175c72 100644 --- a/libevmjit/Cache.cpp +++ b/libevmjit/Cache.cpp @@ -28,17 +28,10 @@ namespace CacheMode g_mode; std::unique_ptr g_lastObject; JITListener* g_listener; - static const size_t c_versionStampLength = 32; llvm::StringRef getLibVersionStamp() { - static auto version = llvm::SmallString{}; - if (version.empty()) - { - version = EVMJIT_VERSION_FULL; - version.resize(c_versionStampLength); - } - return version; + return EVMJIT_VERSION; } } @@ -130,11 +123,13 @@ std::unique_ptr Cache::getObject(std::string const& id) if (auto r = llvm::MemoryBuffer::getFile(cachePath.str(), -1, false)) { auto& buf = r.get(); - auto objVersionStamp = buf->getBufferSize() >= c_versionStampLength ? llvm::StringRef{buf->getBufferEnd() - c_versionStampLength, c_versionStampLength} : llvm::StringRef{}; - if (objVersionStamp == getLibVersionStamp()) + auto expectedStamp = getLibVersionStamp(); + auto stampSize = expectedStamp.size(); + auto objStamp = buf->getBufferSize() >= stampSize ? llvm::StringRef{buf->getBufferEnd() - stampSize, stampSize} : llvm::StringRef{}; + if (objStamp == expectedStamp) g_lastObject = llvm::MemoryBuffer::getMemBufferCopy(r.get()->getBuffer()); else - DLOG(cache) << "Unmatched version: " << objVersionStamp.str() << ", expected " << getLibVersionStamp().str() << "\n"; + DLOG(cache) << "Unmatched version: " << objStamp.str() << ", expected " << expectedStamp.str() << "\n"; } else if (r.getError() != std::make_error_code(std::errc::no_such_file_or_directory)) DLOG(cache) << r.getError().message(); // TODO: Add warning log diff --git a/libevmjit/JIT.cpp b/libevmjit/JIT.cpp index 53c36dcb2..9a852d61b 100644 --- a/libevmjit/JIT.cpp +++ b/libevmjit/JIT.cpp @@ -51,11 +51,11 @@ void printVersion() std::cout << "Ethereum EVM JIT Compiler (http://github.com/ethereum/evmjit):\n" << " EVMJIT version " << EVMJIT_VERSION << "\n" #ifdef NDEBUG - << " Optimized build, " EVMJIT_VERSION_FULL "\n" + << " Optimized build, " #else - << " DEBUG build, " EVMJIT_VERSION_FULL "\n" + << " DEBUG build, " #endif - << " Built " << __DATE__ << " (" << __TIME__ << ")\n" + << __DATE__ << " (" << __TIME__ << ")\n" << std::endl; }