ofrak icon indicating copy to clipboard operation
ofrak copied to clipboard

Use pattern matching and Makefile functions to enable building and starting multiple different ofrak images

Open Jepson2k opened this issue 1 year ago • 1 comments

What is the use case for the feature? Ofrak uses a comprehensive build system and exposes multiple baseline files (ofrak-core-dev, ofrak-dev, ofrak-angr, etc.) but the makefile only supports building ofrak-core-dev by default. We can use pattern matching and makefile functions to enable users to build and start any of these by default without excessive repetition in the Makefile.

Does the feature contain any proprietary information about another company's intellectual property? No

How would you implement this feature? Something like this:

define build_ofrak_image
	@echo "Building OFRAK image using config: $(1).yml"
	python3 build_image.py --config $(1).yml --base --finish --target install
endef

# Pattern rule for building images named "ofrak-<something>.yml".
# Usage examples:
#   make ofrak-dev         -> builds with ofrak-dev.yml
#   make ofrak-angr        -> builds with ofrak-angr.yml
#   make ofrak-binary-ninja-> builds with ofrak-binary-ninja.yml
#   make ofrak-core-dev    -> builds with ofrak-core-dev.yml
#   make ofrak-ghidra      -> builds with ofrak-ghidra.yml
#   make ofrak-tutorial    -> builds with ofrak-tutorial.yml
.PHONY: ofrak-%
ofrak-%: ## Build OFRAK image using ofrak-<name>.yml
	$(call build_ofrak_image,ofrak-$*)

# For compatibility, this target calls the pattern rule for "ofrak-core-dev"
# so "make image" continues to work as before.
.PHONY: image
image: ofrak-core-dev ## Build ofrak-core-dev image

Are there any (reasonable) alternative approaches? Unsure

Are you interested in implementing it yourself? Yes

Jepson2k avatar Dec 27 '24 16:12 Jepson2k

Generally intrigued by this idea.

@rbs-jacob, can you work iwth @Jepson2k to align on an approach that makes sense to you?

whyitfor avatar Jan 02 '25 14:01 whyitfor