Skip to content

Commit

Permalink
Add Windows application manifest (#620)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
  • Loading branch information
jkroepke authored Apr 24, 2024
1 parent 40c8955 commit 219b1f2
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 5 deletions.
6 changes: 5 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
pkg/operator/crds/*.yaml linguist-generated=true

*.txtar text eol=lf
*.txtar text eol=lf
Makefile text eol=lf
tools/make/*.mk text eol=lf
tools/image-tag text eol=lf
tools/release text eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ buildx-v*
cover*.out
.uptodate
node_modules
*.syso

/docs/variables.mk.local

Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
## generate-helm-tests Generate Helm chart tests.
## generate-ui Generate the UI assets.
## generate-versioned-files Generate versioned files.
## generate-winmanifest Generate the Windows application manifest.
##
## Other targets:
##
Expand Down Expand Up @@ -210,8 +211,8 @@ alloy-image-windows:
# Targets for generating assets
#

.PHONY: generate generate-drone generate-helm-docs generate-helm-tests generate-ui generate-versioned-files
generate: generate-drone generate-helm-docs generate-helm-tests generate-ui generate-versioned-files generate-docs
.PHONY: generate generate-drone generate-helm-docs generate-helm-tests generate-ui generate-versioned-files generate-winmanifest
generate: generate-drone generate-helm-docs generate-helm-tests generate-ui generate-versioned-files generate-docs generate-winmanifest

generate-drone:
drone jsonnet -V BUILD_IMAGE_VERSION=$(BUILD_IMAGE_VERSION) --stream --format --source .drone/drone.jsonnet --target .drone/drone.yml
Expand Down Expand Up @@ -250,6 +251,13 @@ ifeq ($(USE_CONTAINER),1)
else
go generate ./docs
endif

generate-winmanifest:
ifeq ($(USE_CONTAINER),1)
$(RERUN_IN_CONTAINER)
else
go generate ./internal/winmanifest
endif
#
# Other targets
#
Expand Down
3 changes: 3 additions & 0 deletions internal/cmd/alloy-service/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"golang.org/x/sys/windows/svc"

// Embed application manifest for Windows builds
_ "github.com/grafana/alloy/internal/winmanifest"
)

const serviceName = "Alloy"
Expand Down
9 changes: 9 additions & 0 deletions internal/winmanifest/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Package winmanifest provides a basic manifest.
//
// You import it for its side effects only, as
//
// import _ "github.com/grafana/alloy/internal/winmanifest"
//
// On non-Windows platforms this package does nothing.

package winmanifest
3 changes: 3 additions & 0 deletions internal/winmanifest/generate_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package winmanifest

//go:generate go run github.com/tc-hib/go-winres@v0.3.3 make --product-version=git-tag --file-version=git-tag
44 changes: 44 additions & 0 deletions internal/winmanifest/winres/winres.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"RT_GROUP_ICON": {
"#1": {
"0000": "../../../packaging/windows/logo.ico"
}
},
"RT_MANIFEST": {
"#1": {
"0409": {
"description": "OpenTelemetry Collector distribution with programmable pipelines",
"minimum-os": "win7",
"execution-level": "as invoker",
"ui-access": false,
"long-path-aware": true
}
}
},
"RT_VERSION": {
"#1": {
"0000": {
"fixed": {
"file_version": "0.0.0.0",
"product_version": "0.0.0.0"
},
"info": {
"0409": {
"Comments": "",
"CompanyName": "Grafana Labs",
"FileDescription": "OpenTelemetry Collector distribution with programmable pipelines",
"FileVersion": "",
"InternalName": "",
"LegalCopyright": "Grafana Labs",
"LegalTrademarks": "",
"OriginalFilename": "",
"PrivateBuild": "",
"ProductName": "Grafana Alloy",
"ProductVersion": "",
"SpecialBuild": ""
}
}
}
}
}
}
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import (
// Embed a set of fallback X.509 trusted roots
// Allows the app to work correctly even when the OS does not provide a verifier or systems roots pool
_ "golang.org/x/crypto/x509roots/fallback"

// Embed application manifest for Windows builds
_ "github.com/grafana/alloy/internal/winmanifest"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions tools/make/packaging.mk
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dist/alloy-darwin-arm64: generate-ui
dist/alloy-windows-amd64.exe: GO_TAGS += builtinassets
dist/alloy-windows-amd64.exe: GOOS := windows
dist/alloy-windows-amd64.exe: GOARCH := amd64
dist/alloy-windows-amd64.exe: generate-ui
dist/alloy-windows-amd64.exe: generate-ui generate-winmanifest
$(PACKAGING_VARS) ALLOY_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy

# NOTE(rfratto): do not use netgo when building Windows binaries, which
Expand Down Expand Up @@ -102,7 +102,7 @@ dist-alloy-service-binaries: dist.temp/alloy-service-windows-amd64.exe
dist.temp/alloy-service-windows-amd64.exe: GO_TAGS += builtinassets
dist.temp/alloy-service-windows-amd64.exe: GOOS := windows
dist.temp/alloy-service-windows-amd64.exe: GOARCH := amd64
dist.temp/alloy-service-windows-amd64.exe: generate-ui
dist.temp/alloy-service-windows-amd64.exe: generate-ui generate-winmanifest
$(PACKAGING_VARS) SERVICE_BINARY=$@ "$(MAKE)" -f $(PARENT_MAKEFILE) alloy-service

#
Expand Down

0 comments on commit 219b1f2

Please sign in to comment.