diff --git a/pkgs/by-name/dx/dxmt/package.nix b/pkgs/by-name/dx/dxmt/package.nix new file mode 100644 index 000000000000..2545292cb01b --- /dev/null +++ b/pkgs/by-name/dx/dxmt/package.nix @@ -0,0 +1,132 @@ +{ + lib, + stdenv, + pkgsCross, + fetchFromGitHub, + buildPackages, + cmake, + git, + python3, + meson, + ninja, + tinyxxd, + sqlite, + libz, + ncurses, + libxml2, + wine64, + darwin, + symlinkJoin, +}: +let + dxmt-llvm = stdenv.mkDerivation rec { + pname = "dxmt-llvm"; + version = "15.0.7"; + + src = fetchFromGitHub { + owner = "llvm"; + repo = "llvm-project"; + tag = version; + hash = "sha256-wjuZQyXQ/jsmvy6y1aksCcEDXGBjuhpgngF3XQJ/T4s="; + }; + + nativeBuildInputs = [ + cmake + git + ninja + python3 + ]; + + cmakeFlags = [ + "-DLLVM_ENABLE_ZSTD=OFF" + "-DLLVM_BUILD_TOOLS=Off" + "-S ../llvm" + ]; + }; + inherit (darwin) xcode; + + dxmt = pkgsCross.mingwW64.stdenv.mkDerivation (finalAttrs: { + pname = "dxmt"; + version = "0.80"; + + src = fetchFromGitHub { + owner = "3shain"; + repo = "dxmt"; + rev = "v${finalAttrs.version}"; + hash = "sha256-HNSKqEYu8se8DyzwRbqfmHRRyBXyW6D5ddPaEdnkuL4="; + fetchSubmodules = true; + }; + + patches = [ + ./winecrt0.patch + ]; + + postPatch = '' + substituteInPlace src/airconv/darwin/meson.build --replace-fail -lcurses -lncurses + + sed -e "/find_program('xcrun')/d" \ + -e "s,metalir_generator = generator(xcrun,metalir_generator = generator(find_program('${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metal')," \ + -e "s,metallib_generator = generator(xcrun,metallib_generator = generator(find_program('${xcode}/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metallib')," \ + -e "s/'-sdk', 'macosx', 'metal\(lib\)\{0,1\}', //" \ + -i meson.build + ''; + + nativeBuildInputs = [ + meson + ninja + tinyxxd + buildPackages.stdenv.cc + ]; + + buildInputs = [ + sqlite + libz + ncurses + libxml2 + ]; + + mesonFlags = [ + (lib.mesonOption "native_llvm_path" "${dxmt-llvm}") + (lib.mesonOption "wine_install_path" "${wine64}") + ]; + + preBuild = '' + export HOME=$TMPDIR + ''; + + __structuredAttrs = true; + strictDeps = true; + + meta = { + description = "Metal-based translation layer for Direct3D 10/11"; + homepage = "https://github.com/3shain/dxmt"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.feyorsh ]; + platforms = lib.platforms.windows; + hydraPlatforms = [ ]; + }; + }); +in +symlinkJoin { + name = "dxmt-${dxmt.version}"; + + paths = [ dxmt ]; + + passthru = { + inherit dxmt; + }; + + __structuredAttrs = true; + strictDeps = true; + + meta = { + inherit (dxmt.meta) + description + homepage + maintainers + license + ; + platforms = [ "x86_64-darwin" ]; + hydraPlatforms = [ ]; + }; +} diff --git a/pkgs/by-name/dx/dxmt/winecrt0.patch b/pkgs/by-name/dx/dxmt/winecrt0.patch new file mode 100644 index 000000000000..f4d0830659bb --- /dev/null +++ b/pkgs/by-name/dx/dxmt/winecrt0.patch @@ -0,0 +1,33 @@ +diff --git c/src/winemetal/meson.build i/src/winemetal/meson.build +index 858d4b3..d937e29 100644 +--- c/src/winemetal/meson.build ++++ i/src/winemetal/meson.build +@@ -26,8 +26,19 @@ elif wine_install_path != '' + if not wine_install_path.startswith('/') + wine_install_path = join_paths(meson.project_source_root(), wine_install_path) + endif +- lib_winecrt0 = cc.find_library('winecrt0', dirs : [ join_paths(wine_install_path,'lib/wine', windows_builtin_install_dir) ]) +- lib_ntdll = cc.find_library('ntdll', dirs : [ join_paths(wine_install_path, 'lib/wine', windows_builtin_install_dir)], static: true) ++ winecrt0_unix_archive = custom_target( ++ 'winecrt0_fixup', ++ output : 'libwinecrt0_fixed.a', ++ command : [ ++ 'sh', '-c', ++ 'ar p "$1" unix_lib.o > unix_lib.o && ar crs "$2" unix_lib.o', ++ 'sh', ++ join_paths(wine_install_path, 'lib/wine', windows_builtin_install_dir, 'libwinecrt0.a'), ++ '@OUTPUT@', ++ ], ++ ) ++ lib_winecrt0 = declare_dependency(sources : winecrt0_unix_archive) ++ lib_ntdll = cc.find_library('ntdll', dirs : [ join_paths(wine_install_path, 'lib/wine', windows_builtin_install_dir)]) + lib_dbghelp = cc.find_library('dbghelp', dirs : [ join_paths(wine_install_path, 'lib/wine', windows_builtin_install_dir) ]) + winebuild = join_paths(wine_install_path, 'bin/winebuild') + else +@@ -59,4 +70,4 @@ custom_target('postprocess_lib', + + if cpu_family == 'x86_64' or cpu_family == 'aarch64' + subdir('unix') +-endif +\ No newline at end of file ++endif