Skip to content

Commit

Permalink
Add support for darwin-arm64 chipset (#1169)
Browse files Browse the repository at this point in the history
* Add support for darwin-arm64 chipset

Signed-off-by: Domenico Luciani <[email protected]>

* Split darwin builder into a separate module extracting the code for a more generic use

Signed-off-by: Domenico Luciani <[email protected]>

* Split darwin.mk to lifecycle.mk and launcher.mk

Signed-off-by: Domenico Luciani <[email protected]>

* Update launcher.mk with a better naming

Co-authored-by: Natalie Arellano <[email protected]>
Signed-off-by: Domenico Luciani <[email protected]>

* Update lifecycle.mk with a better naming

Co-authored-by: Natalie Arellano <[email protected]>
Signed-off-by: Domenico Luciani <[email protected]>

* Adjusted called function

Signed-off-by: Domenico Luciani <[email protected]>

---------

Signed-off-by: Domenico Luciani <[email protected]>
Co-authored-by: Natalie Arellano <[email protected]>
  • Loading branch information
Domenico Luciani and natalieparellano authored Aug 18, 2023
1 parent df9ae90 commit c72dc20
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
52 changes: 25 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,34 +184,32 @@ else
ln -sf lifecycle.exe $(OUT_DIR)$/creator.exe
endif

build-darwin-amd64: build-darwin-amd64-lifecycle build-darwin-amd64-launcher

build-darwin-amd64-lifecycle: $(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle
$(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle: export GOOS:=darwin
$(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle: export GOARCH:=amd64
$(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle: OUT_DIR:=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
$(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle: $(GOFILES)
$(BUILD_DIR)/darwin-amd64/lifecycle/lifecycle:
@echo "> Building lifecycle for darwin/amd64..."
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/lifecycle -a ./cmd/lifecycle
@echo "> Creating lifecycle symlinks for darwin/amd64..."
ln -sf lifecycle $(OUT_DIR)/detector
ln -sf lifecycle $(OUT_DIR)/analyzer
ln -sf lifecycle $(OUT_DIR)/restorer
ln -sf lifecycle $(OUT_DIR)/builder
ln -sf lifecycle $(OUT_DIR)/exporter
ln -sf lifecycle $(OUT_DIR)/rebaser
## DARWIN ARM64/AMD64
include lifecycle.mk
include launcher.mk
build-darwin-arm64: build-darwin-arm64-lifecycle build-darwin-arm64-launcher
build-darwin-arm64-lifecycle:
$(eval GOARCH := arm64)
$(eval TARGET := darwin-arm64)
$(eval OUT_DIR := $(BUILD_DIR)/$(TARGET)/lifecycle)
$(call build_lifecycle)
build-darwin-arm64-launcher:
$(eval GOARCH := arm64)
$(eval TARGET := darwin-arm64)
$(eval OUT_DIR := $(BUILD_DIR)/$(TARGET)/lifecycle)
$(call build_launcher)

build-darwin-amd64-launcher: $(BUILD_DIR)/darwin-amd64/lifecycle/launcher
$(BUILD_DIR)/darwin-amd64/lifecycle/launcher: export GOOS:=darwin
$(BUILD_DIR)/darwin-amd64/lifecycle/launcher: export GOARCH:=amd64
$(BUILD_DIR)/darwin-amd64/lifecycle/launcher: OUT_DIR:=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
$(BUILD_DIR)/darwin-amd64/lifecycle/launcher: $(GOFILES)
$(BUILD_DIR)/darwin-amd64/lifecycle/launcher:
@echo "> Building launcher for darwin/amd64..."
mkdir -p $(OUT_DIR)
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/launcher -a ./cmd/launcher
test $$(du -m $(OUT_DIR)/launcher|cut -f 1) -le 4
build-darwin-amd64: build-darwin-amd64-lifecycle build-darwin-amd64-launcher
build-darwin-amd64-lifecycle:
$(eval GOARCH := amd64)
$(eval TARGET := darwin-amd64)
$(eval OUT_DIR := $(BUILD_DIR)/$(TARGET)/lifecycle)
$(call build_lifecycle)
build-darwin-amd64-launcher:
$(eval GOARCH := amd64)
$(eval TARGET := darwin-amd64)
$(eval OUT_DIR := $(BUILD_DIR)/$(TARGET)/lifecycle)
$(call build_launcher)

generate-sbom: run-syft-windows run-syft-linux-amd64 run-syft-linux-arm64

Expand Down
6 changes: 6 additions & 0 deletions launcher.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
define build_launcher
@echo "> Building launcher for $(TARGET)..."
mkdir -p $(OUT_DIR)
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/launcher -a ./cmd/launcher
test $$(du -m $(OUT_DIR)/launcher | cut -f 1) -le 4
endef
11 changes: 11 additions & 0 deletions lifecycle.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
define build_lifecycle
@echo "> Building lifecycle for $(TARGET)..."
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/lifecycle -a ./cmd/lifecycle
@echo "> Creating lifecycle symlinks for $(1)..."
ln -sf lifecycle $(OUT_DIR)/detector
ln -sf lifecycle $(OUT_DIR)/analyzer
ln -sf lifecycle $(OUT_DIR)/restorer
ln -sf lifecycle $(OUT_DIR)/builder
ln -sf lifecycle $(OUT_DIR)/exporter
ln -sf lifecycle $(OUT_DIR)/rebaser
endef

0 comments on commit c72dc20

Please sign in to comment.