feat: add arm64 Windows builds (#12130)

This commit is contained in:
Joshua Powers 2022-11-08 13:44:51 -07:00 committed by GitHub
parent 7c7069d693
commit 6390d31eb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 173 additions and 62 deletions

View File

@ -151,7 +151,7 @@ commands:
condition:
equal: [ windows, << parameters.type >> ]
steps:
- run: make versioninfo
- run: go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.4.0
- when:
condition: << parameters.nightly >>
steps:

View File

@ -107,12 +107,6 @@ deps:
version:
@echo $(version)-$(commit)
.PHONY: versioninfo
versioninfo:
go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.4.0; \
go run scripts/generate_versioninfo/main.go; \
go generate cmd/telegraf/telegraf_windows.go; \
build_tools:
$(HOSTGO) build -o ./tools/custom_builder/custom_builder$(EXEEXT) ./tools/custom_builder
$(HOSTGO) build -o ./tools/license_checker/license_checker$(EXEEXT) ./tools/license_checker
@ -224,6 +218,8 @@ clean:
rm -f telegraf
rm -f telegraf.exe
rm -rf build
rm -rf cmd/telegraf/resource.syso
rm -rf cmd/telegraf/versioninfo.json
rm -rf tools/custom_builder/custom_builder
rm -rf tools/custom_builder/custom_builder.exe
rm -rf tools/readme_config_includer/generator
@ -316,7 +312,7 @@ i386 += freebsd_i386.tar.gz i386.deb linux_i386.tar.gz i386.rpm
.PHONY: i386
i386:
@ echo $(i386)
windows += windows_i386.zip windows_amd64.zip
windows += windows_i386.zip windows_amd64.zip windows_arm64.zip
.PHONY: windows
windows:
@ echo $(windows)
@ -337,6 +333,8 @@ package: docs $(include_packages)
.PHONY: $(include_packages)
$(include_packages):
if [ "$(suffix $@)" = ".zip" ]; then go generate cmd/telegraf/telegraf_windows.go; fi
@$(MAKE) install
@mkdir -p $(pkgdir)
@ -443,6 +441,9 @@ freebsd_armv7.tar.gz: export GOARM := 7
windows_amd64.zip: export GOOS := windows
windows_amd64.zip: export GOARCH := amd64
windows_arm64.zip: export GOOS := windows
windows_arm64.zip: export GOARCH := arm64
darwin_amd64.tar.gz: export GOOS := darwin
darwin_amd64.tar.gz: export GOARCH := amd64
@ -452,11 +453,11 @@ darwin_arm64.tar.gz: export GOARCH := arm64
windows_i386.zip: export GOOS := windows
windows_i386.zip: export GOARCH := 386
windows_i386.zip windows_amd64.zip: export prefix =
windows_i386.zip windows_amd64.zip: export bindir = $(prefix)
windows_i386.zip windows_amd64.zip: export sysconfdir = $(prefix)
windows_i386.zip windows_amd64.zip: export localstatedir = $(prefix)
windows_i386.zip windows_amd64.zip: export EXEEXT := .exe
windows_i386.zip windows_amd64.zip windows_arm64.zip: export prefix =
windows_i386.zip windows_amd64.zip windows_arm64.zip: export bindir = $(prefix)
windows_i386.zip windows_amd64.zip windows_arm64.zip: export sysconfdir = $(prefix)
windows_i386.zip windows_amd64.zip windows_arm64.zip: export localstatedir = $(prefix)
windows_i386.zip windows_amd64.zip windows_arm64.zip: export EXEEXT := .exe
%.deb: export pkg := deb
%.deb: export prefix := /usr

View File

@ -1,6 +1,6 @@
//go:build windows
//go:generate goversioninfo -icon=../../assets/windows/tiger.ico
//go:generate ../../scripts/windows-gen-syso.sh $GOARCH
package main

View File

@ -6,8 +6,8 @@ These builds are generated from the master branch each night:
| DEB | RPM | TAR GZ | ZIP |
| --------------- | --------------- | ------------------------------| --- |
| [amd64.deb](https://dl.influxdata.com/telegraf/nightlies/telegraf_nightly_amd64.deb) | [aarch64.rpm](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly.aarch64.rpm) | [darwin_amd64.tar.gz](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_darwin_amd64.tar.gz) | [windows_amd64.zip](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_windows_amd64.zip) |
| [arm64.deb](https://dl.influxdata.com/telegraf/nightlies/telegraf_nightly_arm64.deb) | [armel.rpm](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly.armel.rpm) | [darwin_arm64.tar.gz](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_darwin_arm64.tar.gz) | [windows_i386.zip](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_windows_i386.zip) |
| [armel.deb](https://dl.influxdata.com/telegraf/nightlies/telegraf_nightly_armel.deb) | [armv6hl.rpm](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly.armv6hl.rpm) | [freebsd_amd64.tar.gz](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_freebsd_amd64.tar.gz) | |
| [arm64.deb](https://dl.influxdata.com/telegraf/nightlies/telegraf_nightly_arm64.deb) | [armel.rpm](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly.armel.rpm) | [darwin_arm64.tar.gz](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_darwin_arm64.tar.gz) | [windows_arm64.zip](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_windows_arm64.zip) |
| [armel.deb](https://dl.influxdata.com/telegraf/nightlies/telegraf_nightly_armel.deb) | [armv6hl.rpm](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly.armv6hl.rpm) | [freebsd_amd64.tar.gz](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_freebsd_amd64.tar.gz) | [windows_i386.zip](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_windows_i386.zip) |
| [armhf.deb](https://dl.influxdata.com/telegraf/nightlies/telegraf_nightly_armhf.deb) | [i386.rpm](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly.i386.rpm) | [freebsd_armv7.tar.gz](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_freebsd_armv7.tar.gz) | |
| [i386.deb](https://dl.influxdata.com/telegraf/nightlies/telegraf_nightly_i386.deb) | [ppc64le.rpm](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly.ppc64le.rpm) | [freebsd_i386.tar.gz](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_freebsd_i386.tar.gz) | |
| [mips.deb](https://dl.influxdata.com/telegraf/nightlies/telegraf_nightly_mips.deb) | [riscv64.rpm](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly.riscv64.rpm) | [linux_amd64.tar.gz](https://dl.influxdata.com/telegraf/nightlies/telegraf-nightly_linux_amd64.tar.gz) | |

View File

@ -0,0 +1,137 @@
// Copyright (c) 2010 The win Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of the authors may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// This is the official list of 'win' authors for copyright purposes.
//
// Alexander Neumann <an2048@googlemail.com>
// Joseph Watson <jtwatson@linux-consulting.us>
// Kevin Pors <krpors@gmail.com>
//go:build windows
package win_perf_counters
// Union specialization for double values
type PDH_FMT_COUNTERVALUE_DOUBLE struct {
CStatus uint32
DoubleValue float64
}
// Union specialization for 64 bit integer values
type PDH_FMT_COUNTERVALUE_LARGE struct {
CStatus uint32
LargeValue int64
}
// Union specialization for long values
type PDH_FMT_COUNTERVALUE_LONG struct {
CStatus uint32
LongValue int32
padding [4]byte
}
type PDH_FMT_COUNTERVALUE_ITEM_DOUBLE struct {
SzName *uint16
FmtValue PDH_FMT_COUNTERVALUE_DOUBLE
}
// Union specialization for 'large' values, used by PdhGetFormattedCounterArrayLarge()
type PDH_FMT_COUNTERVALUE_ITEM_LARGE struct {
SzName *uint16 // pointer to a string
FmtValue PDH_FMT_COUNTERVALUE_LARGE
}
// Union specialization for long values, used by PdhGetFormattedCounterArrayLong()
type PDH_FMT_COUNTERVALUE_ITEM_LONG struct {
SzName *uint16 // pointer to a string
FmtValue PDH_FMT_COUNTERVALUE_LONG
}
// PDH_COUNTER_INFO structure contains information describing the properties of a counter. This information also includes the counter path.
type PDH_COUNTER_INFO struct {
//Size of the structure, including the appended strings, in bytes.
DwLength uint32
//Counter type. For a list of counter types, see the Counter Types section of the <a "href=http://go.microsoft.com/fwlink/p/?linkid=84422">Windows Server 2003 Deployment Kit</a>.
//The counter type constants are defined in Winperf.h.
DwType uint32
//Counter version information. Not used.
CVersion uint32
//Counter status that indicates if the counter value is valid. For a list of possible values,
//see <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa371894(v=vs.85).aspx">Checking PDH Interface Return Values</a>.
CStatus uint32
//Scale factor to use when computing the displayable value of the counter. The scale factor is a power of ten.
//The valid range of this parameter is PDH_MIN_SCALE (7) (the returned value is the actual value times 10⁷) to
//PDH_MAX_SCALE (+7) (the returned value is the actual value times 10⁺⁷). A value of zero will set the scale to one, so that the actual value is returned
LScale int32
//Default scale factor as suggested by the counter's provider.
LDefaultScale int32
//The value passed in the dwUserData parameter when calling PdhAddCounter.
DwUserData *uint32
//The value passed in the dwUserData parameter when calling PdhOpenQuery.
DwQueryUserData *uint32
//Null-terminated string that specifies the full counter path. The string follows this structure in memory.
SzFullPath *uint16 // pointer to a string
//Null-terminated string that contains the name of the computer specified in the counter path. Is NULL, if the path does not specify a computer.
//The string follows this structure in memory.
SzMachineName *uint16 // pointer to a string
//Null-terminated string that contains the name of the performance object specified in the counter path. The string follows this structure in memory.
SzObjectName *uint16 // pointer to a string
//Null-terminated string that contains the name of the object instance specified in the counter path. Is NULL, if the path does not specify an instance.
//The string follows this structure in memory.
SzInstanceName *uint16 // pointer to a string
//Null-terminated string that contains the name of the parent instance specified in the counter path. Is NULL, if the path does not specify a parent instance.
//The string follows this structure in memory.
SzParentInstance *uint16 // pointer to a string
//Instance index specified in the counter path. Is 0, if the path does not specify an instance index.
DwInstanceIndex uint32 // pointer to a string
//Null-terminated string that contains the counter name. The string follows this structure in memory.
SzCounterName *uint16 // pointer to a string
//Help text that describes the counter. Is NULL if the source is a log file.
SzExplainText *uint16 // pointer to a string
//Start of the string data that is appended to the structure.
DataBuffer [1]uint32 // pointer to an extra space
}
// The PDH_RAW_COUNTER structure returns the data as it was collected from the counter provider. No translation, formatting, or other interpretation is performed on the data
type PDH_RAW_COUNTER struct {
// Counter status that indicates if the counter value is valid. Check this member before using the data in a calculation or displaying its value. For a list of possible values,
// see https://docs.microsoft.com/windows/desktop/PerfCtrs/checking-pdh-interface-return-values
CStatus uint32
// Local time for when the data was collected
TimeStamp FILETIME
// First raw counter value.
FirstValue int64
// Second raw counter value. Rate counters require two values in order to compute a displayable value.
SecondValue int64
// If the counter type contains the PERF_MULTI_COUNTER flag, this member contains the additional counter data used in the calculation.
// For example, the PERF_100NSEC_MULTI_TIMER counter type contains the PERF_MULTI_COUNTER flag.
MultiCount uint32
}
type PDH_RAW_COUNTER_ITEM struct {
// Pointer to a null-terminated string that specifies the instance name of the counter. The string is appended to the end of this structure.
SzName *uint16
//A PDH_RAW_COUNTER structure that contains the raw counter value of the instance
RawValue PDH_RAW_COUNTER
}

View File

@ -1,46 +0,0 @@
// Generate the versioninfo.json with the current build version from the makefile
// The file versioninfo.json is used by the goversioninfo package to add version info into a windows binary
package main
import (
"bytes"
"encoding/json"
"log"
"os"
"os/exec"
"strings"
)
type VersionInfo struct {
StringFileInfo StringFileInfo
}
type StringFileInfo struct {
ProductName string
ProductVersion string
}
func main() {
e := exec.Command("make", "version")
var out bytes.Buffer
e.Stdout = &out
if err := e.Run(); err != nil {
log.Fatalf("Failed to get version from makefile: %v", err)
}
version := strings.TrimSuffix(out.String(), "\n")
v := VersionInfo{
StringFileInfo: StringFileInfo{
ProductName: "Telegraf",
ProductVersion: version,
},
}
file, err := json.MarshalIndent(v, "", " ")
if err != nil {
log.Fatalf("Failed to marshal json: %v", err)
}
if err := os.WriteFile("cmd/telegraf/versioninfo.json", file, 0644); err != nil {
log.Fatalf("Failed to write versioninfo.json: %v", err)
}
}

19
scripts/windows-gen-syso.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Run goversioninfo to generate the resource.syso to embed version info.
set -eux
NAME="Telegraf"
VERSION=$(cd ../../ && make version)
FLAGS=()
# If building for arm64, then incude the extra flags required.
if [ -n "${1+x}" ] && [ "$1" = "arm64" ]; then
FLAGS=(-arm -64)
fi
goversioninfo "${FLAGS[@]}" \
-product-name "$NAME" \
-product-version "$VERSION" \
-skip-versioninfo \
-icon=../../assets/windows/tiger.ico \
-o resource.syso