Closer align Makefiles & Dockerfiles (#748)

This commit is contained in:
David Chavez 2022-08-02 16:22:20 +02:00 committed by GitHub
parent 4ed82c71dc
commit 61c68666d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 116 additions and 175 deletions

View File

@ -1,11 +0,0 @@
#!/bin/bash
cp -av /usr/local/lib/libSDL2* /lib/x86_64-linux-gnu/
git config --global --add safe.directory /soh
make setup -C soh -j$(nproc) OPTFLAGS=-O2 DEBUG=0 CC="gcc" CXX="g++"
/opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake -B StormLib/build-switch -S StormLib -DCMAKE_INSTALL_PREFIX=/opt/devkitpro/portlibs/switch/
make -C StormLib/build-switch -j$(nproc)
make install -C StormLib/build-switch
make -f Makefile.switch -j$(nproc) OPTFLAGS=-O2 DEBUG=0

View File

@ -32,13 +32,6 @@ sudo docker run --rm -it -v $(pwd):/soh soh /bin/bash
``` ```
Inside the Docker container: Inside the Docker container:
```bash ```bash
# Clone and build StormLib
git clone https://github.com/ladislav-zezula/StormLib external/StormLib
cmake -B external/StormLib/build -S external/StormLib
cmake --build external/StormLib/build
cp external/StormLib/build/libstorm.a external
cp /usr/local/lib/libGLEW.a external
cd soh cd soh
# Extract the assets/Compile the exporter/Run the exporter # Extract the assets/Compile the exporter/Run the exporter
make setup -j$(nproc) OPTFLAGS=-O2 DEBUG=0 make setup -j$(nproc) OPTFLAGS=-O2 DEBUG=0

View File

@ -3,45 +3,56 @@ FROM ubuntu:20.04 as build
ENV LANG C.UTF-8 ENV LANG C.UTF-8
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
ENV GCCVER=10
RUN apt-get update && \ RUN apt-get update && \
apt-get upgrade -y && \ apt-get upgrade -y && \
apt-get install -y \ apt-get install -y \
binutils \ binutils \
gcc-10 \ gcc-${GCCVER} \
g++-10 \ g++-${GCCVER} \
patchelf \ p7zip-full \
p7zip-full \ python3 \
python3.9 \ make \
make \ cmake \
cmake \ curl \
curl \ git \
git \ lld \
lld \ wget \
libsdl2-dev \ libglew-dev \
zlib1g-dev \ libsdl2-dev \
libbz2-dev \ zlib1g-dev \
libpng-dev \ libbz2-dev \
libgles2-mesa-dev && \ libpng-dev \
ln -s /usr/bin/g++-10 /usr/bin/g++ && \ libgles2-mesa-dev && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 && \ update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCCVER} 10 && \
gcc --version && \ update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCCVER} 10
g++ --version
RUN apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/apt /var/lib/cache /var/lib/log
RUN git clone https://github.com/Perlmint/glew-cmake.git && \ RUN git clone https://github.com/Perlmint/glew-cmake.git && \
cmake glew-cmake && \ cmake glew-cmake && \
make -j$(nproc) && \ make -j$(nproc) && \
make install make install
ENV SDL2VER=2.0.22 ENV SDL2VER=2.0.22
RUN curl -sLO https://libsdl.org/release/SDL2-${SDL2VER}.tar.gz && \ RUN curl -sLO https://libsdl.org/release/SDL2-${SDL2VER}.tar.gz && \
tar -xzf SDL2-${SDL2VER}.tar.gz && \ tar -xzf SDL2-${SDL2VER}.tar.gz && \
cd SDL2-${SDL2VER} && \ cd SDL2-${SDL2VER} && \
./configure --prefix=/usr && \ ./configure --build=x86_64-linux-gnu && \
make && make install && \ make -j$(nproc) && make install && \
rm ../SDL2-${SDL2VER}.tar.gz && \ rm ../SDL2-${SDL2VER}.tar.gz
cp -av /lib/libSDL* /lib/x86_64-linux-gnu/
RUN \
ln -sf /proc/self/mounts /etc/mtab && \
mkdir -p /usr/local/share/keyring/ && \
wget -O /usr/local/share/keyring/devkitpro-pub.gpg https://apt.devkitpro.org/devkitpro-pub.gpg && \
echo "deb [signed-by=/usr/local/share/keyring/devkitpro-pub.gpg] https://apt.devkitpro.org stable main" > /etc/apt/sources.list.d/devkitpro.list && \
apt-get update -y && \
apt-get install -y devkitpro-pacman && \
yes | dkp-pacman -Syu switch-dev switch-portlibs --noconfirm
ENV DEVKITPRO=/opt/devkitpro
ENV DEVKITARM=/opt/devkitpro/devkitARM
ENV DEVKITPPC=/opt/devkitpro/devkitPPC
ENV PATH=$PATH:/opt/devkitpro/portlibs/switch/bin/
RUN mkdir /soh RUN mkdir /soh
WORKDIR /soh WORKDIR /soh

