changeset 212:6b08fbd7f206

chore: merge branches
author Paper <mrpapersonic@gmail.com>
date Sun, 07 Jan 2024 09:54:50 -0500
parents 7cf53145de11 (current diff) 52dda8927a81 (diff)
children 58e81b42a0d6
files
diffstat 11 files changed, 243 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.builds/macos.yml	Sun Jan 07 09:54:50 2024 -0500
@@ -0,0 +1,43 @@
+image: debian/bookworm
+packages:
+  - qtbase5-dev
+  - qttools5-dev
+  - cmake
+  - clang
+  - libcurl4-openssl-dev
+  - wget
+  - fuse
+  - file
+  - pkg-config
+  # osxcross deps start
+  - libxml2-dev
+  - libssl-dev
+  - lzma-dev
+  - python3
+  - xz-utils
+  - bzip2
+  - cpio
+  - libbz2-1.0
+  - zlib1g-dev
+sources:
+  - https://hg.sr.ht/~mrpapersonic/minori
+  - https://github.com/tpoechtrager/osxcross
+environment:
+  BUILD_SUBMITTER: hg.sr.ht
+  MACOSX_DEPLOYMENT_TARGET: 10.9
+tasks:
+  - build: |
+      cd osxcross/tarballs
+      wget "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.9.sdk.tar.xz"
+      cd ..
+      export TARGET_DIR="$PWD/target"
+      UNATTENDED=1 ./build.sh
+      export PATH="$TARGET_DIR/bin:$PATH"
+      cd ..
+      osxcross-macports install qt5-qtbase qt5-qttools
+      CC="o64-clang" CXX="o64-clang++" CXXFLAGS="-stdlib=libc++" cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER= -DCMAKE_CXX_COMPILER=o64-clang++
+      make
+triggers:
+  - action: email
+    condition: failure
+    to: Paper <mrpapersonic@gmail.com>
--- a/.builds/win32.yml	Sun Jan 07 09:54:17 2024 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-image: debian/bookworm
-packages:
-  - wget
-  - tar
-  - zstd
-  - gpg
-  - clang
-  - lld
-  - xz-utils
-  - wine
-  - cmake
-  - ncurses-bin
-  - qtbase5-dev
-  - qttools5-dev
-sources:
-  - https://hg.sr.ht/~mrpapersonic/minori
-  - https://github.com/holyblackcat/quasi-msys2
-environment:
-  BUILD_SUBMITTER: hg.sr.ht
-tasks:
-  - get-wine32: |
-      sudo dpkg --add-architecture i386
-      sudo apt-get update
-      sudo apt-get -y install wine32:i386
-  - build: |
-      export WINEARCH=win32
-      cd quasi-msys2
-      echo MINGW32 >msystem.txt
-      make install _gcc _qt5-base _qt5-tools _curl
-      cd ../minori
-      mkdir build
-      cd build
-      sudo bash -c 'echo -n 1 >/proc/sys/fs/binfmt_misc/status'
-      bash -c 'source ../../quasi-msys2/env/all.src && cmake .. -G "Unix Makefiles" -DCMAKE_AUTOMOC_EXECUTABLE="$(which moc)" -DCMAKE_AUTORCC_EXECUTABLE="$(which rcc)" && make'
-triggers:
-  - action: email
-    condition: failure
-    to: Paper <mrpapersonic@gmail.com>
--- a/.builds/win64.yml	Sun Jan 07 09:54:17 2024 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-image: debian/bookworm
-packages:
-  - wget
-  - tar
-  - zstd
-  - gpg
-  - clang
-  - lld
-  - xz-utils
-  - wine
-  - cmake
-  - ncurses-bin
-  - qtbase5-dev
-  - qttools5-dev
-sources:
-  - https://hg.sr.ht/~mrpapersonic/minori
-  - https://github.com/holyblackcat/quasi-msys2
-environment:
-  BUILD_SUBMITTER: hg.sr.ht
-tasks:
-  - build: |
-      cd quasi-msys2
-      echo MINGW64 >msystem.txt
-      make install _gcc _qt5-base _qt5-tools _curl
-      cd ../minori
-      mkdir build
-      cd build
-      sudo bash -c 'echo -n 1 >/proc/sys/fs/binfmt_misc/status'
-      bash -c 'source ../../quasi-msys2/env/all.src && export AUTOMOC_EXECUTABLE="$(which moc)" && export AUTORCC_EXECUTABLE="$(which rcc)" && cmake .. -G "Unix Makefiles" && make'
-triggers:
-  - action: email
-    condition: failure
-    to: Paper <mrpapersonic@gmail.com>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.builds/windows.yml	Sun Jan 07 09:54:50 2024 -0500
@@ -0,0 +1,50 @@
+image: debian/bookworm
+packages:
+  - wget
+  - tar
+  - zstd
+  - gpg
+  - clang
+  - lld
+  - xz-utils
+  - wine
+  - cmake
+  - ncurses-bin
+  - qtbase5-dev
+  - qttools5-dev
+sources:
+  - https://hg.sr.ht/~mrpapersonic/minori
+environment:
+  BUILD_SUBMITTER: hg.sr.ht
+tasks:
+  - build-win64: |
+      export WINEARCH=win64
+      git clone https://github.com/holyblackcat/quasi-msys2 quasi-msys2-win64
+      cd quasi-msys2-win64
+      echo MINGW64 >msystem.txt
+      make install _gcc _qt5-base _qt5-tools _curl
+      cd ../minori
+      mkdir build64
+      cd build64
+      sudo bash -c 'echo -n 1 >/proc/sys/fs/binfmt_misc/status'
+      bash -c 'source ../../quasi-msys2-win64/env/all.src && cmake .. -G "Unix Makefiles" -DCMAKE_AUTOMOC_EXECUTABLE="$(which moc)" -DCMAKE_AUTORCC_EXECUTABLE="$(which rcc)" && make'
+  - get-wine32: |
+      sudo dpkg --add-architecture i386
+      sudo apt-get update
+      sudo apt-get -y install wine32:i386
+  - build-win32: |
+      export WINEARCH=win32
+      export WINEPREFIX="$HOME/.wine32"
+      git clone https://github.com/holyblackcat/quasi-msys2 quasi-msys2-win32
+      cd quasi-msys2-win32
+      echo MINGW32 >msystem.txt
+      make install _gcc _qt5-base _qt5-tools _curl
+      cd ../minori
+      mkdir build32
+      cd build32
+      sudo bash -c 'echo -n 1 >/proc/sys/fs/binfmt_misc/status'
+      bash -c 'source ../../quasi-msys2-win32/env/all.src && cmake .. -G "Unix Makefiles" -DCMAKE_AUTOMOC_EXECUTABLE="$(which moc)" -DCMAKE_AUTORCC_EXECUTABLE="$(which rcc)" && make'
+triggers:
+  - action: email
+    condition: failure
+    to: Paper <mrpapersonic@gmail.com>
--- a/CMakeLists.txt	Sun Jan 07 09:54:17 2024 -0500
+++ b/CMakeLists.txt	Sun Jan 07 09:54:50 2024 -0500
@@ -190,8 +190,7 @@
 set_property(TARGET minori PROPERTY AUTOMOC ON)
 set_property(TARGET minori PROPERTY AUTORCC ON)
 
