Skip to content

Commit

Permalink
Merge mantle/Makefile into Makefile
Browse files Browse the repository at this point in the history
Add targets for the mantle binaries and kolet. Put mantle binaries into
the top-level `bin/` directory. Simplify `schema-check` docs and logic
since we're no longer double-vendoring the schema. Add `vendor` target.
  • Loading branch information
jlebon committed Jan 16, 2023
1 parent 74d7bfb commit 7b86d0b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 53 deletions.
25 changes: 15 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PYIGNORE ?= E128,E241,E402,E501,E722,W503,W504
.PHONY: all check shellcheck flake8 pycheck unittest clean mantle mantle-check install

MANTLE_BINARIES := ore kola plume
KOLET_ARCHES := aarch64 ppc64le s390x x86_64

all: bin/coreos-assembler mantle

Expand Down Expand Up @@ -66,16 +67,16 @@ clean:
rm -f ${src_checked} ${tests_checked} ${cwd_checked}
find . -name "*.py[co]" -type f | xargs rm -f
find . -name "__pycache__" -type d | xargs rm -rf
rm -rfv bin

mantle:
cd mantle && $(MAKE)
mantle: $(MANTLE_BINARIES) kolet

.PHONY: $(MANTLE_BINARIES) kolet
$(MANTLE_BINARIES) kolet:
cd mantle && $(MAKE) $@
mantle/build cmd/$(basename $@)

mantle-check:
cd mantle && $(MAKE) test
cd mantle && ./test

.PHONY: schema
schema:
Expand All @@ -84,17 +85,12 @@ schema:
# To update the coreos-assembler schema:
# Edit src/v1.json
# $ make schema
# $ (cd mantle && go mod vendor)
.PHONY: schema-check
schema-check: DIGEST = $(shell sha256sum src/v1.json | awk '{print $$1}')
schema-check:
# Is the generated Go code synced with the schema?
grep -q "$(DIGEST)" pkg/builds/cosa_v1.go
grep -q "$(DIGEST)" pkg/builds/schema_doc.go
# Are the vendored copies of the generated code synced with the
# canonical ones?
diff -u mantle/vendor/github.com/coreos/coreos-assembler/pkg/builds/cosa_v1.go pkg/builds/cosa_v1.go
diff -u mantle/vendor/github.com/coreos/coreos-assembler/pkg/builds/schema_doc.go pkg/builds/schema_doc.go

install:
install -d $(DESTDIR)$(PREFIX)/lib/coreos-assembler
Expand All @@ -111,4 +107,13 @@ install:
ln -sf ../lib/coreos-assembler/cp-reflink $(DESTDIR)$(PREFIX)/bin/
ln -sf coreos-assembler $(DESTDIR)$(PREFIX)/bin/cosa
install -d $(DESTDIR)$(PREFIX)/lib/coreos-assembler/tests/kola
cd mantle && $(MAKE) install DESTDIR=$(DESTDIR)
cd bin && install -D -t $(DESTDIR)$(PREFIX)/bin $(MANTLE_BINARIES)
for arch in $(KOLET_ARCHES); do \
install -D -m 0755 -t $(DESTDIR)$(PREFIX)/lib/kola/$${arch} bin/$${arch}/kolet; \
done

.PHONY: vendor
vendor:
@go mod vendor
@go mod tidy

40 changes: 0 additions & 40 deletions mantle/Makefile

This file was deleted.

6 changes: 3 additions & 3 deletions mantle/build
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ host_build() {
go build \
-ldflags "${ldflags}" \
-mod vendor \
-o "bin/$cmd" \
-o "../bin/$cmd" \
${race} \
"$@" "${REPO_PATH}/cmd/$cmd"
}
Expand All @@ -38,13 +38,13 @@ cross_static_build() {
local cmd=$1; shift
local a
for a in ${KOLET_ARCHES}; do \
mkdir -p "bin/$a"
mkdir -p "../bin/$a"
echo "Building $a/$cmd (static)"
CGO_ENABLED=0 GOARCH=${BASEARCH_TO_GOARCH[$a]} \
go build \
-ldflags "${ldflags} -extldflags=-static" \
-mod vendor \
-o "bin/$a/$cmd" \
-o "../bin/$a/$cmd" \
-tags osusergo,netgo \
"${REPO_PATH}/cmd/$cmd"
done
Expand Down

0 comments on commit 7b86d0b

Please sign in to comment.