mirror of
https://github.com/netdata/netdata.git
synced 2025-04-14 17:48:37 +00:00

* Integrate Go plugin with build system. * Fix Debian packaging rules. * Add FreeBSD support to Go toolchain handling. * Add Go ldflags handling. * Fix version detection when GCCGO is used. * Fix Go ldflags handling. * Correctly fix Go toolchain version detection. * Properly mark Go as a required dependency in CMake. * Disable VCS stamping as it does not work correctly on some platforms. * Autodetect minimum required Go version from go.mod files. This allows us to avoid needing to update the CMakeLists.txt file when the required version changes in a Go component’s go.mod file. * Prefix GoTools module name with Netdata to ensure we get our local module. * Update integrations code to use new Go plugin location. * Remove old go packaging files. * keep old logic for initial cleanup that is working * Re-sync Go plugin sources. * Fix search order for finding Go toolchain. * update module name * fix /usr/local/go overwrite condition --------- Co-authored-by: Fotis Voutsas <fotis@netdata.cloud> Co-authored-by: ilyam8 <ilya@netdata.cloud>
39 lines
1.2 KiB
CMake
39 lines
1.2 KiB
CMake
# Custom CMake module to find the Go toolchain
|
|
#
|
|
# Copyright (c) 2024 Netdata Inc
|
|
#
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
#
|
|
# This is a relatively orthodox CMake Find Module. It can be used by
|
|
# simply including it and then invoking `find_package(Go)`.
|
|
#
|
|
# Version handling is done by CMake itself via the
|
|
# find_package_handle_standard_args() function, so `find_package(Go 1.21)`
|
|
# will also work correctly.
|
|
|
|
if(GO_FOUND)
|
|
return()
|
|
endif()
|
|
|
|
# Two passes are needed here so that we prefer a copy in `/usr/local/go/bin` over a system copy.
|
|
find_program(GO_EXECUTABLE go PATHS /usr/local/go/bin DOC "Go toolchain" NO_DEFAULT_PATH)
|
|
find_program(GO_EXECUTABLE go DOC "Go toolchain")
|
|
|
|
if (GO_EXECUTABLE)
|
|
execute_process(
|
|
COMMAND ${GO_EXECUTABLE} version
|
|
OUTPUT_VARIABLE GO_VERSION_STRING
|
|
RESULT_VARIABLE RESULT
|
|
)
|
|
if (RESULT EQUAL 0)
|
|
string(REGEX MATCH "go([0-9]+\\.[0-9]+(\\.[0-9]+)?)" GO_VERSION_STRING "${GO_VERSION_STRING}")
|
|
string(REGEX MATCH "([0-9]+\\.[0-9]+(\\.[0-9]+)?)" GO_VERSION_STRING "${GO_VERSION_STRING}")
|
|
endif()
|
|
endif()
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package_handle_standard_args(
|
|
Go
|
|
REQUIRED_VARS GO_EXECUTABLE
|
|
VERSION_VAR GO_VERSION_STRING
|
|
)
|