Skip to content

Commit

Permalink
remove obsolete packaging/publishing (#267)
Browse files Browse the repository at this point in the history
* remove obsolete packaging/publishing
* fix: allow to build from source tarball
  • Loading branch information
ekoby authored Apr 15, 2021
1 parent e76be41 commit e7554e3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 68 deletions.
41 changes: 1 addition & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ if (DEFINED ENV{BUILD_NUMBER})
set(ZITI_BUILDNUM $ENV{BUILD_NUMBER})
endif ()

set(ZITI_VERSION ${PROJECT_VERSION}-${ZITI_BUILDNUM})

link_directories(${CMAKE_BINARY_DIR}/lib)

add_subdirectory(deps)
Expand All @@ -67,41 +65,6 @@ elseif (WIN32)
endif ()

include(CPack)
add_custom_target(publish
COMMENT "generate publish specs"
)

if(${GIT_BRANCH} STREQUAL main)
set(PUB_PFX ziti-staging)
else()
set(PUB_PFX ziti-snapshot/${GIT_BRANCH})
endif()

set(PUB_OPTS --apikey=$ENV{JFROG_API_KEY} --url https://netfoundry.jfrog.io/netfoundry --build-name=ziti --build-number=${ZITI_VERSION})
string(TOLOWER ${CMAKE_SYSTEM_NAME} PUB_OS)
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} PUB_ARCH)

if(${PUB_ARCH} STREQUAL "x86_64" )
set(PUB_ARCH "amd64")
endif()

macro(PUBCOMP comp)
set(${comp}_PUB_PATH ${PUB_PFX}/${comp}/${PUB_ARCH}/${PUB_OS}/${ZITI_VERSION}/${comp}.${archive_sfx})
set(${comp}_PUB_PROPS "version=${ZITI_VERSION}\;name=${comp}\;arch=${PUB_ARCH}\;os=${PUB_OS}\;branch=${GIT_BRANCH}")

add_custom_target(${comp}-pub
BYPRODUCTS ${CMAKE_BINARY_DIR}/${comp}-pub-spec.json
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${comp}-${ZITI_VERSION}-${CPACK_SYSTEM_NAME}.${archive_sfx}
COMMAND echo "{"
\"target\": \"${${comp}_PUB_PATH}\",
\"pattern\": \"${CMAKE_CURRENT_BINARY_DIR}/${comp}-${ZITI_VERSION}-${CPACK_SYSTEM_NAME}.${archive_sfx}\",
\"props\": \"${${comp}_PUB_PROPS}\"
"}" > ${CMAKE_BINARY_DIR}/${comp}-pub-spec.json
VERBATIM
)

add_dependencies(publish ${comp}-pub)
endmacro(PUBCOMP)

# use prefix length to trim path for logging, see utils.c
if (CMAKE_GENERATOR STREQUAL "Ninja" AND CMAKE_BINARY_DIR MATCHES "${CMAKE_SOURCE_DIR}")
Expand All @@ -115,9 +78,7 @@ endif()
add_subdirectory(library)

if (ZITI_BUILD_PROGRAMS)
if (NOT ${PUB_OS} STREQUAL "ios")
add_subdirectory(programs)
endif ()
add_subdirectory(programs)
endif ()

if (ZITI_BUILD_TESTS)
Expand Down
65 changes: 42 additions & 23 deletions git.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,51 @@
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
COMMAND git status
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
RESULT_VARIABLE GIT_STATUS
ERROR_QUIET
OUTPUT_QUIET
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 GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_STATUS EQUAL 0)
message("getting version from git")

execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_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 GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# lookup most recent tag to derive version
execute_process(
COMMAND git describe --tags HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_INFO
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(${GIT_INFO} MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)$")
set(ver ${GIT_INFO})
elseif(${GIT_INFO} MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-[^-]*")
string(JOIN "." ver ${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
endif()
message("project version: ${ver} (derived from git)")
else()
message("no git information available\ntrying to set version from ZITI_SDK_VERSION environment var")
set(ver $ENV{ZITI_SDK_VERSION})
set(GIT_COMMIT_HASH "")
set(GIT_BRANCH "unknown")
endif()

# capture build date
if (WIN32)
Expand All @@ -30,20 +63,6 @@ execute_process(
)
endif()

# lookup most recent tag to derive version
execute_process(
COMMAND git describe --tags HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_INFO
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(${GIT_INFO} MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)$")
set(ver ${GIT_INFO})
elseif(${GIT_INFO} MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-[^-]*")
string(JOIN "." ver ${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
endif()
message("project version: ${ver} (derived from git)")



6 changes: 1 addition & 5 deletions programs/ziti-prox-c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
project(ziti-prox-c)

add_executable(ziti-prox-c proxy.c)

Expand All @@ -10,7 +9,7 @@ endif()
target_link_libraries(ziti-prox-c PUBLIC ziti subcommand)
target_include_directories(ziti-prox-c PRIVATE ${ziti-sdk_SOURCE_DIR}/inc_internal)

set(ZITI_ARCHIVE_NAME "ziti-prox-c-${ZITI_VERSION}-${CPACK_SYSTEM_NAME}.${archive_sfx}")
set(ZITI_ARCHIVE_NAME "ziti-prox-c-${PROJECT_VERSION}-${CPACK_SYSTEM_NAME}.${archive_sfx}")
set(ZITI_EXECUTABLE_NAME "ziti-prox-c${CMAKE_EXECUTABLE_SUFFIX}")
if (UNIX)
add_custom_target(ziti-prox-c-pack
Expand All @@ -25,6 +24,3 @@ else()
COMMAND zip "${ZITI_ARCHIVE_NAME}" "${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE_INIT}/${ZITI_EXECUTABLE_NAME}"
)
endif()

#add_dependencies(publish ${ZITI_ARCHIVE_NAME})
PUBCOMP(ziti-prox-c)

0 comments on commit e7554e3

Please sign in to comment.