Skip to content

Commit

Permalink
Modify build system to place artefacts in separate out/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
keirf committed Mar 13, 2022
1 parent 7f5642a commit 773d173
Show file tree
Hide file tree
Showing 29 changed files with 167 additions and 296 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
export VER=${{ steps.vars.outputs.sha_short }}
make -j4 dist VER=$VER
mkdir -p _cidist
rm flashfloppy-$VER.zip
mv out/flashfloppy-$VER .
rm flashfloppy-$VER/RELEASE_NOTES
git rev-parse HEAD >flashfloppy-$VER/COMMIT
zip -r flashfloppy-$VER.zip flashfloppy-$VER
Expand All @@ -34,8 +34,8 @@ jobs:
- name: Build debug dist
run: |
export VER=${{ steps.vars.outputs.sha_short }}-debug
env debug=y make -j4 dist VER=$VER
rm flashfloppy-$VER.zip
make -j4 dist VER=$VER level=debug
mv out/flashfloppy-$VER .
rm flashfloppy-$VER/RELEASE_NOTES
git rev-parse HEAD >flashfloppy-$VER/COMMIT
echo debug >>flashfloppy-$VER/COMMIT
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
run: |
export VER=${{ steps.vars.outputs.ref }}
make -j4 dist VER=$VER
mv out/flashfloppy-$VER.zip .
- name: Create Release
id: create_release
Expand Down
14 changes: 2 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
*.[oa]
.*.d
*~
*.ld
*.elf
*.bin
*.hex
*.orig
*.rej
*.rld
*.upd
*.dfu
/flashfloppy-*
/index.html
/HxC_Compat*
/out
/ext
167 changes: 80 additions & 87 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,111 +4,104 @@ export FW_VER := 3.30
PROJ := FlashFloppy
VER := v$(FW_VER)

SUBDIRS += src bootloader bl_update io_test
PYTHON := python3

.PHONY: all upd clean flash start serial gotek
export ROOT := $(CURDIR)

ifneq ($(RULES_MK),y)
.PHONY: FORCE

.DEFAULT_GOAL := gotek
export ROOT := $(CURDIR)
.DEFAULT_GOAL := all

prod-%: FORCE
$(eval export mcu := $*)
$(MAKE) target target=bootloader level=prod
$(MAKE) target target=floppy level=prod
$(MAKE) target target=quickdisk level=prod
$(MAKE) target target=bl_update level=prod
$(MAKE) target target=io_test level=prod

debug-%: FORCE
$(eval export mcu := $*)
$(MAKE) target target=bootloader level=debug
$(MAKE) target target=floppy level=debug
$(MAKE) target target=quickdisk level=debug
$(MAKE) target target=bl_update level=debug
$(MAKE) target target=io_test level=debug

logfile-%: FORCE
$(eval export mcu := $*)
$(MAKE) target target=bootloader level=logfile
$(MAKE) target target=floppy level=logfile
$(MAKE) target target=quickdisk level=logfile

all-%: FORCE prod-% debug-% logfile-% ;

all: FORCE all-stm32f105 all-at32f435 ;

clean: FORCE
rm -rf out

all:
$(MAKE) -f $(ROOT)/Rules.mk all
mrproper: FORCE clean
rm -rf ext

clean:
rm -f *.hex *.upd *.dfu *.html
$(MAKE) -f $(ROOT)/Rules.mk $@
out: FORCE
mkdir -p out/$(mcu)/$(level)/$(target)
rsync -a --include="*/" --exclude="*" src/ out/$(mcu)/$(level)/$(target)

gotek: all
mv FF.dfu FF_Gotek-$(VER).dfu
mv FF.upd FF_Gotek-$(VER).upd
mv FF.hex FF_Gotek-$(VER).hex
mv BL.upd FF_Gotek-Bootloader-$(VER).upd
mv IOT.upd FF_Gotek-IO-Test-$(VER).upd
target: FORCE out
$(MAKE) -C out/$(mcu)/$(level)/$(target) -f $(ROOT)/Rules.mk target.bin target.hex target.upd target.dfu $(mcu)=y $(level)=y $(target)=y

