mirror of
https://github.com/grumpycoders/pcsx-redux.git
synced 2024-05-16 19:11:04 -04:00
[New Branch Prep] Added docker aarch64 cross-compiler files
This commit is contained in:
parent
e27261f6f5
commit
91e2f600f4
247
Makefile-cross-aa64
Normal file
247
Makefile-cross-aa64
Normal file
|
@ -0,0 +1,247 @@
|
|||
TARGET := pcsx-redux
|
||||
BUILD ?= Debug
|
||||
DESTDIR ?= /usr/local
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
|
||||
CC_IS_CLANG := $(shell $(CC) --version | grep -q clang && echo true || echo false)
|
||||
|
||||
PACKAGES := capstone freetype2 glfw3 libavcodec libavformat libavutil libswresample libuv zlib
|
||||
|
||||
LOCALES := fr
|
||||
|
||||
CXXFLAGS += -std=c++2a
|
||||
CPPFLAGS += `pkg-config --cflags $(PACKAGES)`
|
||||
CPPFLAGS += -I.
|
||||
CPPFLAGS += -Isrc
|
||||
CPPFLAGS += -Ithird_party
|
||||
CPPFLAGS += -Ithird_party/fmt/include/
|
||||
CPPFLAGS += -Ithird_party/gl3w
|
||||
CPPFLAGS += -Ithird_party/googletest/googletest/include
|
||||
CPPFLAGS += -Ithird_party/imgui
|
||||
CPPFLAGS += -Ithird_party/imgui/backends
|
||||
CPPFLAGS += -Ithird_party/imgui/examples
|
||||
CPPFLAGS += -Ithird_party/imgui/misc/cpp
|
||||
CPPFLAGS += -Ithird_party/imgui_club
|
||||
CPPFLAGS += -Ithird_party/http-parser
|
||||
CPPFLAGS += -Ithird_party/libelfin
|
||||
CPPFLAGS += -Ithird_party/luajit/src
|
||||
CPPFLAGS += -Ithird_party/luv/src
|
||||
CPPFLAGS += -Ithird_party/luv/deps/lua-compat-5.3/c-api
|
||||
CPPFLAGS += -Ithird_party/ucl -Ithird_party/ucl/include
|
||||
CPPFLAGS += -Ithird_party/zep/extensions
|
||||
CPPFLAGS += -Ithird_party/zep/include
|
||||
CPPFLAGS += -Ithird_party/zstr/src
|
||||
CPPFLAGS += -Ithird_party/xbyak/xbyak
|
||||
CPPFLAGS += -g
|
||||
CPPFLAGS += -DIMGUI_IMPL_OPENGL_LOADER_GL3W -DIMGUI_ENABLE_FREETYPE
|
||||
CPPFLAGS += -DZEP_FEATURE_CPP_FILE_SYSTEM
|
||||
IMGUI_CPPFLAGS += -include src/forced-includes/imgui.h
|
||||
|
||||
CPPFLAGS_Release += -O3
|
||||
CPPFLAGS_Debug += -O0
|
||||
CPPFLAGS_Coverage += -O0
|
||||
CPPFLAGS_Coverage += -fprofile-instr-generate -fcoverage-mapping
|
||||
CPPFLAGS_asan += -O1 -fsanitize=address -fno-omit-frame-pointer
|
||||
CPPFLAGS_ReleaseWithTracy += -O3 -DTRACY_ENABLE
|
||||
|
||||
ifeq ($(CC_IS_CLANG),true)
|
||||
CXXFLAGS += -fcoroutines-ts
|
||||
LUAJIT_CFLAGS = -fno-stack-check
|
||||
else
|
||||
CXXFLAGS += -fcoroutines
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
CPPFLAGS += -mmacosx-version-min=10.15
|
||||
CPPFLAGS += -stdlib=libc++
|
||||
endif
|
||||
|
||||
LDFLAGS += `pkg-config --libs $(PACKAGES)`
|
||||
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
LDFLAGS += -lc++ -framework GLUT -framework OpenGL -framework CoreFoundation -framework Cocoa
|
||||
LDFLAGS += -mmacosx-version-min=10.15
|
||||
else
|
||||
LDFLAGS += -lstdc++fs
|
||||
LDFLAGS += -lGL -lX11
|
||||
endif
|
||||
|
||||
LDFLAGS += third_party/luajit/src/libluajit.a
|
||||
LDFLAGS += -ldl
|
||||
LDFLAGS += -g
|
||||
|
||||
CPPFLAGS += -fPIC -Wl,-rpath-link,/opt/cross/sysroot/usr/lib/aarch64-linux-gnu -L/opt/cross/sysroot/usr/lib/aarch64-linux-gnu
|
||||
LDFLAGS += -fPIC -Wl,-rpath-link,/opt/cross/sysroot/usr/lib/aarch64-linux-gnu -L/opt/cross/sysroot/usr/lib/aarch64-linux-gnu
|
||||
|
||||
|
||||
LDFLAGS_Coverage += -fprofile-instr-generate -fcoverage-mapping
|
||||
LDFLAGS_asan += -fsanitize=address
|
||||
|
||||
CPPFLAGS += $(CPPFLAGS_$(BUILD)) -pthread
|
||||
LDFLAGS += $(LDFLAGS_$(BUILD)) -pthread
|
||||
|
||||
LD := $(CXX)
|
||||
|
||||
SRCS := $(call rwildcard,src/,*.cc)
|
||||
SRCS += third_party/fmt/src/os.cc third_party/fmt/src/format.cc
|
||||
IMGUI_SRCS += $(wildcard third_party/imgui/*.cpp)
|
||||
VIXL_SRCS := $(wildcard third_party/vixl/src/*.cc)
|
||||
VIXL_SRCS += $(wildcard third_party/vixl/src/aarch64/*.cc)
|
||||
SRCS += $(IMGUI_SRCS)
|
||||
SRCS += $(wildcard third_party/libelfin/*.cc)
|
||||
SRCS += third_party/gl3w/GL/gl3w.c
|
||||
SRCS += third_party/imgui/backends/imgui_impl_opengl3.cpp
|
||||
SRCS += third_party/imgui/backends/imgui_impl_glfw.cpp
|
||||
SRCS += third_party/imgui/misc/cpp/imgui_stdlib.cpp
|
||||
SRCS += third_party/imgui/misc/freetype/imgui_freetype.cpp
|
||||
SRCS += third_party/imgui_lua_bindings/imgui_lua_bindings.cpp
|
||||
SRCS += third_party/http-parser/http_parser.c
|
||||
SRCS += third_party/luv/src/luv.c
|
||||
SRCS += third_party/tracy/TracyClient.cpp
|
||||
SRCS += third_party/zep/extensions/repl/mode_repl.cpp
|
||||
SRCS += $(wildcard third_party/zep/src/*.cpp)
|
||||
SRCS += third_party/zep/src/mcommon/animation/timer.cpp
|
||||
SRCS += third_party/zep/src/mcommon/file/path.cpp
|
||||
SRCS += third_party/zep/src/mcommon/string/stringutils.cpp
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
SRCS += src/main/complain.mm
|
||||
endif
|
||||
|
||||
SRCS += $(VIXL_SRCS)
|
||||
CPPFLAGS += -DVIXL_INCLUDE_TARGET_AARCH64 -DVIXL_CODE_BUFFER_MMAP
|
||||
CPPFLAGS += -Ithird_party/vixl/src -Ithird_party/vixl/src/aarch64
|
||||
|
||||
SUPPORT_SRCS := $(call rwildcard,src/support/,*.cc)
|
||||
SUPPORT_SRCS += third_party/fmt/src/os.cc third_party/fmt/src/format.cc
|
||||
SUPPORT_SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c
|
||||
OBJECTS := $(patsubst %.c,%.o,$(filter %.c,$(SRCS)))
|
||||
OBJECTS += $(patsubst %.cc,%.o,$(filter %.cc,$(SRCS)))
|
||||
OBJECTS += $(patsubst %.cpp,%.o,$(filter %.cpp,$(SRCS)))
|
||||
OBJECTS += $(patsubst %.mm,%.o,$(filter %.mm,$(SRCS)))
|
||||
OBJECTS += third_party/luajit/src/libluajit.a
|
||||
|
||||
SUPPORT_OBJECTS := $(patsubst %.c,%.o,$(filter %.c,$(SUPPORT_SRCS)))
|
||||
SUPPORT_OBJECTS += $(patsubst %.cc,%.o,$(filter %.cc,$(SUPPORT_SRCS)))
|
||||
SUPPORT_OBJECTS += third_party/luajit/src/libluajit.a
|
||||
NONMAIN_OBJECTS := $(filter-out src/main/mainthunk.o,$(OBJECTS))
|
||||
IMGUI_OBJECTS := $(patsubst %.cpp,%.o,$(filter %.cpp,$(IMGUI_SRCS)))
|
||||
VIXL_OBJECTS := $(patsubst %.cc,%.o,$(filter %.cc,$(VIXL_SRCS)))
|
||||
|
||||
$(IMGUI_OBJECTS): EXTRA_CPPFLAGS := $(IMGUI_CPPFLAGS)
|
||||
|
||||
TESTS_SRC := $(call rwildcard,tests/,*.cc)
|
||||
TESTS := $(patsubst %.cc,%,$(TESTS_SRC))
|
||||
|
||||
CP ?= cp
|
||||
MKDIRP ?= mkdir -p
|
||||
|
||||
all: dep $(TARGET)
|
||||
|
||||
strip: all
|
||||
strip $(TARGET)
|
||||
|
||||
openbios:
|
||||
$(MAKE) $(MAKEOPTS) -C src/mips/openbios
|
||||
|
||||
install: all strip
|
||||
$(MKDIRP) $(DESTDIR)/bin
|
||||
$(MKDIRP) $(DESTDIR)/share/applications
|
||||
$(MKDIRP) $(DESTDIR)/share/icons/hicolor/256x256/apps
|
||||
$(MKDIRP) $(DESTDIR)/share/pcsx-redux/fonts
|
||||
$(MKDIRP) $(DESTDIR)/share/pcsx-redux/i18n
|
||||
$(MKDIRP) $(DESTDIR)/share/pcsx-redux/resources
|
||||
$(CP) $(TARGET) $(DESTDIR)/bin
|
||||
$(CP) resources/pcsx-redux.desktop $(DESTDIR)/share/applications
|
||||
convert resources/pcsx-redux.ico[0] -alpha on -background none $(DESTDIR)/share/icons/hicolor/256x256/apps/pcsx-redux.png
|
||||
$(CP) third_party/noto/* $(DESTDIR)/share/pcsx-redux/fonts
|
||||
$(CP) i18n/*.po $(DESTDIR)/share/pcsx-redux/i18n
|
||||
$(CP) resources/*.ico $(DESTDIR)/share/pcsx-redux/resources
|
||||
$(CP) third_party/SDL_GameControllerDB/LICENSE $(DESTDIR)/share/pcsx-redux/resources
|
||||
$(CP) third_party/SDL_GameControllerDB/gamecontrollerdb.txt $(DESTDIR)/share/pcsx-redux/resources
|
||||
|
||||
install-openbios: openbios
|
||||
$(MKDIRP) $(DESTDIR)/share/pcsx-redux/resources
|
||||
$(CP) src/mips/openbios/openbios.bin $(DESTDIR)/share/pcsx-redux/resources
|
||||
zip -j src/mips/openbios/openbios.zip src/mips/openbios/openbios.elf
|
||||
|
||||
appimage:
|
||||
rm -rf AppDir
|
||||
DESTDIR=AppDir/usr $(MAKE) $(MAKEOPTS) install
|
||||
appimage-builder --skip-tests
|
||||
|
||||
third_party/luajit/src/libluajit.a:
|
||||
$(MAKE) $(MAKEOPTS) -C third_party/luajit/src amalg HOST_CC=gcc-10 CROSS=aarch64-linux-gnu- TARGET_CFLAGS=--sysroot=/opt/cross/sysroot BUILDMODE=static CFLAGS=$(LUAJIT_CFLAGS) XCFLAGS=-DLUAJIT_ENABLE_GC64 MACOSX_DEPLOYMENT_TARGET=10.15
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(LD) -o $@ $(OBJECTS) $(LDFLAGS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c -o $@ $< $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CFLAGS)
|
||||
|
||||
%.o: %.cc
|
||||
$(CXX) -c -o $@ $< $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CXXFLAGS)
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -o $@ $< $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CXXFLAGS)
|
||||
|
||||
%.o: %.mm
|
||||
$(CC) -c -o $@ $< $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CFLAGS)
|
||||
|
||||
%.dep: %.c
|
||||
$(CC) $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CFLAGS) -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
|
||||
|
||||
%.dep: %.cc
|
||||
$(CXX) $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CXXFLAGS) -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
|
||||
|
||||
%.dep: %.cpp
|
||||
$(CXX) $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CXXFLAGS) -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(TARGET) $(DEPS) gtest-all.o
|
||||
$(MAKE) -C third_party/luajit clean MACOSX_DEPLOYMENT_TARGET=10.15
|
||||
|
||||
gtest-all.o: $(wildcard third_party/googletest/googletest/src/*.cc)
|
||||
$(CXX) -O3 -g $(CXXFLAGS) -Ithird_party/googletest/googletest -Ithird_party/googletest/googletest/include -c third_party/googletest/googletest/src/gtest-all.cc
|
||||
|
||||
gitclean:
|
||||
git clean -f -d -x
|
||||
git submodule foreach --recursive git clean -f -d -x
|
||||
|
||||
define msgmerge
|
||||
msgmerge --update i18n/$(1).po i18n/pcsx-redux.pot
|
||||
endef
|
||||
|
||||
regen-i18n:
|
||||
find src -name *.cc -or -name *.c -or -name *.h | sort -u > pcsx-src-list.txt
|
||||
xgettext --keyword=_ --language=C++ --add-comments --sort-output -o i18n/pcsx-redux.pot --omit-header -f pcsx-src-list.txt
|
||||
rm pcsx-src-list.txt
|
||||
$(foreach l,$(LOCALES),$(call msgmerge,$(l)))
|
||||
|
||||
pcsx-redux-tests: $(foreach t,$(TESTS),$(t).o) $(NONMAIN_OBJECTS) gtest-all.o
|
||||
$(LD) -o pcsx-redux-tests $(NONMAIN_OBJECTS) gtest-all.o $(foreach t,$(TESTS),$(t).o) -Ithird_party/googletest/googletest/include third_party/googletest/googletest/src/gtest_main.cc $(LDFLAGS)
|
||||
|
||||
runtests: pcsx-redux-tests
|
||||
./pcsx-redux-tests
|
||||
|
||||
psyq-obj-parser: $(SUPPORT_OBJECTS) tools/psyq-obj-parser/psyq-obj-parser.cc
|
||||
$(LD) -o $@ $(SUPPORT_OBJECTS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) tools/psyq-obj-parser/psyq-obj-parser.cc -Ithird_party/ELFIO
|
||||
|
||||
ps1-packer: $(SUPPORT_OBJECTS) tools/ps1-packer/ps1-packer.cc
|
||||
$(LD) -o $@ $(SUPPORT_OBJECTS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) tools/ps1-packer/ps1-packer.cc
|
||||
|
||||
.PHONY: all dep clean gitclean regen-i18n runtests openbios install strip appimage
|
||||
|
||||
DEPS += $(patsubst %.c,%.dep,$(filter %.c,$(SRCS)))
|
||||
DEPS := $(patsubst %.cc,%.dep,$(filter %.cc,$(SRCS)))
|
||||
DEPS += $(patsubst %.cpp,%.dep,$(filter %.cpp,$(SRCS)))
|
||||
|
||||
dep: $(DEPS)
|
||||
|
||||
ifneq ($(MAKECMDGOALS), regen-i18n)
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
ifneq ($(MAKECMDGOALS), gitclean)
|
||||
-include $(DEPS)
|
||||
endif
|
||||
endif
|
||||
endif
|
5
cross-env.list
Normal file
5
cross-env.list
Normal file
|
@ -0,0 +1,5 @@
|
|||
PKG_CONFIG_SYSROOT_DIR=/opt/cross/sysroot
|
||||
PKG_CONFIG_PATH=
|
||||
PKG_CONFIG_LIBDIR=/opt/cross/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig
|
||||
CC=aarch64-linux-gnu-gcc --sysroot=/opt/cross/sysroot
|
||||
CXX=aarch64-linux-gnu-g++ --sysroot=/opt/cross/sysroot
|
23
dockermake-cross.bat
Normal file
23
dockermake-cross.bat
Normal file
|
@ -0,0 +1,23 @@
|
|||
@echo off
|
||||
set OLDCWD=%cd%
|
||||
cd %~dp0
|
||||
set ROOT=%cd%
|
||||
cd %OLDCWD%
|
||||
|
||||
set REL=%OLDCWD%
|
||||
|
||||
SETLOCAL EnableDelayedExpansion
|
||||
|
||||
set MAT=
|
||||
set UPP=
|
||||
for /f "tokens=*" %%a in ('echo.%ROOT:\=^&echo.%') do (
|
||||
set SUB=!SUB!%%a\
|
||||
call set TMP=%%src:!SUB!=%%
|
||||
set MAT=!SUB!
|
||||
)
|
||||
set REL=%UPP%!REL:%MAT%=!
|
||||
if "!REL!" EQU "!ROOT!" (set REL=) ELSE (set "REL=!REL:\=/!")
|
||||
set REL=/!REL!
|
||||
|
||||
docker build -t aarch64cross .\tools\build-cross
|
||||
docker run --rm --env-file "%ROOT%/env.list" -i -w"/project%REL%" -v "%ROOT%:/project" aarch64cross make --makefile=Makefile-cross-aa64 %*
|
10
dockermake-cross.sh
Executable file
10
dockermake-cross.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
ROOT=$(dirname $0)
|
||||
CWD=$(pwd)
|
||||
cd $ROOT
|
||||
ROOT=$(pwd)
|
||||
cd $CWD
|
||||
#TEMPORARY
|
||||
docker build -t aarch64cross tools/build-cross/
|
||||
docker run --rm --env-file ${ROOT}/cross-env.list -i -w/project${CWD#$ROOT} -v "${ROOT}:/project" -u `id -u`:`id -g` aarch64cross make --makefile=Makefile-cross-aa64 $@
|
56
tools/build-cross/Dockerfile
Normal file
56
tools/build-cross/Dockerfile
Normal file
|
@ -0,0 +1,56 @@
|
|||
# Dockerfile for grumpycoders/pcsx-redux-build
|
||||
|
||||
FROM debian:bullseye-slim
|
||||
|
||||
# The tzdata package isn't docker-friendly, and something pulls it.
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV TZ Etc/GMT
|
||||
|
||||
RUN apt update
|
||||
RUN apt dist-upgrade -y
|
||||
|
||||
# Utility packages
|
||||
RUN apt install -y git
|
||||
RUN apt install -y make
|
||||
RUN apt install -y pkg-config
|
||||
|
||||
# Compilers & base libraries
|
||||
RUN apt install -y g++-10
|
||||
RUN apt install -y gcc-10
|
||||
RUN apt install -y gcc
|
||||
# CI utilities
|
||||
RUN apt install -y curl wget
|
||||
RUN apt install -y python
|
||||
|
||||
|
||||
# Cross Compiler stuff
|
||||
RUN apt install -y debootstrap
|
||||
RUN apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
||||
RUN apt install -y qemu-user-static
|
||||
|
||||
WORKDIR /
|
||||
|
||||
# Create directory to hold aarch64 sysroot
|
||||
RUN mkdir -p /opt/cross/sysroot
|
||||
|
||||
# Run debootstrap to pull down Debian bullseye aarch64 rootfs
|
||||
RUN debootstrap --arch=arm64 --variant=minbase \
|
||||
--include=build-essential,pkg-config,libcapstone-dev,libfreetype-dev,libavcodec-dev,libavformat-dev,libavutil-dev,libglfw3-dev,libswresample-dev,libuv1-dev,\
|
||||
zlib1g-dev --foreign bullseye /opt/cross/sysroot
|
||||
|
||||
# Copy qemu-user-static over to sysroot so second stage can run
|
||||
RUN cp /usr/bin/qemu-aarch64-static /opt/cross/sysroot/usr/bin/
|
||||
|
||||
# chroot into aarch64 sysroot and run debootstrap second stage to unpack packages and set up symlinks
|
||||
RUN chroot /opt/cross/sysroot /usr/bin/qemu-aarch64-static /bin/sh -c "/debootstrap/debootstrap --second-stage"
|
||||
|
||||
# Fix symlinks in the sysroot
|
||||
WORKDIR /opt/cross
|
||||
RUN wget https://raw.githubusercontent.com/abhiTronix/rpi_rootfs/master/scripts/sysroot-relativelinks.py
|
||||
RUN chmod +x sysroot-relativelinks.py
|
||||
RUN ./sysroot-relativelinks.py sysroot
|
||||
|
||||
RUN mkdir /project
|
||||
RUN mkdir -p /home/coder/dconf
|
||||
RUN chmod a+rwx /home/coder/dconf
|
||||
WORKDIR /project
|
Loading…
Reference in a new issue