Skip to content

Commit

Permalink
Refactor use Absolute path for Makefile (#2670)
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango authored Oct 4, 2024
1 parent da0ac80 commit da446c0
Show file tree
Hide file tree
Showing 55 changed files with 244 additions and 219 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,18 @@ GIT_COMMIT := $(eval GIT_COMMIT := $(shell git rev-list -1 HEAD))$(GIT_COMMIT)
MAKELISTS := Makefile $(shell find Makefile.d -type f -regex ".*\.mk")

ROOTDIR = $(eval ROOTDIR := $(or $(shell git rev-parse --show-toplevel), $(PWD)))$(ROOTDIR)
PROTODIRS := $(eval PROTODIRS := $(shell find apis/proto -type d | sed -e "s%apis/proto/%%g" | grep -v "apis/proto"))$(PROTODIRS)
PROTODIRS := $(eval PROTODIRS := $(shell find $(ROOTDIR)/apis/proto -type d | sed -e "s%apis/proto/%%g" | grep -v "apis/proto"))$(PROTODIRS)
BENCH_DATASET_BASE_DIR = hack/benchmark/assets
BENCH_DATASET_MD5_DIR_NAME = checksum
BENCH_DATASET_HDF5_DIR_NAME = dataset
BENCH_DATASET_MD5_DIR = $(BENCH_DATASET_BASE_DIR)/$(BENCH_DATASET_MD5_DIR_NAME)
BENCH_DATASET_HDF5_DIR = $(BENCH_DATASET_BASE_DIR)/$(BENCH_DATASET_HDF5_DIR_NAME)

PROTOS := $(eval PROTOS := $(shell find apis/proto -type f -regex ".*\.proto"))$(PROTOS)
PROTOS := $(eval PROTOS := $(shell find $(ROOTDIR)/apis/proto -type f -regex ".*\.proto"))$(PROTOS)
PROTOS_V1 := $(eval PROTOS_V1 := $(filter apis/proto/v1/%.proto,$(PROTOS)))$(PROTOS_V1)
PBGOS = $(PROTOS:apis/proto/%.proto=apis/grpc/%.pb.go)
SWAGGERS = $(PROTOS:apis/proto/%.proto=apis/swagger/%.swagger.json)
PBDOCS = apis/docs/v1/docs.md
PBDOCS = $(ROOTDIR)/apis/docs/v1/docs.md

LDFLAGS = -static -fPIC -pthread -std=gnu++23 -lstdc++ -lm -z relro -z now -flto=auto -march=native -mtune=native -fno-plt -Ofast -fvisibility=hidden -ffp-contract=fast -fomit-frame-pointer -fmerge-all-constants -funroll-loops -falign-functions=32 -ffunction-sections -fdata-sections

Expand Down Expand Up @@ -795,13 +795,13 @@ changelog/update:
echo "" >> $(TEMP_DIR)/CHANGELOG.md
$(MAKE) -s changelog/next/print >> $(TEMP_DIR)/CHANGELOG.md
echo "" >> $(TEMP_DIR)/CHANGELOG.md
tail -n +2 CHANGELOG.md >> $(TEMP_DIR)/CHANGELOG.md
mv -f $(TEMP_DIR)/CHANGELOG.md CHANGELOG.md
tail -n +2 $(ROOTDIR)/CHANGELOG.md >> $(TEMP_DIR)/CHANGELOG.md
mv -f $(TEMP_DIR)/CHANGELOG.md $(ROOTDIR)/CHANGELOG.md

.PHONY: changelog/next/print
## print next changelog entry
changelog/next/print:
@cat hack/CHANGELOG.template.md | \
@cat $(ROOTDIR)/hack/CHANGELOG.template.md | \
sed -e 's/{{ version }}/$(VERSION)/g'
@echo "$$BODY"

Expand Down
4 changes: 2 additions & 2 deletions Makefile.d/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ifeq ($(REMOTE),true)
-t $(GHCRORG)/$(IMAGE):$(TAG) \
$(EXTRA_ARGS) \
--output type=registry,oci-mediatypes=true,compression=zstd,compression-level=5,force-compression=true,push=true \
-f $(DOCKERFILE) .
-f $(DOCKERFILE) $(ROOTDIR)
else
@echo "starting local build for $(IMAGE):$(TAG)"
DOCKER_BUILDKIT=1 $(DOCKER) build \
Expand All @@ -113,7 +113,7 @@ else
$(EXTRA_ARGS) \
-t $(CRORG)/$(IMAGE):$(TAG) \
-t $(GHCRORG)/$(IMAGE):$(TAG) \
-f $(DOCKERFILE) .
-f $(DOCKERFILE) $(ROOTDIR)
endif

.PHONY: docker/name/agent-ngt
Expand Down
3 changes: 1 addition & 2 deletions Makefile.d/functions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ define go-build
-X '$(GOPKG)/internal/info.AlgorithmInfo=$5' \
-X '$(GOPKG)/internal/info.BuildCPUInfoFlags=$(CPU_INFO_FLAGS)' \
-X '$(GOPKG)/internal/info.BuildTime=$(DATETIME)' \
-X '$(GOPKG)/internal/info.CGOEnabled=$(CGO_ENABLED)' \
-X '$(GOPKG)/internal/info.CGOEnabled=$(if $(filter 1,$(strip $(CGO_ENABLED))),true,false)' \
-X '$(GOPKG)/internal/info.GitCommit=$(GIT_COMMIT)' \
-X '$(GOPKG)/internal/info.GoArch=$(GOARCH)' \
-X '$(GOPKG)/internal/info.GoOS=$(GOOS)' \
Expand Down Expand Up @@ -434,4 +434,3 @@ define gen-deadlink-checker
$$BIN_PATH -path $3 -ignore-path $4 -format $5 $1; \
rm -rf $$BIN_PATH
endef

2 changes: 1 addition & 1 deletion Makefile.d/git.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
.PHONY: git/config/init
## add git configs required for development
git/config/init:
git config commit.template ".commit_template"
git config commit.template "$(ROOTDIR)/.commit_template"
git config core.fileMode false

.PHONY: git/hooks/init
Expand Down
78 changes: 39 additions & 39 deletions Makefile.d/helm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,69 +37,69 @@ $(BINDIR)/helm-docs:
.PHONY: helm/package/vald
## packaging Helm chart for Vald
helm/package/vald:
helm package charts/vald
helm package $(ROOTDIR)/charts/vald

.PHONY: helm/package/vald-helm-operator
## packaging Helm chart for vald-helm-operator
helm/package/vald-helm-operator: \
helm/schema/crd/vald \
helm/schema/crd/vald-helm-operator
helm package charts/vald-helm-operator
helm package $(ROOTDIR)/charts/vald-helm-operator

.PHONY: helm/package/vald-benchmark-operator
## packaging Helm chart for vald-helm-operator
helm/package/vald-benchmark-operator: \
helm/schema/crd/vald-benchmark-job \
helm/schema/crd/vald-benchmark-scenario \
helm/schema/crd/vald-benchmark-operator
helm package charts/vald-benchmark-operator
helm package $(ROOTDIR)/charts/vald-benchmark-operator

.PHONY: helm/package/vald-readreplica
helm/package/vald-readreplica:
helm package charts/vald-readreplica
helm package $(ROOTDIR)/charts/vald-readreplica

.PHONY: helm/repo/add
## add Helm chart repository
helm/repo/add:
helm repo add vald https://vald.vdaas.org/charts

.PHONY: helm/docs/vald
helm/docs/vald: charts/vald/README.md
helm/docs/vald: $(ROOTDIR)/charts/vald/README.md

# force to rebuild
.PHONY: charts/vald/README.md
charts/vald/README.md: \
charts/vald/README.md.gotmpl \
charts/vald/values.yaml
.PHONY: $(ROOTDIR)/charts/vald/README.md
$(ROOTDIR)/charts/vald/README.md: \
$(ROOTDIR)/charts/vald/README.md.gotmpl \
$(ROOTDIR)/charts/vald/values.yaml
helm-docs

.PHONY: helm/docs/vald-helm-operator
helm/docs/vald-helm-operator: charts/vald-helm-operator/README.md
helm/docs/vald-helm-operator: $(ROOTDIR)/charts/vald-helm-operator/README.md

# force to rebuild
.PHONY: charts/vald-helm-operator/README.md
charts/vald-helm-operator/README.md: \
charts/vald-helm-operator/README.md.gotmpl \
charts/vald-helm-operator/values.yaml
.PHONY: $(ROOTDIR)/charts/vald-helm-operator/README.md
$(ROOTDIR)/charts/vald-helm-operator/README.md: \
$(ROOTDIR)/charts/vald-helm-operator/README.md.gotmpl \
$(ROOTDIR)/charts/vald-helm-operator/values.yaml
helm-docs

.PHONY: helm/docs/vald-readreplica
helm/docs/vald-readreplica: charts/vald-readreplica/README.md
helm/docs/vald-readreplica: $(ROOTDIR)/charts/vald-readreplica/README.md

.PHONY: helm/docs/vald-benchmark-operator
helm/docs/vald-benchmark-operator: charts/vald-benchmark-operator/README.md
helm/docs/vald-benchmark-operator: $(ROOTDIR)/charts/vald-benchmark-operator/README.md

.PHONY: charts/vald-benchmark-operator/README.md
charts/vald-benchmark-operator/README.md: \
charts/vald-benchmark-operator/README.md.gotmpl \
charts/vald-benchmark-operator/values.yaml
.PHONY: $(ROOTDIR)/charts/vald-benchmark-operator/README.md
$(ROOTDIR)/charts/vald-benchmark-operator/README.md: \
$(ROOTDIR)/charts/vald-benchmark-operator/README.md.gotmpl \
$(ROOTDIR)/charts/vald-benchmark-operator/values.yaml
helm-docs

# force to rebuild
.PHONY: charts/vald-readreplica/README.md
charts/vald-readreplica/README.md: \
charts/vald-readreplica/README.md.gotmpl \
charts/vald-readreplica/values.yaml
.PHONY: $(ROOTDIR)/charts/vald-readreplica/README.md
$(ROOTDIR)/charts/vald-readreplica/README.md: \
$(ROOTDIR)/charts/vald-readreplica/README.md.gotmpl \
$(ROOTDIR)/charts/vald-readreplica/values.yaml
helm-docs

.PHONY: helm/schema/all
Expand All @@ -112,42 +112,42 @@ helm/schema/all: \

.PHONY: helm/schema/vald
## generate json schema for Vald Helm Chart
helm/schema/vald: charts/vald/values.schema.json
helm/schema/vald: $(ROOTDIR)/charts/vald/values.schema.json

charts/vald/values.schema.json: \
charts/vald/values.yaml
$(ROOTDIR)/charts/vald/values.schema.json: \
$(ROOTDIR)/charts/vald/values.yaml
$(call gen-vald-helm-schema,vald/values)

.PHONY: helm/schema/vald-helm-operator
## generate json schema for Vald Helm Operator Chart
helm/schema/vald-helm-operator: charts/vald-helm-operator/values.schema.json
helm/schema/vald-helm-operator: $(ROOTDIR)/charts/vald-helm-operator/values.schema.json

charts/vald-helm-operator/values.schema.json: \
charts/vald-helm-operator/values.yaml
$(ROOTDIR)/charts/vald-helm-operator/values.schema.json: \
$(ROOTDIR)/charts/vald-helm-operator/values.yaml
$(call gen-vald-helm-schema,vald-helm-operator/values)

.PHONY: helm/schema/vald-benchmark-job
## generate json schema for Vald Benchmark Job Chart
helm/schema/vald-benchmark-job: charts/vald-benchmark-operator/job-values.schema.json
helm/schema/vald-benchmark-job: $(ROOTDIR)/charts/vald-benchmark-operator/job-values.schema.json

charts/vald-benchmark-operator/job-values.schema.json: \
charts/vald-benchmark-operator/schemas/job-values.yaml
$(ROOTDIR)/charts/vald-benchmark-operator/job-values.schema.json: \
$(ROOTDIR)/charts/vald-benchmark-operator/schemas/job-values.yaml
$(call gen-vald-helm-schema,vald-benchmark-operator/schemas/job-values)

.PHONY: helm/schema/vald-benchmark-scenario
## generate json schema for Vald Benchmark Job Chart
helm/schema/vald-benchmark-scenario: charts/vald-benchmark-operator/scenario-values.schema.json
helm/schema/vald-benchmark-scenario: $(ROOTDIR)/charts/vald-benchmark-operator/scenario-values.schema.json

charts/vald-benchmark-operator/scenario-values.schema.json: \
charts/vald-benchmark-operator/schemas/scenario-values.yaml
$(ROOTDIR)/charts/vald-benchmark-operator/scenario-values.schema.json: \
$(ROOTDIR)/charts/vald-benchmark-operator/schemas/scenario-values.yaml
$(call gen-vald-helm-schema,vald-benchmark-operator/schemas/scenario-values)

.PHONY: helm/schema/vald-benchmark-operator
## generate json schema for Vald Benchmark Operator Chart
helm/schema/vald-benchmark-operator: charts/vald-benchmark-operator/values.schema.json
helm/schema/vald-benchmark-operator: $(ROOTDIR)/charts/vald-benchmark-operator/values.schema.json

charts/vald-benchmark-operator/values.schema.json: \
charts/vald-benchmark-operator/values.yaml
$(ROOTDIR)/charts/vald-benchmark-operator/values.schema.json: \
$(ROOTDIR)/charts/vald-benchmark-operator/values.yaml
$(call gen-vald-helm-schema,vald-benchmark-operator/values)

.PHONY: yq/install
Expand Down
Loading

0 comments on commit da446c0

Please sign in to comment.