Skip to content

Commit

Permalink
Merge pull request #105 from devkitPro/merge-build-refactor
Browse files Browse the repository at this point in the history
wut 1.0.0-beta9
  • Loading branch information
ashquarky authored May 22, 2019
2 parents f7af9c3 + 540b1de commit ed4e168
Show file tree
Hide file tree
Showing 71 changed files with 1,092 additions and 1,202 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
build/
release/
debug/
lib/
*.a
*.o
*.d
*.elf
*.rpx
*.bz2
docs/html/
.vs/
CMakeSettings.json
Empty file removed .gitmodules
Empty file.
31 changes: 11 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ matrix:
- os: linux
dist: xenial
sudo: required
env: DEPLOY_FILE=wut.7z
env: DEPLOY_FILE=wut-*.tar.bz2

addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:cginternals/backports-ppa'
packages:
- p7zip-full

cache:
directories:
Expand All @@ -34,26 +32,19 @@ install:
script:
- cd "$TRAVIS_BUILD_DIR"
# Build wut
- mkdir build && cd build
- cmake -DCMAKE_INSTALL_PREFIX=wut_install ../
- make -j4 install
- export WUT_ROOT=$PWD/wut_install
- cd ../
- make -j4
- sudo make install
# Build tests
- cd tests
- mkdir build && cd build
- cmake ../
- make -j4 VERBOSE=TRUE
- cd ../../
- echo Tests disabled for now
# - cd tests
# - mkdir build && cd build
# - cmake ../
# - make -j4 VERBOSE=TRUE
# - cd ../../
# Build samples
- cd samples
- mkdir build && cd build
- cmake -DCMAKE_INSTALL_PREFIX=$WUT_ROOT/samples ../
- make -j4 VERBOSE=TRUE install
- cd samples/make
- make -j4
- cd ../../
# Create deploy zips
- cd $WUT_ROOT
- 7z a $DEPLOY_FILE .

deploy:
provider: releases
Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#### wut 1.0.0-beta9
###### Breaking changes
- coreinit's `exit` is no longer defined in `<coreinit/exit.h>`. Please use `<stdlib.h>` instead, which pulls in newlib's exit.
- RPL import sections (`.fimport_coreinit` etc.) are now garbage-collected when using wut-tools 1.1.0 or above (required). Code relying on weak links to Cafe functions may exhibit different behaviour.
- `snd_core` and `snd_user` are no longer linked, due to naming conflicts with `sndcore2` and `snduser2`. wut has never shipped headers for these libraries, but if you are using them, please switch to `sndcore2` and `snduser2`.
- Changes to CMake's linker flags may cause existing build trees to fail. Please delete any old build files and re-run CMake.
- Two new symbols, `__rpx_start` and `__rpl_start`, are now used internally by the toolchain, while `_start` is now undefined. As usual, applications are strongly discouraged from prefixing any symbol with two underscores, in order to avoid conflicts of this type.

###### Deprecations
- `WUT_ROOT` should no longer be defined in the user's environment, and will be set to `$DEVKITPRO/wut` internally. CMake lists and makefiles that use `$WUT_ROOT/share` to find `wut.mk` or `wut.toolchain.cmake` should be changed to `$DEVKITPRO/wut/share`.
- All of wut's static libraries (`-lcoreinit`, `-lwhb`, etc.) have been merged into a single `libwut`, which gets automatically linked in for all builds. While empty static libraries have been provided for CMake builds to ease the transition, these will be removed eventually. Applications should remove the build flags to link any of wut's libraries.
- Similarly, wut's build configuration options (devoptab, wutmalloc, newlib) are now integrated into `libwut`. For CMake builds, the `wut_enable_*` macros will now log a deprecation warning, and should be removed as soon as possible.
- Use of `wut.mk` as a build system is now deprecated. Applications should move to `wut_rules` and devkitPro-style makefiles, such as those in [the samples](/samples/make). `wut.mk` will not be updated further, and will be removed in a future release.

