Skip to content

Commit 94e3921

Browse files
authored
Merge branch 'main' into Breakpoints-improvements
2 parents a962441 + c7d263b commit 94e3921

Some content is hidden

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

73 files changed

+2669
-877
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Nix Flake actions
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
nix-matrix:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
matrix: ${{ steps.set-matrix.outputs.matrix }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: cachix/install-nix-action@v30
15+
- id: set-matrix
16+
name: Generate Nix Matrix
17+
run: |
18+
set -Eeu
19+
matrix="$(nix eval --json '.#githubActions.matrix')"
20+
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
21+
22+
nix-build:
23+
name: ${{ matrix.name }} (${{ matrix.system }})
24+
needs: nix-matrix
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: n1hility/cancel-previous-runs@v2
31+
with:
32+
token: ${{ secrets.GITHUB_TOKEN }}
33+
- uses: cachix/install-nix-action@v30
34+
- run: nix build -L '.#${{ matrix.attr }}'

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,9 @@ luacov.stats.out
124124
/lua
125125
/lua_modules
126126
/.luarocks
127+
128+
# appimage build files
129+
/appimage-build
130+
/AppDir
131+
/*.AppImage
132+
/*.AppImage.zsync

Makefile

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ CROSS ?= none
55

66
UNAME_S := $(shell uname -s)
77
UNAME_M := $(shell uname -m)
8-
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
8+
rwildcard = $(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
99
CC_IS_CLANG := $(shell $(CC) --version | grep -q clang && echo true || echo false)
1010

11-
PACKAGES := capstone freetype2 glfw3 libavcodec libavformat libavutil libswresample libuv zlib libcurl
11+
PACKAGES := capstone freetype2 glfw3 libavcodec libavformat libavutil libswresample libcurl libuv zlib
12+
OPTIONAL_PACKAGES := md4c fmt libllhttp libluv liburiparser
13+
OPTIONAL_LIBRARIES := multipart ucl
1214

1315
LOCALES := el es_ES fr ja pt_BR uk zh_CN
1416

@@ -19,29 +21,28 @@ HAS_SUBMODULES = true
1921
endif
2022

2123
CXXFLAGS += -std=c++2b
22-
CPPFLAGS += `pkg-config --cflags $(PACKAGES)`
2324
CPPFLAGS += -I.
2425
CPPFLAGS += -Isrc
2526
CPPFLAGS += -Ithird_party
2627
CPPFLAGS += -Ithird_party/ELFIO
27-
CPPFLAGS += -Ithird_party/fmt/include/
28+
CPPFLAGS_pkg_fmt += -Ithird_party/fmt/include/
2829
CPPFLAGS += -Ithird_party/gl3w
2930
CPPFLAGS += -Ithird_party/googletest/googletest/include
3031
CPPFLAGS += -Ithird_party/imgui
3132
CPPFLAGS += -Ithird_party/imgui/backends
3233
CPPFLAGS += -Ithird_party/imgui/examples
3334
CPPFLAGS += -Ithird_party/imgui/misc/cpp
3435
CPPFLAGS += -Ithird_party/libelfin
35-
CPPFLAGS += -Ithird_party/llhttp
36+
CPPFLAGS_pkg_libllhttp += -Ithird_party/llhttp
3637
CPPFLAGS += -Ithird_party/luajit/src
37-
CPPFLAGS += -Ithird_party/luv/src
38-
CPPFLAGS += -Ithird_party/luv/deps/lua-compat-5.3/c-api
38+
CPPFLAGS_pkg_libluv += -Ithird_party/luv/src
39+
CPPFLAGS_pkg_libluv += -Ithird_party/luv/deps/lua-compat-5.3/c-api
3940
CPPFLAGS += -Ithird_party/magic_enum/include/magic_enum
40-
CPPFLAGS += -Ithird_party/md4c/src
41-
CPPFLAGS += -Ithird_party/multipart-parser-c
41+
CPPFLAGS_pkg_md4c += -Ithird_party/md4c/src
42+
CPPFLAGS_lib_multipart += -Ithird_party/multipart-parser-c
4243
CPPFLAGS += -Ithird_party/tracy/public
43-
CPPFLAGS += -Ithird_party/ucl -Ithird_party/ucl/include
44-
CPPFLAGS += -Ithird_party/uriparser/include
44+
CPPFLAGS_lib_ucl += -Ithird_party/ucl -Ithird_party/ucl/include
45+
CPPFLAGS_pkg_liburiparser += -Ithird_party/uriparser/include
4546
CPPFLAGS += -Ithird_party/zep/extensions
4647
CPPFLAGS += -Ithird_party/zep/include
4748
CPPFLAGS += -Ithird_party/xbyak/xbyak
@@ -75,7 +76,6 @@ ifeq ($(UNAME_S),Darwin)
7576
endif
7677

7778
LUAJIT_LDFLAGS := $(LDFLAGS)
78-
LDFLAGS += `pkg-config --libs $(PACKAGES)`
7979

8080
ifeq ($(UNAME_S),Darwin)
8181
LDFLAGS += -lc++ -framework GLUT -framework OpenGL -framework CoreFoundation -framework Cocoa
@@ -108,8 +108,8 @@ endif
108108

109109
LD := $(CXX)
110110

111-
SRCS := $(call rwildcard,src/,*.cc)
112-
SRCS += third_party/fmt/src/os.cc third_party/fmt/src/format.cc
111+
SRCS += $(call rwildcard,src/,*.cc)
112+
SRCS_pkg_fmt += third_party/fmt/src/os.cc third_party/fmt/src/format.cc
113113
IMGUI_SRCS += $(wildcard third_party/imgui/*.cpp)
114114
VIXL_SRCS := $(call rwildcard, third_party/vixl/src,*.cc)
115115
SRCS += $(IMGUI_SRCS)
@@ -129,16 +129,16 @@ SRCS += third_party/imgui/misc/freetype/imgui_freetype.cpp
129129
SRCS += third_party/imgui_lua_bindings/imgui_lua_bindings.cpp
130130
SRCS += third_party/imgui_md/imgui_md.cpp
131131
SRCS += third_party/imgui_memory_editor/imgui_memory_editor.cpp
132-
SRCS += $(wildcard third_party/llhttp/*.c)
132+
SRCS_pkg_libllhttp += $(wildcard third_party/llhttp/*.c)
133133
SRCS += $(wildcard third_party/lpeg/*.c)
134134
SRCS += third_party/lua-protobuf/pb.c
135135
SRCS += third_party/luafilesystem/src/lfs.c
136-
SRCS += third_party/luv/src/luv.c
137-
SRCS += third_party/md4c/src/md4c.c
138-
SRCS += third_party/multipart-parser-c/multipart_parser.c
136+
SRCS_pkg_libluv += third_party/luv/src/luv.c
137+
SRCS_pkg_md4c += third_party/md4c/src/md4c.c
138+
SRCS_lib_multipart += third_party/multipart-parser-c/multipart_parser.c
139139
SRCS += third_party/nanovg/src/nanovg.c
140-
SRCS += third_party/tracy/public/TracyClient.cpp
141-
SRCS += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c
140+
SRCS_ReleaseWithTracy += third_party/tracy/public/TracyClient.cpp
141+
SRCS_lib_ucl += third_party/ucl/src/n2e_99.c third_party/ucl/src/alloc.c
142142
SRCS += $(wildcard third_party/uriparser/src/*.c)
143143
SRCS += third_party/zep/extensions/repl/mode_repl.cpp
144144
SRCS += $(wildcard third_party/zep/src/*.cpp)
@@ -176,6 +176,37 @@ TOOLS = exe2elf exe2iso modconv ps1-packer psyq-obj-parser
176176

177177
##############################################################################
178178

179+
SRCS += $(SRCS_$(BUILD))
180+
181+
define CHECK_PKG
182+
ifeq ($(shell pkg-config --exists $(1) && echo true || echo false),true)
183+
PACKAGES += $(1)
184+
else
185+
CPPFLAGS += $(CPPFLAGS_pkg_$(1))
186+
LDFLAGS += $(LDFLAGS_pkg_$(1))
187+
SRCS += $(SRCS_pkg_$(1))
188+
endif
189+
endef
190+
191+
define CHECK_LIB
192+
ifeq ($(shell echo "int main(){}" | gcc -x c - -l$(1) -Wl,--no-as-needed -Wl,--unresolved-symbols=ignore-all -Wl,--no-undefined -o /dev/null >& /dev/null && echo true || echo false),true)
193+
LDFLAGS += -l$(1)
194+
else
195+
CPPFLAGS += $(CPPFLAGS_lib_$(1))
196+
LDFLAGS += $(LDFLAGS_lib_$(1))
197+
SRCS += $(SRCS_lib_$(1))
198+
endif
199+
endef
200+
201+
$(foreach pkg,$(OPTIONAL_PACKAGES),$(eval $(call CHECK_PKG,$(pkg))))
202+
$(foreach lib,$(OPTIONAL_LIBRARIES),$(eval $(call CHECK_LIB,$(lib))))
203+
204+
CPPFLAGS_PKGCONFIG := $(shell pkg-config --cflags $(PACKAGES))
205+
LDFLAGS_PKGCONFIG := $(shell pkg-config --libs $(PACKAGES))
206+
207+
CPPFLAGS += $(CPPFLAGS_PKGCONFIG)
208+
LDFLAGS += $(LDFLAGS_PKGCONFIG)
209+
179210
OBJECTS += $(patsubst %.c,%.o,$(filter %.c,$(SRCS)))
180211
OBJECTS += $(patsubst %.cc,%.o,$(filter %.cc,$(SRCS)))
181212
OBJECTS += $(patsubst %.cpp,%.o,$(filter %.cpp,$(SRCS)))
@@ -259,13 +290,13 @@ $(TARGET): $(OBJECTS)
259290
%.o: %.mm
260291
$(CC) -c -o $@ $< $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CFLAGS)
261292

262-
%.dep: %.c
293+
%.dep: third_party/luajit/src/luajit.h %.c
263294
$(CC) $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CFLAGS) -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
264295

265-
%.dep: %.cc
296+
%.dep: third_party/luajit/src/luajit.h %.cc
266297
$(CXX) $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CXXFLAGS) -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
267298

268-
%.dep: %.cpp
299+
%.dep: third_party/luajit/src/luajit.h %.cpp
269300
$(CXX) $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CXXFLAGS) -M -MT $(addsuffix .o, $(basename $@)) -MF $@ $<
270301

271302
clean:
@@ -329,3 +360,7 @@ endif
329360
endif
330361
endif
331362
endif
363+
364+
third_party/luajit/src/lua.hpp: third_party/luajit/src/luajit.h
365+
366+
third_party/luajit/src/luajit.h: third_party/luajit/src/libluajit.a

flake.lock

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
description = "PlayStation 1 emulator and debugger";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
nix-github-actions.url = "github:nix-community/nix-github-actions";
7+
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
8+
};
9+
10+
outputs = {
11+
self,
12+
nixpkgs,
13+
nix-github-actions
14+
}:
15+
let
16+
lib = nixpkgs.lib;
17+
# githubSystems = builtins.attrNames nix-github-actions.lib.githubPlatforms;
18+
# forAllSystems = lib.genAttrs lib.systems.flakeExposed;
19+
# forGithubSystems = lib.genAttrs githubSystems;
20+
# TODO: githubSystems should be supportedSystems intersects lib.githubPlatforms
21+
# Some of the dependencies don't build on clang. Will fix later
22+
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
23+
forAllSystems = lib.genAttrs supportedSystems;
24+
forGithubSystems = lib.genAttrs supportedSystems;
25+
in {
26+
packages = forAllSystems (system:
27+
let pkgs = import nixpkgs { inherit system; };
28+
in {
29+
pcsx-redux = pkgs.callPackage ./pcsx-redux.nix {
30+
src = self;
31+
platforms = lib.systems.flakeExposed;
32+
};
33+
# FIXME: default gets duplicated in githubActions
34+
# default = self.packages.${system}.pcsx-redux;
35+
});
36+
37+
githubActions = nix-github-actions.lib.mkGithubMatrix {
38+
checks = forGithubSystems (system: self.packages.${system});
39+
};
40+
};
41+
}

0 commit comments

Comments
 (0)