Skip to content
Open
Show file tree
Hide file tree
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
91 changes: 30 additions & 61 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,37 @@
name: Build binaries
name: C/C++ CI

on: [push, pull_request]

jobs:
build:
name: ubuntu-18.04
runs-on: ubuntu-18.04
timeout-minutes: 20
container: devkitpro/devkitppc:latest

steps:
- uses: actions/checkout@v2

- name: Cache
id: cache-1
uses: actions/cache@v2
with:
path: cache
key: ${{ runner.os }}-cache-1

- name: Download devkitPPC r37, libogc 2.1.0, bin2s, elf2dol, ppc-mxml 2.11 and libfat-ogc 1.1.5
if: steps.cache-1.outputs.cache-hit != 'true'
# general-tools is needed for bin2s and gamecube-tools is needed for elf2dol
run: |
mkdir cache && cd cache
wget "https://wii.leseratte10.de/devkitPro/file.php/devkitPPC-r37-4-linux.pkg.tar.xz"
wget "https://wii.leseratte10.de/devkitPro/file.php/libogc-2.1.0-1-any.pkg.tar.xz"
wget "https://wii.leseratte10.de/devkitPro/file.php/general-tools-1.2.0-1-linux.pkg.tar.xz"
wget "https://wii.leseratte10.de/devkitPro/file.php/gamecube-tools-1.0.2-1-linux.pkg.tar.xz"
wget "https://wii.leseratte10.de/devkitPro/file.php/ppc-mxml-2.11-2-any.pkg.tar.xz"
wget "https://wii.leseratte10.de/devkitPro/file.php/libfat-ogc-1.1.5-2-any.pkg.tar.xz"
cd ..

- name: Extract all the archives
run: |
tar -xf cache/devkitPPC-r37-4-linux.pkg.tar.xz opt/devkitpro/devkitPPC --strip-components=1
tar -xf cache/libogc-2.1.0-1-any.pkg.tar.xz opt/devkitpro/libogc --strip-components=1
tar -xf cache/libfat-ogc-1.1.5-2-any.pkg.tar.xz opt/devkitpro/libogc --strip-components=1
tar -xf cache/general-tools-1.2.0-1-linux.pkg.tar.xz opt/devkitpro/tools/bin/bin2s --strip-components=4
sudo cp bin2s /usr/local/bin/bin2s
tar -xf cache/gamecube-tools-1.0.2-1-linux.pkg.tar.xz opt/devkitpro/tools/bin/elf2dol --strip-components=4
sudo cp elf2dol /usr/local/bin/elf2dol
tar -xf cache/ppc-mxml-2.11-2-any.pkg.tar.xz opt/devkitpro/portlibs --strip-components=1