HXC_FF_URL := https://www.github.com/keirf/flashfloppy-hxc-file-selector
HXC_FF_URL := $(HXC_FF_URL)/releases/download
HXC_FF_VER := v9-FF

dist:
rm -rf flashfloppy-*
mkdir -p flashfloppy-$(VER)/alt/bootloader
mkdir -p flashfloppy-$(VER)/alt/logfile
mkdir -p flashfloppy-$(VER)/alt/io-test
mkdir -p flashfloppy-$(VER)/alt/quickdisk/logfile
$(MAKE) clean
$(MAKE) mcu=stm32f105 gotek
cp -a FF_Gotek-$(VER).dfu flashfloppy-$(VER)/
cp -a FF_Gotek-$(VER).upd flashfloppy-$(VER)/
cp -a FF_Gotek-$(VER).hex flashfloppy-$(VER)/
cp -a FF_Gotek-Bootloader-$(VER).upd flashfloppy-$(VER)/alt/bootloader/
cp -a FF_Gotek-IO-Test-$(VER).upd flashfloppy-$(VER)/alt/io-test/
$(MAKE) clean
$(MAKE) mcu=stm32f105 debug=n logfile=y -f $(ROOT)/Rules.mk upd
mv FF.upd flashfloppy-$(VER)/alt/logfile/FF_Gotek-Logfile-$(VER).upd
$(MAKE) clean
$(MAKE) mcu=stm32f105 quickdisk=y -f $(ROOT)/Rules.mk upd
mv FF.upd flashfloppy-$(VER)/alt/quickdisk/FF_Gotek-QuickDisk-$(VER).upd
$(MAKE) clean
$(MAKE) mcu=stm32f105 quickdisk=y debug=n logfile=y -f $(ROOT)/Rules.mk upd
mv FF.upd flashfloppy-$(VER)/alt/quickdisk/logfile/FF_Gotek-QuickDisk-Logfile-$(VER).upd
python3 scripts/mk_qd.py --window=6.5 flashfloppy-$(VER)/alt/quickdisk/Blank.qd
$(MAKE) clean
cp -a COPYING flashfloppy-$(VER)/
cp -a README.md flashfloppy-$(VER)/
cp -a RELEASE_NOTES flashfloppy-$(VER)/
cp -a examples flashfloppy-$(VER)/
[ -e HxC_Compat_Mode-$(HXC_FF_VER).zip ] || \
wget -q --show-progress $(HXC_FF_URL)/$(HXC_FF_VER)/HxC_Compat_Mode-$(HXC_FF_VER).zip
rm -rf index.html
unzip -q HxC_Compat_Mode-$(HXC_FF_VER).zip
mv HxC_Compat_Mode flashfloppy-$(VER)
mkdir -p flashfloppy-$(VER)/scripts
cp -a scripts/edsk* flashfloppy-$(VER)/scripts/
cp -a scripts/mk_hfe.py flashfloppy-$(VER)/scripts/
zip -r flashfloppy-$(VER).zip flashfloppy-$(VER)

mrproper: clean
rm -rf flashfloppy-*
rm -rf HxC_Compat_Mode-$(HXC_FF_VER).zip

else

upd:
$(MAKE) -C src -f $(ROOT)/Rules.mk $(PROJ).elf $(PROJ).bin $(PROJ).hex
$(PYTHON) ./scripts/mk_update.py src/$(PROJ).bin FF.upd

all:
$(MAKE) -C src -f $(ROOT)/Rules.mk $(PROJ).elf $(PROJ).bin $(PROJ).hex
$(MAKE) bootloader=y logfile=n -C bootloader \
-f $(ROOT)/Rules.mk \
Bootloader.elf Bootloader.bin Bootloader.hex
$(MAKE) logfile=n -C bl_update -f $(ROOT)/Rules.mk \
BL_Update.elf BL_Update.bin BL_Update.hex
$(MAKE) logfile=n -C io_test -f $(ROOT)/Rules.mk \
IO_Test.elf IO_Test.bin IO_Test.hex
srec_cat bootloader/Bootloader.hex -Intel src/$(PROJ).hex -Intel \
-o FF.hex -Intel
$(PYTHON) ./scripts/mk_update.py src/$(PROJ).bin FF.upd
$(PYTHON) ./scripts/mk_update.py bl_update/BL_Update.bin BL.upd
$(PYTHON) ./scripts/mk_update.py io_test/IO_Test.bin IOT.upd
$(PYTHON) ./scripts/dfu-convert.py -i FF.hex FF.dfu