-target_include_directories(minori PUBLIC ${CURL_INCLUDE_DIRS} PRIVATE ${INCLUDE})
-target_include_directories(minori PUBLIC ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS})
+target_include_directories(minori PUBLIC ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} PRIVATE ${INCLUDE})
 target_compile_options(minori PRIVATE -Wall -Wpedantic -Wextra -Wsuggest-override -Wold-style-cast)
 if(APPLE)
 	target_compile_definitions(minori PUBLIC MACOSX)
--- a/dep/animia/CMakeLists.txt	Sun Jan 07 09:54:17 2024 -0500
+++ b/dep/animia/CMakeLists.txt	Sun Jan 07 09:54:50 2024 -0500
@@ -72,17 +72,19 @@
 			list(APPEND DEFINES LIBUTIL)
 			list(APPEND SRC_FILES src/fd/libutil.cc)
 		endif() # LIBUTIL_GOOD
-	elseif(LIBKVM_LIBRARY) # BSD libkvm
+	elseif(LIBKVM_LIBRARY) # OpenBSD kvm
+		list(APPEND LIBRARIES ${LIBKVM_LIBRARY})
+		list(APPEND DEFINES LIBKVM)
+		list(APPEND SRC_FILES src/fd/kvm.cc)
+
 		get_filename_component(LIBKVM_DIR ${LIBKVM_LIBRARY} DIRECTORY)
 
 		include(CheckLibraryExists)
