Skip to content
Open
Changes from all commits
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
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,9 @@ $(HOST_BUILD_DIR)/crc-embedder: $(SOURCES)
cross: $(BUILD_DIR)/macos-arm64/crc $(BUILD_DIR)/macos-amd64/crc $(BUILD_DIR)/linux-amd64/crc $(BUILD_DIR)/linux-arm64/crc $(BUILD_DIR)/windows-amd64/crc.exe

.PHONY: containerized ## Cross compile from container
containerized: image := $(shell grep -m 1 '^FROM' images/openshift-ci/Dockerfile | awk '{print $$2}')
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make image derivation robust and overridable.

Current grep/awk breaks with FROM flags (e.g., --platform) or stage aliases (AS builder), and it can’t be overridden cleanly. Prefer a target-specific ?= (respects command-line overrides) and skip flags/alias.

-containerized: image := $(shell grep -m 1 '^FROM' images/openshift-ci/Dockerfile | awk '{print $$2}')
+containerized: image ?= $(shell awk 'BEGIN{IGNORECASE=1} $$1=="FROM"{for(i=2;i<=NF;i++){if($$i ~ /^--/) continue; print $$i; break}}' images/openshift-ci/Dockerfile | sed -E 's/[[:space:]]+[Aa][Ss][[:space:]].*$$//' | head -n1)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
containerized: image := $(shell grep -m 1 '^FROM' images/openshift-ci/Dockerfile | awk '{print $$2}')
containerized: image ?= $(shell awk 'BEGIN{IGNORECASE=1} $$1=="FROM"{for(i=2;i<=NF;i++){if($$i ~ /^--/) continue; print $$i; break}}' images/openshift-ci/Dockerfile | sed -E 's/[[:space:]]+[Aa][Ss][[:space:]].*$$//' | head -n1)
🤖 Prompt for AI Agents
Makefile around line 116: the current image assignment should be made
target-overridable using a target-specific '?=' and the parsing must ignore FROM
flags (tokens starting with '--') and stage aliases like 'AS'. Replace the
single grep/awk one-liner with a '?=' assignment that extracts the first
non-flag, non-"AS" token from the Dockerfile FROM line (e.g., scan fields after
FROM and pick the first field that does not start with '--' and is not 'AS'), so
command-line overrides work and FROM lines containing flags or "AS <stage>" are
handled correctly.

containerized: clean
${CONTAINER_RUNTIME} build -t crc-build -f images/build .
${CONTAINER_RUNTIME} run --name crc-cross crc-build make cross
${CONTAINER_RUNTIME} cp crc-cross:/opt/app-root/src/out ./
${CONTAINER_RUNTIME} rm crc-cross
${CONTAINER_RUNTIME} rmi crc-build
${CONTAINER_RUNTIME} run --rm -v ${PWD}:/data${SELINUX_VOLUME_LABEL} ${image} /bin/bash -c "cd /data && make cross"

.PHONY: generate_mocks
generate_mocks: $(TOOLS_BINDIR)/mockery
Expand Down
Loading