- name: Compile
run: |
PATH=$(pwd)/devkitpro/devkitPPC/bin:$PATH DEVKITPPC=$(pwd)/devkitpro/devkitPPC DEVKITPRO=$(pwd)/devkitpro make install
cd modules
PATH=$(pwd)/../devkitpro/devkitPPC/bin:$PATH DEVKITPPC=$(pwd)/../devkitpro/devkitPPC DEVKITPRO=$(pwd)/../devkitpro make
cd ..
PATH=$(pwd)/devkitpro/devkitPPC/bin:$PATH DEVKITPPC=$(pwd)/devkitpro/devkitPPC DEVKITPRO=$(pwd)/devkitpro make
PATH=$(pwd)/devkitpro/devkitPPC/bin:$PATH DEVKITPPC=$(pwd)/devkitpro/devkitPPC DEVKITPRO=$(pwd)/devkitpro make release
cp modules/*/bin/*.mod .

- name: Upload compiled Brainslug binaries
uses: actions/upload-artifact@v2
with:
name: brainslug
path: |
release/apps
release/bslug
release/readme.txt

- name: Upload compiled modules
uses: actions/upload-artifact@v2
with:
name: modules
path: |
*.mod

- uses: actions/checkout@v1


- name: Build
run: |
export BSLUGDIR=$(pwd)blsug
make && make install
make -C modules
make release
cp modules/*/bin/*.mod .

- name: Upload compiled Brainslug binaries
uses: actions/upload-artifact@v2
with:
name: brainslug
path: |
release/apps
release/bslug
release/readme.txt

- name: Upload compiled modules
uses: actions/upload-artifact@v2
with:
name: modules
path: |
*.mod
7 changes: 3 additions & 4 deletions BUILDING
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
To build the BrainSlug channel you must first have a copy of devkitPro:
http://sourceforge.net/projects/devkitpro/
You must also have libmxml for devkitPro, which can be found here:
http://wiibrew.org/wiki/Mini-XML
To build the BrainSlug channel you must first have a copy of devkitPPC:
https://devkitpro.org
You must also have libmxml for devkitPPC, which can be installed via pacman:
You also need to have libfat installed.

In the root directory of the BrainSlug repository, run the commands:
Expand Down
9 changes: 4 additions & 5 deletions INSTALLING
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
To install BrainSlug for development of modules you must first have a copy of
devkitPro, specifically with devkitPPC included:
http://sourceforge.net/projects/devkitpro/
devkitPPC installed. You can obtain this from devkitPro (https://devkitpro.org)

In the root directory of the BrainSlug repository, run the following commands:
make clean && make -C modules clean
make install

It may be necessary to run the last command with administrative privileges.

This installs the necessary headers into a bslug subdirectory within devkitPro.
This installs the necessary headers into a bslug subdirectory. Please do not
install this to /opt/devkitpro which is reserved for devkitPro tools and libraries.

Now BrainSlug modules can be compiled. See modules/README for more information
about BrainSlug module development.

Expand Down
59 changes: 11 additions & 48 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,15 @@ C := ,
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
endif

ifeq ($(OS),Windows_NT)
$(info Compiling from $(OS))

PORTLIBS := $(DEVKITPRO)/portlibs/ppc
PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
ifeq ($(DEVKITPRO),$(subst :, ,$(DEVKITPRO)))
DEVKITPRO := $(patsubst /$(firstword $(subst /, ,$(DEVKITPRO)))/%,$(firstword $(subst /, ,$(DEVKITPRO))):/%,$(DEVKITPRO))
$(info DEVKITPRO corrected to $(DEVKITPRO))
else
$(info DEVKITPRO is $(DEVKITPRO))
endif
PORTLIBS := $(DEVKITPRO)/portlibs/ppc
ifeq ($(DEVKITPPC),$(subst :, ,$(DEVKITPPC)))
DEVKITPPC := $(patsubst /$(firstword $(subst /, ,$(DEVKITPPC)))/%,$(firstword $(subst /, ,$(DEVKITPPC))):/%,$(DEVKITPPC))
$(info DEVKITPPC corrected to $(DEVKITPPC))
else
$(info DEVKITPPC is $(DEVKITPPC))
endif
else
$(info Compiling from Unix)
BSLUGDIR ?= $(CURDIR)/bslug

PORTLIBS := $(DEVKITPRO)/portlibs/ppc
$(info DEVKITPRO is $(DEVKITPRO))
$(info DEVKITPPC is $(DEVKITPPC))
endif
include $(DEVKITPPC)/base_tools

PORTLIBS := $(DEVKITPRO)/portlibs/ppc

###############################################################################
# Compiler settings

# The toolchain to use.
PREFIX ?= powerpc-eabi-
# Tools to use
AS := $(PREFIX)as
LD := $(PREFIX)g++
CC := $(PREFIX)g++
OBJDUMP := $(PREFIX)objdump
OBJCOPY := $(PREFIX)objcopy
ELF2DOL ?= elf2dol
LD := $(CC)

# -O2: optimise lots
# -Wl$C--gc-sections: remove unneeded symbols
Expand Down Expand Up @@ -124,12 +91,9 @@ SRC :=
# Phony targets
PHONY :=
# Include directories
INC_DIRS := .
INC_DIRS := . $(DEVKITPRO)/libogc/include $(PORTLIBS)/include
# Library directories
LIB_DIRS := $(DEVKITPPC) $(DEVKITPPC)/powerpc-eabi \
$(DEVKITPRO)/libogc $(DEVKITPRO)/libogc/lib/wii \
$(wildcard $(DEVKITPPC)/lib/gcc/powerpc-eabi/*) \
$(PORTLIBS) $(PORTLIBS)/wii
LIB_DIRS := $(DEVKITPRO)/libogc/lib/wii $(PORTLIBS)/lib

###############################################################################
# Rule to make everything.
Expand All @@ -140,11 +104,9 @@ all : $(TARGET) $(BIN)/boot.elf
###############################################################################
# Install rule

BSLUGDIR := $(DEVKITPRO)/bslug

# Rule to install bslug.
PHONY += install
install : bslug_include modules symbols bslug.ld bslug_elf.ld
install : bslug_include modules symbols bslug.ld bslug_elf.ld bslug.mk
$(LOG)
$(addprefix $Qrm -rf ,$(wildcard $(BSLUGDIR)))
$Qmkdir $(BSLUGDIR)
Expand All @@ -153,6 +115,7 @@ install : bslug_include modules symbols bslug.ld bslug_elf.ld
$Qcp -r symbols $(BSLUGDIR)
$Qcp -r bslug.ld $(BSLUGDIR)
$Qcp -r bslug_elf.ld $(BSLUGDIR)
$Qcp -r bslug.mk $(BSLUGDIR)

# Rule to install bslug.
PHONY += uninstall
Expand Down Expand Up @@ -186,14 +149,14 @@ include src/makefile.mk
LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \
$(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS))
CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \
$(patsubst %,-I %/include,$(LIB_DIRS)) -iquote src
-iquote src

OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC)))

ifeq ($(words $(filter clean%,$(MAKECMDGOALS))),0)
ifeq ($(words $(filter install%,$(MAKECMDGOALS))),0)
ifeq ($(words $(filter uninstall%,$(MAKECMDGOALS))),0)
include $(patsubst %.c,$(BUILD)/%.c.d,$(filter %.c,$(SRC)))
-include $(patsubst %.c,$(BUILD)/%.c.d,$(filter %.c,$(SRC)))
endif
endif
endif
Expand Down
134 changes: 134 additions & 0 deletions bslug.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
###############################################################################
# Compiler settings

###############################################################################
# devkitPPC settings
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif

include $(DEVKITPPC)/base_tools

LD := $(PREFIX)ld

FREESTANDING_INC := $(shell LANG=C $(DEVKITPPC)/bin/powerpc-eabi-gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')

INC_DIRS += $(FREESTANDING_INC)include $(FREESTANDING_INC)include-fixed $(BSLUGDIR)/include

# --relocatable: make sure ld doesn't remove relocations bslug will need
# -s: strip local symbols to speed linking
# --gc-sections: remove unneeded symbols
# -T: use the linker script specified (to force certain bslug sections together)
# -Map: generate a map file
LDFLAGS += --relocatable -s --gc-sections -u bslug_load -u bslug_meta \
-T $(BSLUGDIR)/bslug.ld \
$(patsubst %,-Map %,$(strip $(MAP)))
LD1FLAGS += --relocatable -s \
-T $(BSLUGDIR)/bslug_elf.ld


LDFLAGS += $(patsubst %,-l %,$(LIBS)) $(patsubst %,-l %,$(LIBS)) \
$(patsubst %,-L %,$(LIB_DIRS)) $(patsubst %,-L %/lib,$(LIB_DIRS))

CFLAGS += $(patsubst %,-I %,$(INC_DIRS)) \
$(patsubst %,-I %/include,$(LIB_DIRS))

# -O2: optimise lots
# -Wall: generate lots of warnings
# -x c: compile as C code
# -std=gnu99: use the C99 standard with GNU extensions
# -nostdinc: don't include standard headers (we don't have all the symbols)
# -ffreestanding: we don't have libc; don't expect we do
# -DGEKKO: define the symbol GEKKO (used in some libogc headers)
# -DHW_RVL: define the symbol HW_RVL (used in some libogc headers)
# -mrvl: enable wii/gamecube compilation
# -mcpu=750: enable processor specific compilation
# -meabi: enable eabi specific compilation
# -mhard-float: enable hardware floating point instructions
# -fno-common: stop common variables which the loader can't understand
# -msdata-none: do not use r2 or r13 as small data areas
# -memb: enable embedded application specific compilation
# -ffunction-sections: split up functions so linker can garbage collect
# -fdata-sections: split up data so linker can garbage collect
CFLAGS += -O2 -Wall -x c -std=gnu99 -nostdinc \
-ffreestanding \
-DGEKKO -DHW_RVL \
-mrvl -mcpu=750 -meabi -mhard-float -fno-common \
-msdata=none -memb -ffunction-sections -fdata-sections

ifdef DEBUG
else
CFLAGS += -DNDEBUG
endif

###############################################################################
# Variable init

# Phony targets
PHONY :=

###############################################################################
# Rule to make everything.
PHONY += all

all : $(TARGET)

###############################################################################
# Derived rules

OBJECTS := $(patsubst %.c,$(BUILD)/%.c.o,$(filter %.c,$(SRC)))

###############################################################################
# Special build rules

# Rule to make the module file.
$(TARGET) : $(BUILD)/output.elf | $(BIN)
$(LOG)
$Q$(LD) $(BUILD)/output.elf $(LDFLAGS) -o $@

# Rule to make the module file.
$(BUILD)/output.elf : $(OBJECTS) | $(BIN) $(BUILD)
$(LOG)
$Q$(LD) $(OBJECTS) $(LD1FLAGS) -o $@

# Rule to make intermediate directory
$(BUILD) :
$Qmkdir $@

# Rule to make output directory
$(BIN) :
$Qmkdir $@

###############################################################################
# Standard build rules

$(BUILD)/%.c.o: %.c | $(BUILD)
$(LOG)
-$Qmkdir -p $(dir $@)
$Q$(CC) -c $(CFLAGS) $< -o $@

###############################################################################
# Assembly listing rules

# Rule to make assembly listing.
PHONY += list
list : $(LIST)

# Rule to make the listing file.
%.list : $(TARGET)
$(LOG)
-$Qmkdir -p $(dir $@)
$Q$(OBJDUMP) -d $< > $@

###############################################################################
# Clean rule

# Rule to clean files.
PHONY += clean
clean :
$Qrm -rf $(wildcard $(BUILD) $(BIN))

###############################################################################
# Phony targets

.PHONY : $(PHONY)
Loading