Skip to content

Commit 448f57e

Browse files
authored
Merge branch 'main' into ubsan
2 parents c84dc76 + 2c1baf4 commit 448f57e

File tree

289 files changed

+26233
-9865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+26233
-9865
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 PCSX-Redux authors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
BUILD ?= Release
2+
DESTDIR ?= /usr/local
3+
CROSS ?= none
4+
5+
UNAME_S := $(shell uname -s)
6+
UNAME_M := $(shell uname -m)
7+
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
8+
CC_IS_CLANG := $(shell $(CC) --version | grep -q clang && echo true || echo false)
9+
10+
PACKAGES := zlib
11+
12+
ifeq ($(wildcard third_party/ELFIO/elfio/elfio.hpp),)
13+
HAS_SUBMODULES = false
14+
else
15+
HAS_SUBMODULES = true
16+
endif
17+
18+
CXXFLAGS += -std=c++2b
19+
CPPFLAGS += `pkg-config --cflags $(PACKAGES)`
20+
CPPFLAGS += -I.
21+
CPPFLAGS += -Isrc
22+
CPPFLAGS += -Ithird_party
23+
CPPFLAGS += -Ithird_party/ELFIO
24+
CPPFLAGS += -Ithird_party/fmt/include/
25+
CPPFLAGS += -Ithird_party/googletest/googletest/include
26+
CPPFLAGS += -Ithird_party/ucl -Ithird_party/ucl/include
27+
CPPFLAGS += -g
28+
29+
CPPFLAGS_Release += -O3
30+
CPPFLAGS_Debug += -O0
31+
CPPFLAGS_Coverage += -O0
32+
ifeq ($(CC_IS_CLANG),true)
33+
CPPFLAGS_Coverage += -fprofile-instr-generate -fcoverage-mapping
34+
else
35+
CPPFLAGS_Coverage += -fprofile-arcs -ftest-coverage
36+
endif
37+
CPPFLAGS_asan += -O1 -fsanitize=address -fno-omit-frame-pointer
38+
CPPFLAGS_ubsan += -O1 -fsanitize=undefined -fno-omit-frame-pointer
39+
CPPFLAGS_lto += -O3 -flto=auto -fno-fat-lto-objects -flto-partition=one
40+
41+
ifeq ($(CC_IS_CLANG),true)
42+
CXXFLAGS += -fcoroutines-ts
43+
else
44+
CXXFLAGS += -fcoroutines
45+
endif
46+
47+
ifeq ($(UNAME_S),Darwin)
48+
CPPFLAGS += -mmacosx-version-min=10.15
49+
CPPFLAGS += -stdlib=libc++
50+
endif
51+
52+
LDFLAGS += `pkg-config --libs $(PACKAGES)`
53+
54+
ifeq ($(UNAME_S),Darwin)
55+
LDFLAGS += -lc++
56+
LDFLAGS += -mmacosx-version-min=10.15
57+
else
58+
LDFLAGS += -lstdc++fs
59+
endif
60+
61+
LDFLAGS += -g
62+
63+
ifeq ($(CC_IS_CLANG),true)
64+
LDFLAGS_Coverage += -fprofile-instr-generate -fcoverage-mapping
65+
else
66+
LDFLAGS_Coverage += -fprofile-arcs -ftest-coverage
67+
endif
68+
LDFLAGS_asan += -fsanitize=address
69+
LDFLAGS_ubsan += -fsanitize=undefined
70+
LDFLAGS_lto += -O3 -flto=auto -flto-partition=one
71+
72+
CPPFLAGS += $(CPPFLAGS_$(BUILD)) -pthread
73+
LDFLAGS += $(LDFLAGS_$(BUILD)) -pthread
74+
75+
ifeq ($(CROSS),arm64)
76+
CPPFLAGS += -fPIC -Wl,-rpath-link,/opt/cross/sysroot/usr/lib/aarch64-linux-gnu -L/opt/cross/sysroot/usr/lib/aarch64-linux-gnu
77+
LDFLAGS += -fPIC -Wl,-rpath-link,/opt/cross/sysroot/usr/lib/aarch64-linux-gnu -L/opt/cross/sysroot/usr/lib/aarch64-linux-gnu
78+
endif
79+
80+
LD := $(CXX)
81+
82+
SRCS := $(call rwildcard,src/,*.cc)
83+
SRCS += third_party/fmt/src/os.cc third_party/fmt/src/format.cc
84+
SRCS += $(wildcard third_party/cueparser/*.c)
85+
SRCS += $(wildcard third_party/iec-60908b/*.c)
86+
SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c
87+
88+
TOOLS = exe2elf exe2iso ps1-packer psyq-obj-parser
89+
90+
##############################################################################
91+
92+
OBJECTS += $(patsubst %.c,%.o,$(filter %.c,$(SRCS)))
93+
OBJECTS += $(patsubst %.cc,%.o,$(filter %.cc,$(SRCS)))
94+
OBJECTS += $(patsubst %.cpp,%.o,$(filter %.cpp,$(SRCS)))
95+
OBJECTS += $(patsubst %.mm,%.o,$(filter %.mm,$(SRCS)))
96+
97+
TESTS_SRC := $(call rwildcard,tests/,*.cc)
98+
TESTS := $(patsubst %.cc,%,$(TESTS_SRC))
99+
100+
CP ?= cp
101+
MKDIRP ?= mkdir -p
102+
103+
all: check_submodules dep tools
104+
105+
ifeq ($(HAS_SUBMODULES),true)
106+
check_submodules:
107+
108+
else
109+
check_submodules:
110+
@echo "You need to clone this repository recursively, in order to get its submodules."
111+
@false
112+
endif
113+
114+
strip: all
115+
strip $(TOOLS)
116+
117+
install: all strip
118+
$(MKDIRP) $(DESTDIR)/bin
119+
$(CP) $(TOOLS) $(DESTDIR)/bin
120+
121+
%.o: %.c
122+
$(CC) -c -o $@ $< $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CFLAGS)
123+
124+
%.o: %.cc
125+
$(CXX) -c -o $@ $< $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CXXFLAGS)
126+
127+
%.o: %.cpp
128+
$(CXX) -c -o $@ $< $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CXXFLAGS)
129+
130+
%.o: %.mm
131+
$(CC) -c -o $@ $< $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CFLAGS)
132+
133+
%.dep: %.c
134+
$(CC) $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CFLAGS) -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
135+
136+
%.dep: %.cc
137+
$(CXX) $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CXXFLAGS) -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
138+
139+
%.dep: %.cpp
140+
$(CXX) $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CXXFLAGS) -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
141+
142+
clean:
143+
rm -f $(OBJECTS) $(TARGET) $(DEPS) gtest-all.o gtest_main.o
144+
145+
gtest-all.o: $(wildcard third_party/googletest/googletest/src/*.cc)
146+
$(CXX) -O3 -g $(CXXFLAGS) -Ithird_party/googletest/googletest -Ithird_party/googletest/googletest/include -c third_party/googletest/googletest/src/gtest-all.cc
147+
148+
gtest_main.o: third_party/googletest/googletest/src/gtest_main.cc
149+
$(CXX) -O3 -g $(CXXFLAGS) -Ithird_party/googletest/googletest -Ithird_party/googletest/googletest/include -c third_party/googletest/googletest/src/gtest_main.cc
150+
151+
gitclean:
152+
git clean -f -d -x
153+
git submodule foreach --recursive git clean -f -d -x
154+
155+
tests: $(foreach t,$(TESTS),$(t).o) $(NONMAIN_OBJECTS) gtest-all.o gtest_main.o
156+
$(LD) -o tests $(NONMAIN_OBJECTS) gtest-all.o gtest_main.o $(foreach t,$(TESTS),$(t).o) -Ithird_party/googletest/googletest/include $(LDFLAGS)
157+
158+
runtests: tests
159+
./tests
160+
161+
define TOOLDEF
162+
$(1): $(OBJECTS) tools/$(1)/$(1).o
163+
$(LD) -o $(1) $(CPPFLAGS) $(CXXFLAGS) $(OBJECTS) tools/$(1)/$(1).o -static $(LDFLAGS)
164+
165+
endef
166+
167+
$(foreach tool,$(TOOLS),$(eval $(call TOOLDEF,$(tool))))
168+
169+
tools: $(TOOLS)
170+
171+
.PHONY: all dep clean gitclean runtests install strip tools
172+
173+
DEPS += $(patsubst %.c,%.dep,$(filter %.c,$(SRCS)))
174+
DEPS := $(patsubst %.cc,%.dep,$(filter %.cc,$(SRCS)))
175+
DEPS += $(patsubst %.cpp,%.dep,$(filter %.cpp,$(SRCS)))
176+
177+
dep: $(DEPS)
178+
179+
ifneq ($(MAKECMDGOALS), clean)
180+
ifneq ($(MAKECMDGOALS), gitclean)
181+
ifeq ($(HAS_SUBMODULES), true)
182+
-include $(DEPS)
183+
endif
184+
endif
185+
endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# PCSX-Redux's Support & Tools
2+
3+
This repository is a read-only reduced mirror of
4+
[the PCSX-Redux project](https://github.com/grumpycoders/pcsx-redux). It only contains the necessary parts to build the [tools](https://github.com/grumpycoders/pcsx-redux/tree/main/tools) only, as well as the [support libraries](https://github.com/grumpycoders/pcsx-redux/tree/main/support).
5+
Its purpose is to be used as a submodule for projects that want to use the tools and libraries
6+
contained herein without bringing the whole of PCSX-Redux's codebase.
7+
8+
Building the tools is simply done using the `make` command. It is possible to install them on your system using `make install`. There is no build system set for the libraries as they are meant to be used as a pick-and-choose buffet.
9+
10+
Please consult [the upstream repository](https://github.com/grumpycoders/pcsx-redux) and [its documentation](https://pcsx-redux.consoledev.net) for more information. There is also some documentation nested within the folders.
11+
12+
This repository will be updated periodically to match the upstream repository, and its history will be rewritten to remove all commits that are not related to the tools. While care is taken to try and ensure some sort of consistency, a simple `git pull` may not work to update it. Resetting to the remote HEAD is recommended when updating.
13+
14+
All of the code here is MIT-licensed. See the [LICENSE](LICENSE) file for more information.

.github/filter-support/close.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Close Pull Request
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
jobs:
8+
run:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: superbrothers/close-pull-request@v3
12+
with:
13+
comment: "Thank you for your pull request, but this repository is a read-only mirror of the [PCSX-Redux project](https://github.com/grumpycoders/pcsx-redux). Please open your pull request there instead."

.github/filter-support/filter.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
ROOT=$(dirname $0)
6+
CWD=$(pwd)
7+
cd $ROOT
8+
ROOT=$(pwd)
9+
cd $CWD
10+
11+
# Delete non-tools source code
12+
git filter-branch -f --tree-filter '(mv src/mips . || true) && (mv src/support . || true) && (mv src/supportpsx . || true) && rm -rf src && mkdir -p src && (mv mips src || true) && (mv support src || true) && mv supportpsx src || true' --tag-name-filter cat --prune-empty
13+
git filter-branch -f --tree-filter 'find src/mips -depth -type f -not -path src/mips/common/\* -delete || true' --tag-name-filter cat --prune-empty
14+
15+
# Delete some root files.
16+
git filter-branch -f --tree-filter 'rm -f *.yml LICENSE* mips.ps1 TODO.md' --tag-name-filter cat --prune-empty
17+
18+
# Delete irrelevant folders
19+
git filter-branch -f --tree-filter 'rm -rf .github hardware i18n resources .vscode vsprojects tests/pcsxrunner' --tag-name-filter cat --prune-empty
20+
21+
# Need to delete submodules actively.
22+
# Done in two passes for speed.
23+
git filter-branch -f --tree-filter 'find third_party -maxdepth 1 -type d -and -not -name third_party -and -not -path third_party/cueparser* -and -not -path third_party/ELFIO\* -and -not -path third_party/expected\* -and -not -path third_party/fmt\* -and -not -path third_party/googletest\* -and -not -path third_party/iec-60908b\* -and -not -path third_party/magic_enum\* -and -not -path third_party/ucl\* -exec rm -rf {} \; || true' --tag-name-filter cat --prune-empty
24+
git filter-branch -f --tree-filter 'find third_party -maxdepth 1 -type d -and -not -name third_party -and -not -path third_party/cueparser* -and -not -path third_party/ELFIO\* -and -not -path third_party/expected\* -and -not -path third_party/fmt\* -and -not -path third_party/googletest\* -and -not -path third_party/iec-60908b\* -and -not -path third_party/magic_enum\* -and -not -path third_party/ucl\* -exec git rm -f {} \; || true' --tag-name-filter cat --prune-empty
25+
26+
# Delete ffmpeg, versionning, Lua, and libuv-related source code
27+
git filter-branch -f --tree-filter 'find src -type f -name \*lua\* -delete || true' --tag-name-filter cat --prune-empty
28+
git filter-branch -f --tree-filter 'find src -type f -name assembler.\* -delete || true' --tag-name-filter cat --prune-empty
29+
git filter-branch -f --tree-filter 'find src -type f -name ffmpeg\* -delete || true' --tag-name-filter cat --prune-empty
30+
git filter-branch -f --tree-filter 'find src -type f -name uv\* -delete || true' --tag-name-filter cat --prune-empty
31+
git filter-branch -f --tree-filter 'find src -type f -name version\* -delete || true' --tag-name-filter cat --prune-empty
32+
33+
# Inject our new root files.
34+
git filter-branch -f --tree-filter "cp ${ROOT}/README-filtered.md README.md && cp ${ROOT}/LICENSE-filtered LICENSE && cp ${ROOT}/Makefile-filtered Makefile && mkdir -p .github/workflows && cp ${ROOT}/close.yml .github/workflows" --tag-name-filter cat

0 commit comments

Comments
 (0)