This is an automated email from the ASF dual-hosted git repository.
rkieley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/master by this push:
new 8c6d4ea PROTON-2160: Implemented cmake check to enforce golang
version 1.11+ required.
8c6d4ea is described below
commit 8c6d4eadffbcf28dea8068ca0e14ab199d5f745b
Author: Roddie Kieley <[email protected]>
AuthorDate: Tue Dec 10 23:17:32 2019 -0330
PROTON-2160: Implemented cmake check to enforce golang version 1.11+
required.
---
go/CMakeLists.txt | 147 +++++++++++++++++++++++++++++-------------------------
1 file changed, 78 insertions(+), 69 deletions(-)
diff --git a/go/CMakeLists.txt b/go/CMakeLists.txt
index 377c514..4c61eb8 100644
--- a/go/CMakeLists.txt
+++ b/go/CMakeLists.txt
@@ -19,74 +19,83 @@
# Go version
execute_process(COMMAND ${GO_EXE} version OUTPUT_VARIABLE go_ver
OUTPUT_STRIP_TRAILING_WHITESPACE)
-message(STATUS "Found Go: ${GO_EXE} (${go_ver})")
-
-# NOTE: go test -race flag is not included by default, it causes problems on
several platforms:
-# - ubuntu up to trust: link errors
-# - ubuntu from xenial: requires extra package golang-race-detector-runtime
-# - fedora with gccgo: complains about "import cycles"
-# (Works well on fedora with original go)
-# Enable manually with -DGO_TEST_FLAGS="-v -race"
-
-set(GO_BUILD_FLAGS "" CACHE STRING "Flags for 'go build'")
-set(GO_VET_FLAGS "-v" CACHE STRING "Flags for 'go test'")
-set(GO_TEST_FLAGS "-v" CACHE STRING "Flags for 'go test'")
-
-# Flags that differ for golang go and gcc go.
-if (go_ver MATCHES "gccgo")
- set(GO_RPATH_FLAGS -gccgoflags "-Wl,-rpath=${PN_C_LIBRARY_DIR}")
-else()
- set(GO_RPATH_FLAGS -ldflags "-r ${PN_C_LIBRARY_DIR}")
+string(REGEX MATCH "go[0-9]+.[0-9]+[0-9]*" GO_VERSION "${go_ver}")
+string(SUBSTRING ${GO_VERSION} 2 -1 GOLESS_VERSION)
+message(STATUS "Found Go: ${GO_EXE} (${go_ver}) (${GOLESS_VERSION}).")
+
+if (GOLESS_VERSION VERSION_LESS 1.11)
+ set(BUILD_GO "OFF")
+ message(STATUS "Go: ${GO_EXE} (${GOLESS_VERSION}) version to low. At least
1.11 required.")
endif()
-separate_arguments(GO_BUILD_FLAGS)
-separate_arguments(GO_TEST_FLAGS)
-
-# Create a Go tree in the binary directory, link pkg to the source directory,
link go.mod file
-set(GOPATH ${CMAKE_CURRENT_BINARY_DIR})
-add_custom_target(go-pkg-link ALL
- COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/pkg
${GOPATH}/pkg)
-add_custom_target(go-mod-link ALL
- COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/../go.mod ${GOPATH}/../go.mod)
-
-# Following are CACHE INTERNAL so examples/CMakeLists.txt can see them.
-set(GO_ENV ${PN_ENV_SCRIPT} --
- "GOPATH=${GOPATH}"
- "CGO_CFLAGS=-I${PN_C_INCLUDE_DIR}"
- "CGO_LDFLAGS=-L${PN_C_LIBRARY_DIR}"
- "PN_INTEROP_DIR=${CMAKE_SOURCE_DIR}/tests/interop"
- "SASLPASSWD=${CyrusSASL_Saslpasswd_EXECUTABLE}"
- CACHE INTERNAL "Run a command with Go environment variables")
-
-set(GO ${GO_ENV} ${GO_EXE} CACHE INTERNAL "Run go with environment set")
-
-set(GO_BUILD ${GO} build ${GO_BUILD_FLAGS} ${GO_RPATH_FLAGS} CACHE INTERNAL
"Run go build")
-set(GO_INSTALL ${GO} install ${GO_BUILD_FLAGS} CACHE INTERNAL "Run go install"
)
-set(GO_TEST ${GO} test ${GO_BUILD_FLAGS} ${GO_RPATH_FLAGS} ${GO_TEST_FLAGS}
CACHE INTERNAL "Run go test")
-
-# The go build tools handle dependency checks and incremental builds better
than
-# CMake so just run them every time, they do nothing if nothing needs to be
-# done.
-add_custom_target(go-build ALL
- COMMAND ${GO_INSTALL} $ENV{PWD}/go/pkg/...
- DEPENDS qpid-proton-core go-pkg-link go-mod-link
- WORKING_DIRECTORY $ENV{PWD})
-
-add_test(
- NAME go-test COMMAND ${GO_TEST} $ENV{PWD}/go/pkg/...
- WORKING_DIRECTORY $ENV{PWD})
-
-# Clean up go output directories.
-list(APPEND ADDITIONAL_MAKE_CLEAN_FILES ${GOPATH}/pkg ${GOPATH}/bin)
-
-add_subdirectory(examples)
-
-# Install go sources.
-set (GO_INSTALL_DIR ${SHARE_INSTALL_DIR}/gocode/pkg CACHE PATH "Installation
directory for Go code")
-mark_as_advanced (GO_INSTALL_DIR)
-
-install(DIRECTORY pkg DESTINATION ${GO_INSTALL_DIR} COMPONENT Go)
-install(DIRECTORY examples/
- DESTINATION "${PROTON_SHARE}/examples/go"
- COMPONENT Go
- PATTERN "CMakeLists.txt" EXCLUDE)
+if (BUILD_GO)
+ # NOTE: go test -race flag is not included by default, it causes problems on
several platforms:
+ # - ubuntu up to trust: link errors
+ # - ubuntu from xenial: requires extra package golang-race-detector-runtime
+ # - fedora with gccgo: complains about "import cycles"
+ # (Works well on fedora with original go)
+ # Enable manually with -DGO_TEST_FLAGS="-v -race"
+
+ set(GO_BUILD_FLAGS "" CACHE STRING "Flags for 'go build'")
+ set(GO_VET_FLAGS "-v" CACHE STRING "Flags for 'go test'")
+ set(GO_TEST_FLAGS "-v" CACHE STRING "Flags for 'go test'")
+
+ # Flags that differ for golang go and gcc go.
+ if (go_ver MATCHES "gccgo")
+ set(GO_RPATH_FLAGS -gccgoflags "-Wl,-rpath=${PN_C_LIBRARY_DIR}")
+ else()
+ set(GO_RPATH_FLAGS -ldflags "-r ${PN_C_LIBRARY_DIR}")
+ endif()
+
+ separate_arguments(GO_BUILD_FLAGS)
+ separate_arguments(GO_TEST_FLAGS)
+
+ # Create a Go tree in the binary directory, link pkg to the source
directory, link go.mod file
+ set(GOPATH ${CMAKE_CURRENT_BINARY_DIR})
+ add_custom_target(go-pkg-link ALL
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/pkg
${GOPATH}/pkg)
+ add_custom_target(go-mod-link ALL
+ COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/../go.mod ${GOPATH}/../go.mod)
+
+ # Following are CACHE INTERNAL so examples/CMakeLists.txt can see them.
+ set(GO_ENV ${PN_ENV_SCRIPT} --
+ "GOPATH=${GOPATH}"
+ "CGO_CFLAGS=-I${PN_C_INCLUDE_DIR}"
+ "CGO_LDFLAGS=-L${PN_C_LIBRARY_DIR}"
+ "PN_INTEROP_DIR=${CMAKE_SOURCE_DIR}/tests/interop"
+ "SASLPASSWD=${CyrusSASL_Saslpasswd_EXECUTABLE}"
+ CACHE INTERNAL "Run a command with Go environment variables")
+
+ set(GO ${GO_ENV} ${GO_EXE} CACHE INTERNAL "Run go with environment set")
+
+ set(GO_BUILD ${GO} build ${GO_BUILD_FLAGS} ${GO_RPATH_FLAGS} CACHE INTERNAL
"Run go build")
+ set(GO_INSTALL ${GO} install ${GO_BUILD_FLAGS} CACHE INTERNAL "Run go
install" )
+ set(GO_TEST ${GO} test ${GO_BUILD_FLAGS} ${GO_RPATH_FLAGS} ${GO_TEST_FLAGS}
CACHE INTERNAL "Run go test")
+
+ # The go build tools handle dependency checks and incremental builds better
than
+ # CMake so just run them every time, they do nothing if nothing needs to be
+ # done.
+ add_custom_target(go-build ALL
+ COMMAND ${GO_INSTALL} $ENV{PWD}/go/pkg/...
+ DEPENDS qpid-proton-core go-pkg-link go-mod-link
+ WORKING_DIRECTORY $ENV{PWD})
+
+ add_test(
+ NAME go-test COMMAND ${GO_TEST} $ENV{PWD}/go/pkg/...
+ WORKING_DIRECTORY $ENV{PWD})
+
+ # Clean up go output directories.
+ list(APPEND ADDITIONAL_MAKE_CLEAN_FILES ${GOPATH}/pkg ${GOPATH}/bin)
+
+ add_subdirectory(examples)
+
+ # Install go sources.
+ set (GO_INSTALL_DIR ${SHARE_INSTALL_DIR}/gocode/pkg CACHE PATH "Installation
directory for Go code")
+ mark_as_advanced (GO_INSTALL_DIR)
+
+ install(DIRECTORY pkg DESTINATION ${GO_INSTALL_DIR} COMPONENT Go)
+ install(DIRECTORY examples/
+ DESTINATION "${PROTON_SHARE}/examples/go"
+ COMPONENT Go
+ PATTERN "CMakeLists.txt" EXCLUDE)
+endif()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]