-		check_library_exists(kvm kvm_getprocs ${LIBKVM_DIR} LIBKVM_GOOD)
+		check_library_exists(kvm kvm_getfiles ${LIBKVM_DIR} LIBKVM_HAS_GETFILES)
 
-		if(LIBKVM_GOOD)
-			list(APPEND LIBRARIES ${LIBKVM_LIBRARY})
-			list(APPEND DEFINES LIBKVM)
-			list(APPEND SRC_FILES src/fd/libkvm.cc)
-		endif() # LIBUTIL_GOOD
+		if(LIBKVM_HAS_GETFILES)
+			list(APPEND DEFINES HAVE_KVM_GETFILES)
+		endif() # LIBKVM_HAS_GETFILES
 	endif() # LINUX
 
 	# X11
@@ -108,8 +110,8 @@
 			pkg_check_modules(X11 x11)
 			if(X11_FOUND)
 				# Check for XRes the hard way
-				find_path(X11_XRes_HEADER "extensions/XRes.h" PATHS ${X11_INCLUDE_DIRS})
-				find_library(X11_XRes_LIB XRes ${X11_LIBRARY_DIRS})
+				find_path(X11_XRes_HEADER "X11/extensions/XRes.h" PATHS ${X11_INCLUDE_DIRS})
+				find_library(X11_XRes_LIB XRes PATHS ${X11_LIBRARY_DIRS})
 
 				if(X11_XRes_HEADER AND X11_XRes_LIB)
 					# TODO: We should REALLY check for XResQueryClientIds here...
@@ -150,5 +152,5 @@
 )
 
 target_compile_definitions(animia PRIVATE ${DEFINES})
-target_include_directories(animia PRIVATE include PUBLIC ${INCLUDE_DIRS})
+target_include_directories(animia PUBLIC include PRIVATE ${INCLUDE_DIRS})
 target_link_libraries(animia PUBLIC ${LIBRARIES})
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dep/animia/include/animia/fd/kvm.h	Sun Jan 07 09:54:50 2024 -0500
@@ -0,0 +1,17 @@
+#ifndef __animia__animia__fd__kvm_h
+#define __animia__animia__fd__kvm_h
+
+#include <set>
+#include <string>
+
+#include "animia/fd.h"
+#include "animia/types.h"
+
+namespace animia::internal::kvm {
+
+bool EnumerateOpenProcesses(process_proc_t process_proc);
+bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc);
+
+} // namespace animia::internal::kvm
+
+#endif // __animia__animia__fd__kvm_h
--- a/dep/animia/src/fd.cc	Sun Jan 07 09:54:17 2024 -0500
+++ b/dep/animia/src/fd.cc	Sun Jan 07 09:54:50 2024 -0500
@@ -16,6 +16,10 @@
 #	include "animia/fd/libutil.h"
 #endif
 
+#ifdef LIBKVM
+#	include "animia/fd/kvm.h"
+#endif
+
 namespace animia::internal {
 
 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) {
@@ -37,6 +41,10 @@
 	success ^= libutil::EnumerateOpenFiles(pids, open_file_proc);
 #endif
 
+#ifdef LIBKVM
+	success ^= kvm::EnumerateOpenFiles(pids, open_file_proc);
+#endif
+
 	return success;
 }
 
@@ -59,6 +67,10 @@
 	success ^= libutil::EnumerateOpenProcesses(process_proc);
 #endif
 
