mbv: clean up build
This commit is contained in:
parent
0903c2b60a
commit
922f258884
@ -1,3 +1,5 @@
|
||||
ARG TARGET
|
||||
|
||||
FROM debian:bookworm AS deps
|
||||
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
|
||||
@ -9,27 +11,16 @@ RUN cd /opt && curl -L https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpa
|
||||
FROM deps AS dev
|
||||
|
||||
|
||||
FROM deps AS bootloader-build
|
||||
FROM deps AS build
|
||||
ARG TARGET=${TARGET}
|
||||
|
||||
ADD . /workspace
|
||||
WORKDIR /workspace
|
||||
|
||||
RUN make bootloader.bin
|
||||
RUN make ${TARGET}
|
||||
|
||||
|
||||
FROM deps AS app-build
|
||||
FROM scratch AS export
|
||||
ARG TARGET=${TARGET}
|
||||
|
||||
ADD . /workspace
|
||||
WORKDIR /workspace
|
||||
|
||||
RUN make app.bin
|
||||
|
||||
|
||||
FROM scratch AS bootloader-export
|
||||
|
||||
COPY --from=bootloader-build /workspace/bootloader.bin /
|
||||
|
||||
|
||||
FROM scratch AS app-export
|
||||
|
||||
COPY --from=app-build /workspace/app.bin /
|
||||
COPY --from=build /workspace/${TARGET} /
|
||||
|
24
mbv/Makefile
24
mbv/Makefile
@ -23,20 +23,24 @@ sources += hal/uart/xuartlite.c hal/uart/xuartlite_stats.c hal/uart/xuartlite_in
|
||||
includes += -Ihal/uart
|
||||
|
||||
bootloader_objects = bootloader.o start.o $(sources:.c=.o)
|
||||
app_objects = helloworld.o start.o $(sources:.c=.o)
|
||||
helloworld_objects = helloworld.o start.o $(sources:.c=.o)
|
||||
|
||||
all_objects = $(bootloader_objects) $(helloworld_objects)
|
||||
deps = $(all_objects:.o=.d)
|
||||
|
||||
CPPFLAGS += $(includes)
|
||||
|
||||
%.bin: %.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
%.elf: app.ld
|
||||
$(LD) -Wl,-Tapp.ld $(LDFLAGS) -o $@ $(objects)
|
||||
|
||||
bootloader.elf: $(bootloader_objects) bootloader.ld
|
||||
$(LD) -Wl,-Tbootloader.ld $(LDFLAGS) -o $@ $(bootloader_objects)
|
||||
|
||||
app.elf: $(app_objects) app.ld
|
||||
$(LD) -Wl,-Tapp.ld $(LDFLAGS) -o $@ $(app_objects)
|
||||
|
||||
deps = $(app_objects:.o=.d) $(bootloader_objects:.o=.d)
|
||||
helloworld.elf: objects = $(helloworld_objects)
|
||||
helloworld.elf: $(helloworld_objects)
|
||||
|
||||
HOSTCXX = clang++
|
||||
HOSTLDFLAGS = -lgmock -lgtest -lgtest_main -L/usr/local/opt/llvm/lib -L/usr/local/lib
|
||||
@ -76,8 +80,12 @@ mktest:
|
||||
test_deps =
|
||||
|
||||
.PHONY: bootloader
|
||||
bootloader: ## Build the bootloader in a docker container
|
||||
docker build -o . --target bootloader-export .
|
||||
bootloader: ## Build the bootloader in docker
|
||||
docker build -o . --target export --build-arg TARGET=bootloader.elf .
|
||||
|
||||
.PHONY: helloworld
|
||||
helloworld: ## Build the helloworld app in docker
|
||||
docker build -o . --target export --build-arg TARGET=helloworld.bin .
|
||||
|
||||
.PHONY: dev-image
|
||||
dev-image:
|
||||
@ -89,7 +97,7 @@ dev: dev-image ## Run a dev container
|
||||
|
||||
.PHONY: clean
|
||||
clean: ## Remove generated files
|
||||
rm -rf *.elf *.bin $(app_objects) $(bootloader_objects) $(deps)
|
||||
rm -rf *.elf *.bin $(all_objects) $(deps)
|
||||
rm -rf test/ *.dSYM $(test_deps) *.o
|
||||
|
||||
.PHONY: help
|
||||
|
Loading…
Reference in New Issue
Block a user