###### Other changes
- Builds refactored: wut now uses Makefiles to build itself, as well as providing a devkitPro-style `wut_rules` file - see the `samples/make` folder. The cmake samples are now in `samples/cmake`.
- A new linking feature, `__rplwrap`, was added to help deal with conflicts between newlib's and Cafe's functions. Because of this, wut 1.0.0-beta9 requires wut-tools 1.1.0 or newer.
- Using rplwrap, newlib's `exit` is now correctly chained with coreinit's - calls like `atexit` should work; whether calling `exit` or just returning from `main`. Applications using coreinit's `_Exit` are encouraged to migrate to a normal `exit` call.
- A new header file, `<coreinit/codegen.h>`, has been added and documented for OSCodegen functionality.


#### wut 1.0.0-beta8
42 changes: 0 additions & 42 deletions CMakeLists.txt

This file was deleted.

173 changes: 173 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@

TOPDIR ?= $(CURDIR)
include $(TOPDIR)/share/wut_rules

export WUT_MAJOR := 1
export WUT_MINOR := 0
export WUT_PATCH := 0

VERSION := $(WUT_MAJOR).$(WUT_MINOR).$(WUT_PATCH)

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET := wut
#BUILD := build
SOURCES := cafe \
libraries/wutcrt \
libraries/wutnewlib \
libraries/wutstdc++ \
libraries/wutmalloc \
libraries/wutdevoptab \
libraries/libwhb/src \
libraries/libgfd/src \
libraries/nn_swkbd
DATA := data
INCLUDES := include \
libraries/libwhb/include \
libraries/libgfd/include \

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS := -g -Wall -Werror -save-temps \
-ffunction-sections -fdata-sections \
$(MACHDEP) \
$(BUILD_CFLAGS)

CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__

CXXFLAGS := $(CFLAGS) -std=gnu++17

ASFLAGS := -g $(MACHDEP)

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export TOPDIR := $(CURDIR)

export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))

CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(DEFFILES:.def=.o) $(SFILES:.s=.o) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))

export STUB_LIBS := $(addprefix lib/stubs/lib,$(DEFFILES:.def=.a)) lib/stubs/libnn_swkbd.a lib/stubs/libwhb.a lib/stubs/libgfd.a lib/stubs/libsnd_core.a lib/stubs/libsnd_user.a

export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I.

.PHONY: all dist-bin dist-src dist install clean

#---------------------------------------------------------------------------------
all: lib/libwut.a lib/libwutd.a $(STUB_LIBS)

dist-bin: all
@tar --exclude=*~ -cjf wut-$(VERSION).tar.bz2 include lib share -C libraries/libwhb include -C ../libgfd include

dist-src:
@tar --exclude=*~ -cjf wut-src-$(VERSION).tar.bz2 cafe include libraries share Makefile

dist: dist-src dist-bin

install: dist-bin
mkdir -p $(DESTDIR)$(DEVKITPRO)/wut
bzip2 -cd wut-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/wut

lib:
@[ -d $@ ] || mkdir -p $@

lib/stubs:
@[ -d $@ ] || mkdir -p $@

release:
@[ -d $@ ] || mkdir -p $@

debug:
@[ -d $@ ] || mkdir -p $@

lib/libwut.a :$(SOURCES) $(INCLUDES) | lib release
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DNDEBUG=1 -O2" \
DEPSDIR=$(CURDIR)/release \
--no-print-directory -C release \
-f $(CURDIR)/Makefile

lib/libwutd.a : $(SOURCES) $(INCLUDES) | lib debug
@$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DDEBUG=1 -Og" \
DEPSDIR=$(CURDIR)/debug \
--no-print-directory -C debug \
-f $(CURDIR)/Makefile

# temp: Deprecation stub for directly linking cafe libs (all in libwut)
lib/stubs/lib%.a: | lib/stubs release
@echo stub $(notdir $*)
@$(AR) -rc $@

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -rf release debug lib

#---------------------------------------------------------------------------------
else

DEPENDS := $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT) : $(OFILES)

$(OFILES_SRC) : $(HFILES)

#---------------------------------------------------------------------------------
%_bin.h %.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)


-include $(DEPENDS)

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
87 changes: 0 additions & 87 deletions cafe/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit ed4e168

Please sign in to comment.