+#ifdef LIBKVM
+	success ^= kvm::EnumerateOpenProcesses(process_proc);
+#endif
+
 	return success;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dep/animia/src/fd/kvm.cc	Sun Jan 07 09:54:50 2024 -0500
@@ -0,0 +1,103 @@
+/* kvm.cc: provides support for OpenBSD's libkvm
+**
+** Theoretically, this code *should* work, but I haven't
+** even tested it.
+**
+** This also contains some code to support NetBSD, although
+** it calls the kernel instead of kvm.
+*/
+
+#include "animia/fd/kvm.h"
+#include "animia/fd.h"
+#include "animia.h"
+
+#include <sys/types.h>
+#include <sys/user.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/param.h>
+#include <sys/vnode.h>
+#include <sys/queue.h>
+#include <sys/sysctl.h>
+
+#include <kvm.h>
+
+#include <string>
+
+namespace animia::internal::kvm {
+
+bool EnumerateOpenProcesses(process_proc_t process_proc) {
+	char errbuf[_POSIX2_LINE_MAX];
+	kvm_t* kernel = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
+	if (!kernel)
+		return false;
+
+	int entries = 0;
+	struct kinfo_proc* kinfo = kvm_getprocs(kernel, KERN_PROC_ALL, 0, &entries);
+	if (!kinfo)
+		return false;
+
+	for (int i = 0; i < entries; i++)
+		if (!process_proc({kinfo[i].ki_paddr->p_pid, kinfo[i].ki_paddr->p_comm}))
+			return false;
+
+	kvm_close(kernel);
+
+	return true;
+}
+
+bool EnumerateOpenFiles(std::set<pid_t>& pids, open_file_proc_t open_file_proc) {
+#ifdef HAVE_KVM_GETFILES
+	char errbuf[_POSIX2_LINE_MAX];
+	kvm_t* kernel = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
+	if (!kernel)
+		return false;
+
+	for (const auto& pid : pids) {
+		int cnt;
+		struct kinfo_file* kfile = kvm_getfiles(kernel, KERN_FILE_BYPID, pid, &cnt);
+		if (!kfile)
+			return false;
+
+		for (int i = 0; i < cnt; i++)
+			if (!open_file_proc({pid, kfile[i].kf_path}))
+				return false;
+	}
+
+	kvm_close(kernel);
+
+	return true;
+#else /* For NetBSD... I think */
+	for (const auto& pid : pids) {
+		int mib[6] = {
+			CTL_KERN,
+			KERN_FILE2,
+			KERN_FILE_BYPID,
+			pid,
+			sizeof(struct kinfo_file),
+			0
+		};
+
+		size_t len = 0;
+		if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), NULL, &len, NULL, 0) == -1)
+			return false;
+
+		mib[5] = len / sizeof(struct kinfo_file);
+
+		std::unique_ptr<struct kinfo_file[]> buf(new struct kinfo_file[mib[5]]);
+		if (!buf)
+			return false;
+
+		if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), buf.get(), &len, NULL, 0) == -1)
+			return false;
+
+		for (size_t i = 0; i < cnt; i++)
+			if (!open_file_proc({pid, kfile[i].kf_path}))
+				return false;
+	}
+
+	return true;
+#endif
+}
+
+}
--- a/src/gui/translate/anime.cc	Sun Jan 07 09:54:17 2024 -0500
+++ b/src/gui/translate/anime.cc	Sun Jan 07 09:54:50 2024 -0500
@@ -1,8 +1,11 @@
 #include "core/anime.h"
 #include "core/strings.h"
 #include "gui/translate/anime.h"
+
 #include <QCoreApplication>
 
+#include <unordered_map>
+
 namespace Translate {
 
 std::string ToString(const Anime::ListStatus status) {
--- a/src/gui/translate/config.cc	Sun Jan 07 09:54:17 2024 -0500
+++ b/src/gui/translate/config.cc	Sun Jan 07 09:54:50 2024 -0500
@@ -1,6 +1,8 @@
 #include "core/config.h"
 #include "gui/translate/config.h"
 
+#include <unordered_map>
+
 namespace Translate {
 
 Themes ToTheme(const std::string& theme) {