jkvargas / russimp-sys

Assimp raw bindings
Other
2 stars 22 forks source link

Improve build on clean environments #34

Closed mxpv closed 1 year ago

mxpv commented 1 year ago

I decided to give russimp-sys a try on clean Mac environment and encountered lots of small build issues. Solving ones could potentially make life a bit easier.

So I’ve include the sys crate in my project and got this error

  --- stderr
  wrapper.h:1:10: fatal error: 'assimp/aabb.h' file not found
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ClangDiagnostic("wrapper.h:1:10: fatal error: 'assimp/aabb.h' file not found\n")', /Users/mxpv/.cargo/registry/src/index.crates.io-6f17d22bba15001f/russimp-sys-2.0.0/build.rs:181:10

Apparently assimp headers must be included even when not building from source. 536fa43 Includes headers in the crate package, so it no longer fails.

```bash ❯ cargo publish --dry-run --allow-dirty -v Updating crates.io index Packaging russimp-sys v2.0.0 (/Users/mxpv/Github/russimp-sys) Archiving Cargo.lock Archiving Cargo.toml Archiving Cargo.toml.orig Archiving LICENSE Archiving README.md Archiving assimp/include/assimp/AssertHandler.h Archiving assimp/include/assimp/BaseImporter.h Archiving assimp/include/assimp/Bitmap.h Archiving assimp/include/assimp/BlobIOSystem.h Archiving assimp/include/assimp/ByteSwapper.h Archiving assimp/include/assimp/ColladaMetaData.h Archiving assimp/include/assimp/Compiler/poppack1.h Archiving assimp/include/assimp/Compiler/pstdint.h Archiving assimp/include/assimp/Compiler/pushpack1.h Archiving assimp/include/assimp/CreateAnimMesh.h Archiving assimp/include/assimp/DefaultIOStream.h Archiving assimp/include/assimp/DefaultIOSystem.h Archiving assimp/include/assimp/Exceptional.h Archiving assimp/include/assimp/GenericProperty.h Archiving assimp/include/assimp/GltfMaterial.h Archiving assimp/include/assimp/Hash.h Archiving assimp/include/assimp/IOStreamBuffer.h Archiving assimp/include/assimp/LineSplitter.h Archiving assimp/include/assimp/LogAux.h Archiving assimp/include/assimp/MathFunctions.h Archiving assimp/include/assimp/MemoryIOWrapper.h Archiving assimp/include/assimp/ObjMaterial.h Archiving assimp/include/assimp/ParsingUtils.h Archiving assimp/include/assimp/Profiler.h Archiving assimp/include/assimp/RemoveComments.h Archiving assimp/include/assimp/SGSpatialSort.h Archiving assimp/include/assimp/SceneCombiner.h Archiving assimp/include/assimp/SkeletonMeshBuilder.h Archiving assimp/include/assimp/SmallVector.h Archiving assimp/include/assimp/SmoothingGroups.h Archiving assimp/include/assimp/SmoothingGroups.inl Archiving assimp/include/assimp/SpatialSort.h Archiving assimp/include/assimp/StandardShapes.h Archiving assimp/include/assimp/StreamReader.h Archiving assimp/include/assimp/StreamWriter.h Archiving assimp/include/assimp/StringComparison.h Archiving assimp/include/assimp/StringUtils.h Archiving assimp/include/assimp/Subdivision.h Archiving assimp/include/assimp/TinyFormatter.h Archiving assimp/include/assimp/Vertex.h Archiving assimp/include/assimp/XMLTools.h Archiving assimp/include/assimp/XmlParser.h Archiving assimp/include/assimp/ZipArchiveIOSystem.h Archiving assimp/include/assimp/aabb.h Archiving assimp/include/assimp/ai_assert.h Archiving assimp/include/assimp/anim.h Archiving assimp/include/assimp/camera.h Archiving assimp/include/assimp/cexport.h Archiving assimp/include/assimp/cfileio.h Archiving assimp/include/assimp/cimport.h Archiving assimp/include/assimp/color4.h Archiving assimp/include/assimp/color4.inl Archiving assimp/include/assimp/commonMetaData.h Archiving assimp/include/assimp/defs.h Archiving assimp/include/assimp/fast_atof.h Archiving assimp/include/assimp/importerdesc.h Archiving assimp/include/assimp/light.h Archiving assimp/include/assimp/material.h Archiving assimp/include/assimp/material.inl Archiving assimp/include/assimp/matrix3x3.h Archiving assimp/include/assimp/matrix3x3.inl Archiving assimp/include/assimp/matrix4x4.h Archiving assimp/include/assimp/matrix4x4.inl Archiving assimp/include/assimp/mesh.h Archiving assimp/include/assimp/metadata.h Archiving assimp/include/assimp/pbrmaterial.h Archiving assimp/include/assimp/port/AndroidJNI/AndroidJNIIOSystem.h Archiving assimp/include/assimp/port/AndroidJNI/BundledAssetIOSystem.h Archiving assimp/include/assimp/postprocess.h Archiving assimp/include/assimp/qnan.h Archiving assimp/include/assimp/quaternion.h Archiving assimp/include/assimp/quaternion.inl Archiving assimp/include/assimp/scene.h Archiving assimp/include/assimp/texture.h Archiving assimp/include/assimp/types.h Archiving assimp/include/assimp/vector2.h Archiving assimp/include/assimp/vector2.inl Archiving assimp/include/assimp/vector3.h Archiving assimp/include/assimp/vector3.inl Archiving assimp/include/assimp/version.h Archiving bin/package/main.rs Archiving build.rs Archiving src/lib.rs Archiving wrapper.h Verifying russimp-sys v2.0.0 (/Users/mxpv/Github/russimp-sys) Compiling libc v0.2.148 ```