endif
dist: level := prod
dist: FORCE all
rm -rf out/flashfloppy-*
$(eval t := out/flashfloppy-$(VER))
mkdir -p $(t)/alt/bootloader
mkdir -p $(t)/alt/logfile
mkdir -p $(t)/alt/io-test
mkdir -p $(t)/alt/quickdisk/logfile
$(eval s := out/$(mcu)/$(level)/floppy)
cp -a $(s)/target.dfu $(t)/FF_Gotek-$(VER).dfu
cp -a $(s)/target.upd $(t)/FF_Gotek-$(VER).upd
cp -a $(s)/target.hex $(t)/FF_Gotek-$(VER).hex
$(eval s := out/$(mcu)/$(level)/bootloader)
cp -a $(s)/target.upd $(t)/alt/bootloader/FF_Gotek-Bootloader-$(VER).upd
$(eval s := out/$(mcu)/$(level)/io_test)
cp -a $(s)/target.upd $(t)/alt/io-test/FF_Gotek-IO-Test-$(VER).upd
$(eval s := out/$(mcu)/logfile/floppy)
cp -a $(s)/target.upd $(t)/alt/logfile/FF_Gotek-Logfile-$(VER).upd
$(eval s := out/$(mcu)/$(level)/quickdisk)
cp -a $(s)/target.upd $(t)/alt/quickdisk/FF_Gotek-QuickDisk-$(VER).upd
$(eval s := out/$(mcu)/logfile/quickdisk)
cp -a $(s)/target.upd $(t)/alt/quickdisk/logfile/FF_Gotek-QuickDisk-Logfile-$(VER).upd
$(PYTHON) scripts/mk_qd.py --window=6.5 $(t)/alt/quickdisk/Blank.qd
cp -a COPYING $(t)/
cp -a README.md $(t)/
cp -a RELEASE_NOTES $(t)/
cp -a examples $(t)/
[ -e ext/HxC_Compat_Mode-$(HXC_FF_VER).zip ] || \
(mkdir -p ext ; cd ext ; wget -q --show-progress $(HXC_FF_URL)/$(HXC_FF_VER)/HxC_Compat_Mode-$(HXC_FF_VER).zip ; rm -rf index.html)
(cd $(t) && unzip -q ../../ext/HxC_Compat_Mode-$(HXC_FF_VER).zip)
mkdir -p $(t)/scripts
cp -a scripts/edsk* $(t)/scripts/
cp -a scripts/mk_hfe.py $(t)/scripts/
(cd out && zip -r flashfloppy-$(VER).zip flashfloppy-$(VER))

BAUD=115200
DEV=/dev/ttyUSB0
STM32FLASH=stm32flash

ocd: gotek
python3 scripts/openocd/flash.py `pwd`/FF_Gotek-$(VER).hex
ocd: FORCE all
$(PYTHON) scripts/openocd/flash.py $(target)/target.hex

flash: gotek
sudo $(STM32FLASH) -b $(BAUD) -w FF_Gotek-$(VER).hex $(DEV)
flash: FORCE all
sudo $(STM32FLASH) -b $(BAUD) -w $(target)/target.hex $(DEV)

start:
start: FORCE
sudo $(STM32FLASH) -b $(BAUD) -g 0 $(DEV)

serial:
serial: FORCE
sudo miniterm.py $(DEV) 3000000
49 changes: 21 additions & 28 deletions Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,31 @@ FLAGS += -Wno-unused-value -ffunction-sections
## STM32F105
ifeq ($(mcu),stm32f105)
FLAGS += -mcpu=cortex-m3 -DSTM32F105=1 -DMCU=1
stm32f105=y
ifeq ($(bootloader),y)
# Debug bootloader doesn't fit in 32kB
override debug=n
override logfile=n
endif

## AT32F435
else ifeq ($(mcu),at32f435)
FLAGS += -mcpu=cortex-m4 -DAT32F435=4 -DMCU=4
at32f435=y
endif

