Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update makefile, add install-client target #223

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ BINARY=keymaster

# These are the values we want to pass for Version and BuildTime
VERSION=1.15.3
DEFAULT_HOST?=
DEFAULT_LDFLAGS=-X main.Version=${VERSION}
CLIENT_LDFLAGS=${DEFAULT_LDFLAGS} -X main.defaultHost=${DEFAULT_HOST}
#BUILD_TIME=`date +%FT%T%z`

# keymaster client requires special tags on linux
Expand All @@ -26,20 +29,22 @@ endif
# Setup the -ldflags option for go build here, interpolate the variable values
#LDFLAGS=-ldflags "-X github.com/ariejan/roll/core.Version=${VERSION} -X github.com/ariejan/roll/core.BuildTime=${BUILD_TIME}"

all: init-config-host cmd/keymasterd/binData.go
cd cmd/keymaster; go install ${EXTRA_BUILD_FLAGS} -ldflags "-X main.Version=${VERSION}"
cd cmd/keymasterd; go install -ldflags "-X main.Version=${VERSION}"
cd cmd/keymaster-unlocker; go install -ldflags "-X main.Version=${VERSION}"
cd cmd/keymaster-eventmond; go install -ldflags "-X main.Version=${VERSION}"
all: install-client
cd cmd/keymasterd; go install -ldflags "${DEFAULT_LDFLAGS}"
cd cmd/keymaster-unlocker; go install -ldflags "${DEFAULT_LDFLAGS}"
cd cmd/keymaster-eventmond; go install -ldflags "${DEFAULT_LDFLAGS}"

build: cmd/keymasterd/binData.go
go build ${EXTRA_BUILD_FLAGS} -ldflags "-X main.Version=${VERSION}" -o bin/ ./...
go build ${EXTRA_BUILD_FLAGS} -ldflags "${DEFAULT_LDFLAGS}" -o bin/ ./...

cmd/keymasterd/binData.go:
-go-bindata -fs -o cmd/keymasterd/binData.go -prefix cmd/keymasterd/data cmd/keymasterd/data/...

install-client: init-config-host cmd/keymasterd/binData.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still need init-config-host? Seems like you can delete both the file, the make target and all references in the make target.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK will do it. I just didn't want to do a large change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

cd cmd/keymaster; go install ${EXTRA_BUILD_FLAGS} -ldflags "${CLIENT_LDFLAGS}"

win-client: client-test
go build -ldflags "-X main.Version=${VERSION}" -o bin .\cmd\keymaster\
go build -ldflags "${CLIENT_LDFLAGS}" -o bin .\cmd\keymaster\

client-test:
go test -v ./cmd/keymaster/...
Expand Down
5 changes: 3 additions & 2 deletions cmd/keymaster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
// process can inject the version number on the fly when building the
// binary. Use only from the Usage() function.
Version = defaultVersionNumber
defaultHost = defaultConfigHost
userAgentString = userAgentAppName
)

Expand Down Expand Up @@ -110,10 +111,10 @@ func loadConfigFile(client *http.Client, logger log.Logger) (
if err != nil {
logger.Fatal(err)
}
} else if len(defaultConfigHost) > 1 { // if there is a configHost AND there is NO config file, create one
} else if len(defaultHost) > 1 { // if there is a configHost AND there is NO config file, create one
if _, err := os.Stat(*configFilename); os.IsNotExist(err) {
err = config.GetConfigFromHost(
*configFilename, defaultConfigHost, client, logger)
*configFilename, defaultHost, client, logger)
if err != nil {
logger.Fatal(err)
}
Expand Down
Loading