Skip to content

Commit

Permalink
Add Lint and Build Actions (#3)
Browse files Browse the repository at this point in the history
* echo PS2SDK path in build action

* cleaned up src/Makefile

* only save artifacts for main/tag builds

* only save artifacts for main/tag builds

* move SYSTEM.CNF to dist folder

* update problems in Makefile

* update gitignore for python cache

* limit when build runs

* run linter recursively

* add linter GH action

* rename draw.h to pass linter

* move files to new structure

* add dist readme

* add build workflow

* add missing files

* stop ignoring .obj files because they are important

* use ps2dev container for everything

* add newline to force new commit date

Co-authored-by: Tom Marks <[email protected]>
  • Loading branch information
phy1um and phy1um authored Aug 29, 2021
1 parent 22acb1a commit e4aa70e
Show file tree
Hide file tree
Showing 24 changed files with 10,236 additions and 22 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build
on:
push:
branches:
- main
tags:
- v*.*.*
pull_request:
jobs:
build:
runs-on: ubuntu-latest
container:
image: ps2dev/ps2dev
steps:
- uses: actions/checkout@v2
- run: apk add python3 make gmp-dev mpfr-dev mpc1-dev
- run: make assets
- run: echo "using PS2 SDK @ $PS2SDK"
- run: make dist/test.elf
- uses: actions/upload-artifact@v2
with:
name: game package
path: dist/
if: ${{ github.ref == 'refs/head/main' || startsWith(github.ref, 'refs/tags') }}


12 changes: 12 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Run Linter
on: [push]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- run: pip install cpplint
- run: make lint


4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ test.iso
# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
Expand Down Expand Up @@ -53,3 +52,6 @@ Module.symvers
Mkfile.old
dkms.conf

# python stuff
**/__pycache__/
**/*.bin
43 changes: 24 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
PS2SDK=/usr/local/ps2dev/ps2sdk

ISO_TGT=test.iso
EE_BIN=test.elf
EE_OBJS=main.o gs.o mesh.o draw.o math.o pad.o
EE_LIBS=-ldma -lgraph -ldraw -lkernel -ldebug -lmath3d -lm -lpad
EE_CFLAGS += -Wall --std=c99
EE_LDFLAGS = -L$(PSDSDK)/ee/common/lib -L$(PS2SDK)/ee/lib
BIN=dist/test.elf

PS2HOST?=192.168.20.99

Expand All @@ -15,40 +9,51 @@ DOCKER?=sudo docker

include .lintvars

ifdef PLATFORM
include $(PS2SDK)/samples/Makefile.eeglobal
include $(PS2SDK)/samples/Makefile.pref
endif
dist: $(BIN) assets

.PHONY: assets
assets:
$(MAKE) -C asset
cp asset/*.bin dist/

$(BIN):
$(MAKE) -C src test.elf
cp src/test.elf dist/test.elf

# TODO(phy1um): update ISO building to include everything in dist/
$(ISO_TGT): $(EE_BIN)
mkisofs -l -o $(ISO_TGT) $(EE_BIN) SYSTEM.CNF
mkisofs -l -o $(ISO_TGT) $(BIN) dist/SYSTEM.CNF

.PHONY: docker-build
docker-build:
$(DOCKER) run -v $(shell pwd):/src $(DOCKER_IMG) make $(ISO_TGT)
.PHONY: docker-elf
docker-elf:
$(DOCKER) run -v $(shell pwd):/src $(DOCKER_IMG) make $(BIN)


.PHONY: clean
clean:
rm -rf $(ISO_TGT) $(EE_BIN) $(EE_OBJS)
$(MAKE) -C src clean
$(MAKE) -C asset clean
rm -rf dist/*

.PHONY: run
run:
PCSX2 --elf=$(PWD)/$(EE_BIN)
PCSX2 --elf=$(PWD)/$(BIN)

# TODO(phy1um): this could be improved, hard-coded ELF name is bad
.PHONY: runps2
runps2:
ps2client -h $(PS2HOST) -t 10 execee host:$(EE_BIN)
cp dist && ps2client -h $(PS2HOST) -t 10 execee host:test.elf

.PHONY: resetps2
resetps2:
ps2client -h $(PS2HOST) -t 5 reset

.PHONY: lint
lint:
cpplint --filter=$(CPPLINT_FILTERS) --counting=total --linelength=$(CPPLINT_LINE_LENGTH) --extensions=c,h *.c *.h
cpplint --filter=$(CPPLINT_FILTERS) --counting=total --linelength=$(CPPLINT_LINE_LENGTH) --extensions=c,h --recursive .

.PHONY: format
format:
$(DOCKER) run $(DOCKERFLAGS) -v $(shell pwd):/workdir unibeautify/clang-format -i -sort-includes *.c *.h


Loading

0 comments on commit e4aa70e

Please sign in to comment.