After the fix above, I started seeing linker problems (on MacOS)

  = note: ld: library 'assimp' not found
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

So I ran brew install assimp, but that did not help. Looks like the build script doesn’t take into account brew directories, 4537f5d adds brew to search paths.

and lastly ZLib.

zlib feature is enabled by default, but it makes sense only when building from source code, which is disabled by default. If we’re not building from source, we should expect zlib to exist (same as assimp).

I confirmed this to work on both Intel and M1 macs (with just brew install assimp as prerequisite).

```bash ❯ cargo test Compiling russimp-sys v2.0.0 (/Users/mxpv/Github/russimp-sys) Finished test [unoptimized + debuginfo] target(s) in 3.54s Running unittests src/lib.rs (target/debug/deps/russimp_sys-37468f7323fd3374) running 46 tests test bindgen_test_layout_aiAABB ... ok test bindgen_test_layout_aiBone ... ok test bindgen_test_layout_aiAnimMesh ... ok test bindgen_test_layout_aiColor3D ... ok test bindgen_test_layout_aiAnimation ... ok test bindgen_test_layout_aiCamera ... ok test bindgen_test_layout_aiColor4D ... ok test bindgen_test_layout_aiExportDataBlob ... ok test bindgen_test_layout_aiExportFormatDesc ... ok test bindgen_test_layout_aiFace ... ok test bindgen_test_layout_aiFileIO ... ok test bindgen_test_layout_aiFile ... ok test bindgen_test_layout_aiImporterDesc ... ok test bindgen_test_layout_aiLogStream ... ok test bindgen_test_layout_aiLight ... ok test bindgen_test_layout_aiMaterial ... ok test bindgen_test_layout_aiMaterialProperty ... ok test bindgen_test_layout_aiMatrix3x3 ... ok test bindgen_test_layout_aiMatrix4x4 ... ok test bindgen_test_layout_aiMemoryInfo ... ok test bindgen_test_layout_aiMesh ... ok test bindgen_test_layout_aiMeshAnim ... ok test bindgen_test_layout_aiMeshKey ... ok test bindgen_test_layout_aiMeshMorphAnim ... ok test bindgen_test_layout_aiMeshMorphKey ... ok test bindgen_test_layout_aiMetadata ... ok test bindgen_test_layout_aiMetadataEntry ... ok test bindgen_test_layout_aiNode ... ok test bindgen_test_layout_aiNodeAnim ... ok test bindgen_test_layout_aiPlane ... ok test bindgen_test_layout_aiPropertyStore ... ok test bindgen_test_layout_aiQuatKey ... ok test bindgen_test_layout_aiQuaternion ... ok test bindgen_test_layout_aiRay ... ok test bindgen_test_layout_aiScene ... ok test bindgen_test_layout_aiSkeleton ... ok test bindgen_test_layout_aiSkeletonBone ... ok test bindgen_test_layout_aiString ... ok test bindgen_test_layout_aiTexel ... ok test bindgen_test_layout_aiTexture ... ok test bindgen_test_layout_aiUVTransform ... ok test bindgen_test_layout_aiVector2D ... ok test bindgen_test_layout_aiVector3D ... ok test bindgen_test_layout_aiVectorKey ... ok test bindgen_test_layout_aiVertexWeight ... ok test tests::test_version ... ok test result: ok. 46 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Running unittests bin/package/main.rs (target/debug/deps/package-8557b93c4a9b2be6) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s ```