Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obj2voxel: init at 1.3.4 #254299

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkgs/by-name/ob/obj2voxel/1.3.4-fix-type-mismatch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff -Naurd x/voxelio/src/stream.cpp y/voxelio/src/stream.cpp
--- x/voxelio/src/stream.cpp 2023-09-11 07:50:51.522074934 +0000
+++ y/voxelio/src/stream.cpp 2023-09-11 08:02:19.105142327 +0000
@@ -117,7 +117,8 @@
return;
}

- size_t overwriteLength = std::min(size() - pos, length);
+ size_t const remaining = size() - pos;
+ size_t overwriteLength = std::min(remaining, length);
size_t pushLength = length - overwriteLength;

auto overwriteTarget = static_cast<std::vector<u8> *>(sink)->begin() + static_cast<ptrdiff_t>(pos);
74 changes: 74 additions & 0 deletions pkgs/by-name/ob/obj2voxel/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, cmake
}:

stdenv.mkDerivation (finalAttrs: {
pname = "obj2voxel";
version = "1.3.4";

src = (
fetchFromGitHub {
owner = "Eisenwave";
repo = "obj2voxel";
rev = "v${finalAttrs.version}";
fetchSubmodules = true;
hash = "sha256-FkGQjYm15le1Na+2U1TgK4nNOZNs5bME5J87pjVFpDs=";
}
).overrideAttrs (
# prompted by https://github.com/Eisenwave/obj2voxel/pull/9
_: {
GIT_CONFIG_KEY_0 = "url.https://github.com/.insteadOf";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if we could upstream the url change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done: Eisenwave/obj2voxel#9

For the time being, the workaround might still be necessary.

GIT_CONFIG_VALUE_0 = "[email protected]:";
GIT_CONFIG_COUNT = 1;
}
);

patches = [
# pull missing definitions (https://github.com/Eisenwave/voxel-io/pull/3)
(
fetchpatch {
name = "add-std-includes.patch";
url = "https://github.com/Eisenwave/voxel-io/compare/d902568de2d4afda254e533a5ee9e4ad5fe7d2be...2f800f6aca8acd0cc18f9625b411c6dc2956f2ea.patch";
hash = "sha256-2JeFBx0Ds++BplWXuxOo4KOAW6gXCT/kFI74i0M0ROM=";
stripLen = 1;
extraPrefix = "voxelio/";
}
)
# fix build on aarch64-darwin (https://github.com/Eisenwave/voxel-io/pull/4)
(
fetchpatch {
name = "fix-aarch64-darwin-type-mismatch.patch";
url = "https://github.com/Eisenwave/voxel-io/compare/d902568de2d4afda254e533a5ee9e4ad5fe7d2be...669ac7e9c640fa92bc1989cc7811afbed9bbd8b8.patch";
hash = "sha256-AuvjpTGBLKN0f47IoxIDkV32g9A/4RbvGBo3ToGiH/w=";
stripLen = 1;
extraPrefix = "voxelio/";
}
)
# already fixed in upstream git head
./1.3.4-fix-type-mismatch.patch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use fetchpatch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, not easily. By now, upstream master avoids the issue because all these size_t typed variables have been changed to usize. But this is a rather global change not easily applied, so I decided towards a clear and small patch that just solves the issue remaining after applying the fixes that made it into pull requests.

IMHO, the next best solution would actually be to just build the upstream master. But for now, I decided to keep with the usual policy of building something that has a version number.

];

postPatch = ''
echo 'install(TARGETS obj2voxel-cli DESTINATION ''${CMAKE_INSTALL_PREFIX}/bin)' >> CMakeLists.txt
'';

cmakeFlags = [
"-DBUILD_SHARED_LIBS=${if stdenv.targetPlatform.isStatic then "OFF" else "ON"}"
];

strictDeps = true;

nativeBuildInputs = [ cmake ];

meta = with lib; {
description = "Convert OBJ and STL files to voxels, with support for textures";
mainProgram = "obj2voxel";
homepage = "https://github.com/Eisenwave/obj2voxel";
license = licenses.mit;
platforms = platforms.unix;
maintainers = [ maintainers.gm6k ];
};
})