зеркало из https://github.com/microsoft/CCF.git
cchost --version (#1323)
This commit is contained in:
Родитель
9de3a1f2bd
Коммит
03e6f41eb6
|
@ -70,10 +70,6 @@ jobs:
|
|||
|
||||
# Release
|
||||
- ${{ if eq(parameters.perf_or_release, 'release') }}:
|
||||
- template: release_checks.yml
|
||||
parameters:
|
||||
env: ${{ parameters.env.Hosted }}
|
||||
|
||||
- template: common.yml
|
||||
parameters:
|
||||
target: SGX
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
jobs:
|
||||
- job: Release_Checks
|
||||
displayName: 'Check code is ready for release'
|
||||
|
||||
${{ insert }}: ${{ parameters.env }}
|
||||
|
||||
steps:
|
||||
- checkout: self
|
||||
clean: true
|
||||
submodules: true
|
||||
|
||||
- script: ./check-cmake-version-vs-tag.sh
|
||||
displayName: 'Check project version in CMake matches git tag'
|
||||
condition: succeededOrFailed()
|
|
@ -4,19 +4,18 @@ cmake_minimum_required(VERSION 3.11)
|
|||
|
||||
set(CCF_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include(${CCF_DIR}/cmake/preproject.cmake)
|
||||
include(${CCF_DIR}/cmake/version.cmake)
|
||||
|
||||
project(
|
||||
ccf
|
||||
VERSION 0.11.1
|
||||
VERSION ${CCF_RELEASE_VERSION}
|
||||
LANGUAGES C CXX
|
||||
)
|
||||
|
||||
set(ENV{BETTER_EXCEPTIONS} 1)
|
||||
|
||||
set(CCF_PROJECT_NAME_SUFFIX "")
|
||||
set(CCF_PROJECT_NAME "${PROJECT_VERSION}${CCF_PROJECT_NAME_SUFFIX}")
|
||||
|
||||
message(STATUS "CCF version=${CCF_PROJECT_NAME}")
|
||||
message(STATUS "CCF version=${CCF_VERSION}")
|
||||
message(STATUS "CCF release version=${CCF_RELEASE_VERSION}")
|
||||
|
||||
# Set the default install prefix for CCF. Users may override this value with the
|
||||
# cmake command. For example:
|
||||
|
@ -25,7 +24,7 @@ message(STATUS "CCF version=${CCF_PROJECT_NAME}")
|
|||
#
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX
|
||||
"/opt/ccf/ccf-${CCF_PROJECT_NAME}"
|
||||
"/opt/ccf/ccf-${CCF_VERSION}"
|
||||
CACHE PATH "Default install prefix" FORCE
|
||||
)
|
||||
endif()
|
||||
|
@ -39,6 +38,10 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/preproject.cmake
|
|||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pbft.cmake)
|
||||
|
||||
configure_file(
|
||||
${CCF_DIR}/src/host/version.h.in ${CCF_GENERATED_DIR}/version.h @ONLY
|
||||
)
|
||||
|
||||
set(CONSENSUSES raft pbft)
|
||||
|
||||
option(BUILD_TESTS "Build tests" ON)
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the Apache 2.0 License.
|
||||
|
||||
git_tag=$(git describe --tags --abbrev=0)
|
||||
git_tag=${git_tag#v}
|
||||
|
||||
# Check if git tag looks like a semver value - ignore if not
|
||||
if [[ ${git_tag} =~ ^([[:digit:]])+(\.([[:digit:]])+)*(-.*)?$ ]]; then
|
||||
mkdir -p build
|
||||
pushd build
|
||||
cmake_version=$(cmake .. -L | grep "CCF version=")
|
||||
cmake_version=${cmake_version#*=}
|
||||
echo "Comparing git tag ($git_tag) with CMake version ($cmake_version)"
|
||||
if [[ "${git_tag}" == "${cmake_version}" ]]; then
|
||||
echo "Git tag ($git_tag) matches CMake version ($cmake_version)"
|
||||
exit 0
|
||||
else
|
||||
echo "Git tag ($git_tag) does not match CMake version ($cmake_version) - please update CMake version"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Skipping check - ${git_tag} doesn't look like semver"
|
||||
exit 0
|
||||
fi
|
|
@ -109,14 +109,8 @@ install(PROGRAMS ${CCF_DIR}/tests/scurl.sh ${CCF_DIR}/tests/keygenerator.sh
|
|||
install(DIRECTORY ${CCF_DIR}/getting_started/ DESTINATION getting_started)
|
||||
|
||||
if("sgx" IN_LIST COMPILE_TARGETS)
|
||||
# If OE was built with LINK_SGX=1, then we also need to link SGX
|
||||
if(OE_SGX)
|
||||
message(STATUS "Linking SGX")
|
||||
set(SGX_LIBS sgx_enclave_common sgx_dcap_ql sgx_urts)
|
||||
|
||||
if(NOT DISABLE_QUOTE_VERIFICATION)
|
||||
set(QUOTES_ENABLED ON)
|
||||
endif()
|
||||
if(NOT DISABLE_QUOTE_VERIFICATION)
|
||||
set(QUOTES_ENABLED ON)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
@ -204,7 +198,6 @@ if("sgx" IN_LIST COMPILE_TARGETS)
|
|||
target_link_libraries(
|
||||
cchost
|
||||
PRIVATE uv
|
||||
${SGX_LIBS}
|
||||
${CRYPTO_LIBRARY}
|
||||
${CMAKE_DL_LIBS}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
|
@ -239,6 +232,7 @@ if("virtual" IN_LIST COMPILE_TARGETS)
|
|||
target_compile_options(cchost.virtual PRIVATE -stdlib=libc++)
|
||||
target_include_directories(
|
||||
cchost.virtual PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${OE_INCLUDEDIR}
|
||||
${CCF_GENERATED_DIR}
|
||||
)
|
||||
add_san(cchost.virtual)
|
||||
enable_coverage(cchost.virtual)
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the Apache 2.0 License.
|
||||
|
||||
unset(CCF_VERSION)
|
||||
unset(CCF_RELEASE_VERSION)
|
||||
|
||||
# If possible, deduce project version from git environment
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
||||
find_package(Git)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} describe --tags
|
||||
OUTPUT_VARIABLE "CCF_VERSION"
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
execute_process(
|
||||
COMMAND "bash" "-c" "${GIT_EXECUTABLE} describe --tags --abbrev=0 | tr -d v"
|
||||
OUTPUT_VARIABLE "CCF_RELEASE_VERSION" OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT CCF_RELEASE_VERSION)
|
||||
# If not in a git environment (e.g. release tarball), deduce version from the
|
||||
# source directory name
|
||||
execute_process(
|
||||
COMMAND "bash" "-c"
|
||||
"[[ $(basename ${CMAKE_CURRENT_SOURCE_DIR}) =~ ^CCF-.* ]]"
|
||||
RESULT_VARIABLE "IS_CCF_FOLDER"
|
||||
)
|
||||
|
||||
if(NOT ${IS_CCF_FOLDER} STREQUAL "0")
|
||||
message(FATAL_ERROR "Sources directory is not in \"CCF-...\" folder")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "bash" "-c" "basename ${CMAKE_CURRENT_SOURCE_DIR} | cut -d'-' -f2"
|
||||
OUTPUT_VARIABLE "CCF_VERSION" OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
set(CCF_RELEASE_VERSION ${CCF_VERSION})
|
||||
message(STATUS "CCF version deduced from sources directory: ${CCF_VERSION}")
|
||||
endif()
|
||||
|
||||
# Check that release version is semver
|
||||
execute_process(
|
||||
COMMAND "bash" "-c"
|
||||
"[[ ${CCF_RELEASE_VERSION} =~ ^([[:digit:]])+(\.([[:digit:]])+)*$ ]]"
|
||||
RESULT_VARIABLE "VERSION_IS_SEMVER"
|
||||
)
|
||||
|
||||
if(NOT ${VERSION_IS_SEMVER} STREQUAL "0")
|
||||
message(
|
||||
WARNING
|
||||
"Release version \"${CCF_RELEASE_VERSION}\" does not follow semver. Defaulting to project version 0.0.0"
|
||||
)
|
||||
set(CCF_RELEASE_VERSION "0.0.0")
|
||||
endif()
|
|
@ -15,6 +15,7 @@
|
|||
#include "sig_term.h"
|
||||
#include "ticker.h"
|
||||
#include "time_updater.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <CLI11/CLI11.hpp>
|
||||
#include <codecvt>
|
||||
|
@ -31,6 +32,12 @@ using namespace std::chrono_literals;
|
|||
|
||||
::timespec logger::config::start{0, 0};
|
||||
|
||||
void print_version(size_t)
|
||||
{
|
||||
std::cout << "CCF host: " << ccf::ccf_version << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// ignore SIGPIPE
|
||||
|
@ -42,6 +49,9 @@ int main(int argc, char** argv)
|
|||
app.set_config("--config", "", "Read an INI or TOML file", false);
|
||||
app.allow_config_extras(false);
|
||||
|
||||
app.add_flag(
|
||||
"-v, --version", print_version, "Display CCF host version and exit");
|
||||
|
||||
app.require_subcommand(1, 1);
|
||||
|
||||
std::string enclave_file;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the Apache 2.0 License.
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ccf
|
||||
{
|
||||
static constexpr auto ccf_version = "@CCF_VERSION@";
|
||||
}
|
Загрузка…
Ссылка в новой задаче