View File

@ -1,58 +0,0 @@
FROM ubuntu:20.04 as build
ENV LANG C.UTF-8
ARG DEBIAN_FRONTEND=noninteractive
ENV GCCVER=10
RUN \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
binutils \
gcc-10 \
g++-10 \
p7zip-full \
python3 \
make \
cmake \
curl \
git \
lld \
wget \
libsdl2-dev \
zlib1g-dev \
libbz2-dev \
libpng-dev \
libgles2-mesa-dev && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCCVER} 10 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCCVER} 10
RUN git clone https://github.com/Perlmint/glew-cmake.git && \
cmake glew-cmake && \
make -j$(nproc) && \
make install ARCH64=true
ENV SDL2VER=2.0.22
RUN curl -sLO https://libsdl.org/release/SDL2-${SDL2VER}.tar.gz && \
tar -xzf SDL2-${SDL2VER}.tar.gz && \
cd SDL2-${SDL2VER} && \
./configure --build=x86_64-linux-gnu && \
make && make install && \
rm ../SDL2-${SDL2VER}.tar.gz
RUN \
ln -sf /proc/self/mounts /etc/mtab && \
mkdir -p /usr/local/share/keyring/ && \
wget -O /usr/local/share/keyring/devkitpro-pub.gpg https://apt.devkitpro.org/devkitpro-pub.gpg && \
echo "deb [signed-by=/usr/local/share/keyring/devkitpro-pub.gpg] https://apt.devkitpro.org stable main" > /etc/apt/sources.list.d/devkitpro.list && \
apt-get update -y && \
apt-get install -y devkitpro-pacman && \
yes | dkp-pacman -Syu switch-dev switch-portlibs --noconfirm
ENV DEVKITPRO=/opt/devkitpro
ENV DEVKITARM=/opt/devkitpro/devkitARM
ENV DEVKITPPC=/opt/devkitpro/devkitPPC
ENV PATH=$PATH:/opt/devkitpro/portlibs/switch/bin/
RUN mkdir /soh
WORKDIR /soh

19
Jenkinsfile vendored
View File