ifneq ($(debug),y)
FLAGS += -DNDEBUG
endif

# Following options are mutually exclusive
ifeq ($(bootloader),y)
FLAGS += -DBOOTLOADER=1
else ifeq ($(logfile),y)
endif

ifeq ($(logfile),y)
FLAGS += -DLOGFILE=1
endif

ifeq ($(quickdisk),y)
FLAGS += -DQUICKDISK=1
floppy=n
else
floppy=y
endif

FLAGS += -MMD -MF .$(@F).d
Expand All @@ -58,12 +55,11 @@ CFLAGS += $(CFLAGS-y) $(FLAGS) -include decls.h
AFLAGS += $(AFLAGS-y) $(FLAGS) -D__ASSEMBLY__
LDFLAGS += $(LDFLAGS-y) $(FLAGS) -Wl,--gc-sections

RULES_MK := y

include Makefile
RPATH := $(shell $(PYTHON) $(ROOT)/scripts/rpath.py $(ROOT) $(CURDIR))
include $(RPATH)/Makefile

SUBDIRS += $(SUBDIRS-y)
OBJS += $(OBJS-y) $(patsubst %,%/build.o,$(SUBDIRS))
OBJS += $(OBJS-y) $(OBJS-^n) $(patsubst %,%/build.o,$(SUBDIRS))

# Force execution of pattern rules (for which PHONY cannot be directly used).
.PHONY: FORCE
Expand All @@ -79,19 +75,11 @@ build.o: $(OBJS)
%/build.o: FORCE
$(MAKE) -f $(ROOT)/Rules.mk -C $* build.o

%.o: %.c Makefile
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@

%.o: %.S Makefile
@echo AS $@
$(CC) $(AFLAGS) -c $< -o $@

%.ld: %.ld.S Makefile
%.ld: $(RPATH)/%.ld.S $(RPATH)/Makefile
@echo CPP $@
$(CC) -P -E $(AFLAGS) $< -o $@

%.elf: $(OBJS) %.ld Makefile
%.elf: $(OBJS) %.ld $(RPATH)/Makefile
@echo LD $@
$(CC) $(LDFLAGS) -T$(*F).ld $(OBJS) -o $@
chmod a-x $@
Expand All @@ -100,23 +88,28 @@ build.o: $(OBJS)
@echo OBJCOPY $@
$(OBJCOPY) -O ihex $< $@
chmod a-x $@
ifneq ($(bootloader),y)
srec_cat ../bootloader/target.hex -Intel $@ -Intel -o $@ -Intel
endif

%.bin: %.elf
@echo OBJCOPY $@
$(OBJCOPY) -O binary $< $@
chmod a-x $@

%.o: $(RPATH)/%.c Makefile
%.upd: %.bin
@echo OBJCOPY $@
$(PYTHON) $(ROOT)/scripts/mk_update.py $< $@

%.dfu: %.hex
$(PYTHON) $(ROOT)/scripts/dfu-convert.py -i $< $@

%.o: $(RPATH)/%.c $(RPATH)/Makefile
@echo CC $@
$(CC) $(CFLAGS) -c $< -o $@

%.o: $(RPATH)/%.S Makefile
%.o: $(RPATH)/%.S $(RPATH)/Makefile
@echo AS $@
$(CC) $(AFLAGS) -c $< -o $@

clean:: $(addprefix _clean_,$(SUBDIRS) $(SUBDIRS-n) $(SUBDIRS-))
rm -f *.orig *.rej *~ *.o *.elf *.hex *.bin *.ld $(DEPS)
_clean_%: FORCE
$(MAKE) -f $(ROOT)/Rules.mk -C $* clean

-include $(DEPS)
1 change: 0 additions & 1 deletion bl_update/BL_Update.ld.S

This file was deleted.

22 changes: 0 additions & 22 deletions bl_update/Makefile

This file was deleted.

6 changes: 0 additions & 6 deletions bl_update/display/Makefile

This file was deleted.

3 changes: 0 additions & 3 deletions bl_update/gotek/Makefile

This file was deleted.

Loading

0 comments on commit 773d173

Please sign in to comment.