Skip to content

Commit

Permalink
Merge pull request #656 from openziti/merge-main-to-1.x
Browse files Browse the repository at this point in the history
Merge main to 1.x
  • Loading branch information
ekoby authored May 31, 2024
2 parents c0ba615 + efcfe6e commit bdf8be2
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 56 deletions.
1 change: 1 addition & 0 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- release-1.x

jobs:
update_release_draft:
Expand Down
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
cmake_minimum_required(VERSION 3.22)

include(cmake/version.cmake)
get_version(${CMAKE_CURRENT_LIST_DIR}/version.txt ver GIT_BRANCH GIT_COMMIT_HASH)
get_version(${CMAKE_CURRENT_LIST_DIR}/version.txt GIT_VERSION GIT_BRANCH GIT_COMMIT_HASH)

set(CMAKE_C_STANDARD 99)
project(ziti-sdk
VERSION ${ver}
DESCRIPTION "OpenZiti C SDK"
HOMEPAGE_URL "https://github.com/openziti/ziti-sdk-c"
LANGUAGES C CXX
)
)

set(PROJECT_VERSION ${GIT_VERSION})
include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake)

Expand All @@ -19,7 +21,6 @@ message("project version: ${PROJECT_VERSION}")
message("git info:")
message(" branch : ${GIT_BRANCH}")
message(" hash : ${GIT_COMMIT_HASH}")
message(" date : ${BUILD_DATE}")

message("")
message("using ${CMAKE_GENERATOR}")
Expand Down
65 changes: 33 additions & 32 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@

function(get_version version_file version_var branch_var commit_var)
macro(do_git out_var err_var)
execute_process(
COMMAND git describe --tags --match=[0-9]* HEAD
COMMAND "git" ${ARGN}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_INFO
OUTPUT_VARIABLE git_out
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE git_error
ERROR_VARIABLE git_err
ECHO_ERROR_VARIABLE
)

if (NOT git_error)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE branch
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE commit
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if (git_err)
set(${err_var} ${git_err})
unset(${out_var})
else ()
set(${out_var} "${git_out}")
unset(${err_var})
endif ()
endmacro(do_git)

if (git_error)
function(get_version version_file version_var branch_var commit_var)
do_git(GIT_INFO GIT_ERROR describe --always)
if (GIT_ERROR)
unset(GIT_INFO)
message("getting version from ${version_file}")
message(NOTICE "getting version from ${version_file}")
file(STRINGS ${version_file} ver_info)
list(LENGTH ver_info ver_info_len)
list(GET ver_info 0 GIT_INFO)
list(GET ver_info 1 branch)
list(GET ver_info 2 commit)
list(GET ver_info 1 _branch)
list(GET ver_info 2 _commit)
set(${version_var} ${GIT_INFO} PARENT_SCOPE)
set(${branch_var} ${_branch} PARENT_SCOPE)
set(${commit_var} ${_commit} PARENT_SCOPE)
return()
endif ()

if (${GIT_INFO} MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)$")
set(_ver ${CMAKE_MATCH_1})
elseif (${GIT_INFO} MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-[^-]*")
string(JOIN "." _ver ${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
do_git(_branch GIT_ERROR rev-parse --abbrev-ref HEAD)
do_git(GIT_INFO GIT_ERROR describe --tags --long --first-parent HEAD)
if (${GIT_INFO} MATCHES "^(.*)-([0-9]+)-([^-]*)") # <closest tag>-<distance>-<commit>
set(_commit ${CMAKE_MATCH_3})
if (${CMAKE_MATCH_2} EQUAL "0") #exact tag
set(_ver ${CMAKE_MATCH_1})
else ()
string(JOIN "." _ver ${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
endif ()
endif ()

set(${version_var} ${_ver} PARENT_SCOPE)
set(${branch_var} ${branch} PARENT_SCOPE)
set(${commit_var} ${commit} PARENT_SCOPE)
set(${branch_var} ${_branch} PARENT_SCOPE)
set(${commit_var} ${_commit} PARENT_SCOPE)
endfunction()
2 changes: 1 addition & 1 deletion deps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ else ()

FetchContent_Declare(tlsuv
GIT_REPOSITORY https://github.com/openziti/tlsuv.git
GIT_TAG v0.29.2
GIT_TAG v0.29.3
)
FetchContent_MakeAvailable(tlsuv)

Expand Down
2 changes: 0 additions & 2 deletions programs/host-proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
project(host-proxy)

add_executable(host-proxy host-proxy.c)
target_link_libraries(host-proxy PRIVATE ziti)
2 changes: 0 additions & 2 deletions programs/sample-bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
project(sample-socket)

add_executable(ziti-ncat ziti-ncat.c)
target_link_libraries(ziti-ncat PUBLIC ziti)

Expand Down
2 changes: 0 additions & 2 deletions programs/sample-host/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
project(sample-host)

add_executable(sample-host sample-host.c)
target_link_libraries(sample-host PUBLIC ziti)
2 changes: 0 additions & 2 deletions programs/sample_enroll/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
project(sample_enroll)

add_executable(sample_enroll sample_enroll.c)
target_link_libraries(sample_enroll PUBLIC ziti)
2 changes: 0 additions & 2 deletions programs/sample_http_link/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
project(sample_http_link)

add_executable(sample_http_link sample_http_link.c)
target_link_libraries(sample_http_link PUBLIC ziti)
2 changes: 0 additions & 2 deletions programs/sample_wttr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
project(sample_wttr)

add_executable(sample_wttr sample_wttr.c)
target_link_libraries(sample_wttr PUBLIC ziti)
2 changes: 0 additions & 2 deletions programs/wzcat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
project(wzcat)

add_executable(wzcat ziti_ws.c)
target_link_libraries(wzcat PUBLIC ziti)
4 changes: 0 additions & 4 deletions programs/ziti-prox-c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

project(ziti-prox-c
VERSION ${CMAKE_PROJECT_VERSION}
LANGUAGES C CXX
)
add_executable(ziti-prox-c proxy.c)

if(WIN32)
Expand Down

0 comments on commit bdf8be2

Please sign in to comment.