@ -97,8 +97,7 @@ pipeline {
cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64 cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64
docker build . -t soh docker build . -t soh
docker run --name sohcont -dit --rm -v $(pwd):/soh soh /bin/bash docker run --name sohcont -dit --rm -v $(pwd):/soh soh /bin/bash
cp ../../buildsoh.bash soh docker exec sohcont scripts/linux/build.sh
docker exec sohcont soh/buildsoh.bash
mkdir build mkdir build
mv soh/soh.elf build/ mv soh/soh.elf build/
@ -106,9 +105,9 @@ pipeline {
mv OTRGui/build/assets build/ mv OTRGui/build/assets build/
mv ZAPDTR/ZAPD.out build/assets/extractor/ mv ZAPDTR/ZAPD.out build/assets/extractor/
mv README.md readme.txt mv README.md readme.txt
docker exec sohcont appimage/appimage.sh docker exec sohcont scripts/linux/build-appimage.sh
7z a soh-linux.7z SOH-Linux.AppImage readme.txt 7z a soh-linux.7z SOH-Linux.AppImage readme.txt
''' '''
@ -143,9 +142,9 @@ pipeline {
sh ''' sh '''
cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64 cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64
cd soh cd soh
make setup -j4 OPTFLAGS=-O2 DEBUG=0 LD="ld" make setup -j$(sysctl -n hw.physicalcpu) OPTFLAGS=-O2 DEBUG=0 LD="ld"
make -j4 DEBUG=0 OPTFLAGS=-O2 LD="ld" make -j$(sysctl -n hw.physicalcpu) DEBUG=0 OPTFLAGS=-O2 LD="ld"
make -j4 appbundle make appbundle
mv ../README.md readme.txt mv ../README.md readme.txt
7z a soh-mac.7z soh.app readme.txt 7z a soh-mac.7z soh.app readme.txt
''' '''
@ -177,9 +176,9 @@ pipeline {
sh ''' sh '''
cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64 cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64
docker build . -t sohswitch -f Dockerfile.switch docker build . -t sohswitch
docker run --name sohcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash docker run --name sohcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash
docker exec sohcont .ci/switch/buildswitch.bash docker exec sohcont scripts/switch/build.sh
mv soh/soh.nro . mv soh/soh.nro .
mv README.md readme.txt mv README.md readme.txt

View File

@ -48,11 +48,15 @@ endif
LDFLAGS := -Llib/libgfxd -L../libultraship -L../StormLib/build \ LDFLAGS := -Llib/libgfxd -L../libultraship -L../StormLib/build \
-pthread -lgfxd -lultraship ZAPDUtils/ZAPDUtils.a -lstorm -lbz2 -lm -ldl -pthread -lgfxd -lultraship ZAPDUtils/ZAPDUtils.a -lstorm -lbz2 -lm -ldl
LDFLAGS += $(shell pkg-config --libs glew libpng zlib) $(shell sdl2-config --libs)
INC += $(shell pkg-config --cflags libpng)
ifeq ($(UNAME), Darwin) ifeq ($(UNAME), Darwin)
LDFLAGS += $(shell pkg-config --libs glew libpng zlib) $(shell sdl2-config --libs) -framework OpenGL -framework Foundation LDFLAGS += -framework OpenGL -framework Foundation
INC += $(shell pkg-config --cflags libpng) endif
else
LDFLAGS += -lpng -lGL -lGLEW -lX11 -lz -lSDL2 -lpulse ifeq ($(UNAME), Linux)
LDFLAGS += $(shell pkg-config --libs x11 libpulse)
endif endif
# Use LLD if available. Set LLD=0 to not use it # Use LLD if available. Set LLD=0 to not use it
@ -65,10 +69,12 @@ ifneq ($(LLD),0)
endif endif
UNAMEM := $(shell uname -m) UNAMEM := $(shell uname -m)
ifneq ($(UNAME), Darwin) ifeq ($(UNAME), Linux)
LDFLAGS += -Wl,-export-dynamic -lstdc++fs LDFLAGS += -Wl,-export-dynamic -lstdc++fs
EXPORTERS := -Wl,--whole-archive ../OTRExporter/OTRExporter/OTRExporter.a -Wl,--no-whole-archive EXPORTERS := -Wl,--whole-archive ../OTRExporter/OTRExporter/OTRExporter.a -Wl,--no-whole-archive
else endif
ifeq ($(UNAME), Darwin)
EXPORTERS := -Wl,-force_load ../OTRExporter/OTRExporter/OTRExporter.a EXPORTERS := -Wl,-force_load ../OTRExporter/OTRExporter/OTRExporter.a
endif endif

View File

@ -29,7 +29,6 @@ WARN := -Wall -Wextra -Werror \
-Wno-narrowing \ -Wno-narrowing \
-Wno-missing-field-initializers \ -Wno-missing-field-initializers \
-Wno-error=multichar \ -Wno-error=multichar \
-Wno-unused-command-line-argument \
-Wno-delete-non-abstract-non-virtual-dtor \ -Wno-delete-non-abstract-non-virtual-dtor \
-Wno-unused-private-field \ -Wno-unused-private-field \
-Wno-deprecated-copy-with-user-provided-copy \ -Wno-deprecated-copy-with-user-provided-copy \
@ -46,7 +45,7 @@ endif
CXXFLAGS := $(WARN) $(CXXWARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 CXXFLAGS := $(WARN) $(CXXWARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0
CFLAGS := $(WARN) $(CWARN) -std=c99 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 CFLAGS := $(WARN) $(CWARN) -std=c99 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0
CPPFLAGS := -MMD CPPFLAGS := -MMD $(shell pkg-config --cflags sdl2 glew)
MMFLAGS := -Wno-deprecated-declarations -ObjC++ -fobjc-weak -fobjc-arc MMFLAGS := -Wno-deprecated-declarations -ObjC++ -fobjc-weak -fobjc-arc
@ -62,10 +61,6 @@ ifneq ($(CXX_IS_CLANG),1)
MMFLAGS += -stdlib++-isystem ${STD_ISYSTEM} -cxx-isystem ${CXX_ISYSTEM} MMFLAGS += -stdlib++-isystem ${STD_ISYSTEM} -cxx-isystem ${CXX_ISYSTEM}
endif endif
ifeq ($(UNAME), Darwin) #APPLE
CPPFLAGS += $(shell pkg-config --cflags sdl2 glew) -framework OpenGL -framework Foundation
endif
ifneq ($(DEBUG),0) ifneq ($(DEBUG),0)
CXXFLAGS += -g -D_DEBUG CXXFLAGS += -g -D_DEBUG
CFLAGS += -g -D_DEBUG CFLAGS += -g -D_DEBUG

View File

@ -6,7 +6,7 @@ curl -sSfL https://github.com$(curl https://github.com/probonopd/go-appimage/rel
chmod a+x mkappimage.AppImage chmod a+x mkappimage.AppImage
mkdir -p AppDir/usr/bin mkdir -p AppDir/usr/bin
cp appimage/{soh.desktop,soh.sh} AppDir/ cp scripts/linux/{soh.desktop,soh.sh} AppDir/
cp soh/macosx/sohIcon.png AppDir/soh.png cp soh/macosx/sohIcon.png AppDir/soh.png
curl -sSfL https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt -o AppDir/usr/bin/gamecontrollerdb.txt curl -sSfL https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt -o AppDir/usr/bin/gamecontrollerdb.txt

11
scripts/linux/build.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
cd soh
make setup -j$(nproc) OPTFLAGS=-O2 DEBUG=0
make -j$(nproc) OPTFLAGS=-O2 DEBUG=0
cd ../OTRGui
mkdir build
cd build
cmake ..
cmake --build . --config Release

4
scripts/switch/build.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
make setup -C soh -j$(nproc) OPTFLAGS=-O2 DEBUG=0
make -f Makefile.switch -j$(nproc)

View File

@ -16,26 +16,35 @@ DEBUG ?= 1
OPTFLAGS ?= -O0 OPTFLAGS ?= -O0
LTO ?= 0 LTO ?= 0
# flag to save whether the compiler being used is clang or gcc by checking CXX --version
CXX_IS_CLANG ?= $(shell $(CXX) --version | grep -c clang)
WARN := \ WARN := \
-Wno-return-type \ -Wno-return-type \
-Wno-unused-command-line-argument \
-Wno-implicit-function-declaration \
-Wno-c++11-narrowing \
-funsigned-char \ -funsigned-char \
-fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -ffreestanding -fwrapv \ -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -ffreestanding -fwrapv \
CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib ifeq ($(CXX_IS_CLANG),1)
CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib WARN += -Wno-c++11-narrowing
LDFLAGS :=
ifeq ($(UNAME), Linux) #LINUX
CXXFLAGS += -mhard-float -msse2 -mfpmath=sse
CFLAGS += -mhard-float -msse2 -mfpmath=sse
endif endif
ifeq ($(UNAME), Darwin) #APPLE CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -nostdlib $(shell pkg-config --cflags glew) $(shell sdl2-config --cflags)
CXXFLAGS += $(shell pkg-config --cflags sdl2) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) -framework OpenGL CFLAGS := $(WARN) -std=c99 -Wno-implicit-function-declaration -D_GNU_SOURCE -nostdlib $(shell pkg-config --cflags glew) $(shell sdl2-config --cflags)
CFLAGS += $(shell pkg-config --cflags sdl2) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) -framework OpenGL LDFLAGS :=
ifneq ($(CXX_IS_CLANG),1)
CXXFLAGS += -no-pie
CFLAGS += -no-pie
endif
ifeq ($(UNAME), Linux)
ifeq ($(UNAMEM), x86_64)
CXXFLAGS += -msse2 -mfpmath=sse -mhard-float
CFLAGS += -msse2 -mfpmath=sse -mhard-float
endif
CXXFLAGS += $(shell pkg-config --cflags libpulse)
CFLAGS += $(shell pkg-config --cflags libpulse)
endif endif
CPPFLAGS := -MMD CPPFLAGS := -MMD
@ -57,11 +66,11 @@ ifneq ($(LTO),0)
LDFLAGS += -flto LDFLAGS += -flto
endif endif
ifeq ($(UNAME), Linux) #LINUX ifeq ($(UNAME), Linux)
TARGET := soh.elf TARGET := soh.elf
endif endif
ifeq ($(UNAME), Darwin) #APPLE ifeq ($(UNAME), Darwin)
TARGET := soh-$(UNAMEM) TARGET := soh-$(UNAMEM)
endif endif
@ -78,25 +87,15 @@ INC_DIRS := $(addprefix -I, \
../libultraship/libultraship/Lib/Fast3D/U64/PR \ ../libultraship/libultraship/Lib/Fast3D/U64/PR \
) )
ifeq ($(UNAME), Linux) #LINUX
INC_DIRS += $(addprefix -I, \
/opt/X11/include \
)
endif
LDDIRS := $(addprefix -L, \ LDDIRS := $(addprefix -L, \
../libultraship/ \ ../libultraship/ \
) )
ifeq ($(UNAME), Linux) #LINUX
LDDIRS += $(addprefix -L, \
/opt/X11/lib \
)
endif
LDLIBS := \ LDLIBS := \
$(ZAPDUTILS) \ $(ZAPDUTILS) \
$(LIBSTORM) \ $(LIBSTORM) \
$(shell sdl2-config --libs) \
$(shell pkg-config --libs glew) \
$(addprefix -l, \ $(addprefix -l, \
dl \ dl \
bz2 \ bz2 \
@ -105,24 +104,16 @@ LDLIBS := \
ultraship \ ultraship \
) )
ifeq ($(UNAME), Linux) #LINUX ifeq ($(UNAME), Linux)
LDLIBS += \ LDLIBS += $(shell pkg-config --libs x11 libpulse)
$(addprefix -l, \
X11 \
SDL2 \
GL \
GLEW \
pulse \
)
endif endif
ifeq ($(UNAME), Darwin) #APPLE ifeq ($(UNAME), Darwin)
LDLIBS += \ LDLIBS += \
$(addprefix -framework , \ $(addprefix -framework , \
OpenGL \ OpenGL \
Foundation \ Foundation \
) \ )
$(shell sdl2-config --libs) $(shell pkg-config --libs glew)
endif endif
ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*") ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*")

View File

@ -30,7 +30,7 @@
#include "ichain.h" #include "ichain.h"
#include "regs.h" #include "regs.h"
#if defined(_WIN64) || defined(__x86_64__) || defined(__arm64__) #if defined(__LP64__)
#define _SOH64 #define _SOH64
#endif #endif

View File

@ -1001,7 +1001,7 @@ void DrawFlagsTab() {
// Draws a combo that lets you choose and upgrade value from a drop-down of text values // Draws a combo that lets you choose and upgrade value from a drop-down of text values
void DrawUpgrade(const std::string& categoryName, int32_t categoryId, const std::vector<std::string>& names) { void DrawUpgrade(const std::string& categoryName, int32_t categoryId, const std::vector<std::string>& names) {
ImGui::Text(categoryName.c_str()); ImGui::Text("%s", categoryName.c_str());
ImGui::SameLine(); ImGui::SameLine();
ImGui::PushID(categoryName.c_str()); ImGui::PushID(categoryName.c_str());
if (ImGui::BeginCombo("##upgrade", names[CUR_UPG_VALUE(categoryId)].c_str())) { if (ImGui::BeginCombo("##upgrade", names[CUR_UPG_VALUE(categoryId)].c_str())) {