From 63ea8f16d716e9f70175dad6ef10ee5c9d3a8f05 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Fri, 25 Aug 2023 07:23:18 +0200 Subject: [PATCH] Update project (#23) * Fix issue #11 - Cannot find TextureTypeToString in scope AiTextureType.swift * Remove custom pkg-config files for mac - libassimp.5.2.4 has working support * Fix tests * Update mint dependencies * Update CI * Update headers * Add Swift Package Index shields * Update macOS runner platform * Update Linux CI to account for missing make * Remove texture to string * Make tests Linux compatible again * Update README * Fix linux CI cache --- .github/workflows/ci-linux.yml | 23 ++++++++++++++--------- .github/workflows/ci-macos.yml | 10 +++++----- Mintfile | 4 ++-- README.md | 25 ++++--------------------- Sources/Assimp/AiCamera.swift | 2 +- Sources/Assimp/AiFace.swift | 2 +- Sources/Assimp/AiLight.swift | 2 +- Sources/Assimp/AiMatKey.swift | 2 +- Sources/Assimp/AiMaterial.swift | 2 +- Sources/Assimp/AiMaterialProperty.swift | 4 ++-- Sources/Assimp/AiMesh.swift | 2 +- Sources/Assimp/AiNode.swift | 2 +- Sources/Assimp/AiPostProcessStep.swift | 2 +- Sources/Assimp/AiScene.swift | 2 +- Sources/Assimp/AiShadingMode.swift | 2 +- Sources/Assimp/AiTexture.swift | 2 +- Sources/Assimp/AiTextureType.swift | 8 +------- Sources/Assimp/Assimp.swift | 2 +- Sources/Assimp/CArray.swift | 2 +- Sources/Assimp/String+aiString.swift | 2 +- Sources/Assimp/simd+aiVector.swift | 2 +- Tests/AssimpTests/AssimpTests.swift | 4 ++-- assimp5.0.0.mac.pc | 11 ----------- assimp5.0.1.mac.pc | 11 ----------- 24 files changed, 45 insertions(+), 85 deletions(-) delete mode 100644 assimp5.0.0.mac.pc delete mode 100644 assimp5.0.1.mac.pc diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 0c72696..4c4a7b4 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -16,27 +16,32 @@ jobs: image: swift:${{ matrix.swift }} steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v3.6.0 + - name: Restore APT cache - uses: actions/cache@v3 + uses: actions/cache@v3.3.1 with: path: /var/cache/apt key: ${{ runner.os }}-apt + - name: Restore cached SPM dependencies - uses: actions/cache@v3 + uses: actions/cache@v3.3.1 with: - path: | - .build/repositories - key: ${{ runner.os }}-spm-repos-${{ hashFiles('**/Package.resolved') }} + path: .build + key: swiftpm-${{ runner.os }}-${{ inputs.swift-version }}-${{ hashFiles('Package.swift') }} restore-keys: | - ${{ runner.os }}-spm-repos- + swiftpm-${{ runner.os }}-${{ inputs.swift-version }}- + swiftpm-${{ runner.os }}- + - name: Install dependencies run: | # update dependency source list to more modern linux distribution # echo -e "deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse" >> /etc/apt/sources.list apt update apt-get install -y -qq pkg-config libassimp-dev + - name: Test - run: make test + run: swift test + - name: Build Release - run: make build-release + run: swift build -c release diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 7f1c715..20dafda 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -8,17 +8,17 @@ on: jobs: macos-test-build-release-xcode: - runs-on: macOS-latest + runs-on: macos-13 strategy: matrix: - xcode: ["13.2.1"] + xcode: ["14.3.1", "15.0"] steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v3.6.0 - name: Select Xcode ${{ matrix.xcode }} run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app - name: Restore cached Homebrew dependencies - uses: actions/cache@v3 + uses: actions/cache@v3.3.1 with: path: | ~/Library/Caches/Homebrew/assimp--* @@ -26,7 +26,7 @@ jobs: key: ${{ runner.os }}-brew-assimp-${{ hashFiles('.github/brew-formulae') }} restore-keys: ${{ runner.os }}-brew-assimp- - name: Restore cached SPM dependencies - uses: actions/cache@v3 + uses: actions/cache@v3.3.1 with: path: | .build/repositories diff --git a/Mintfile b/Mintfile index c6b7ccc..fac03b5 100644 --- a/Mintfile +++ b/Mintfile @@ -1,2 +1,2 @@ -realm/SwiftLint@0.52.2 -nicklockwood/SwiftFormat@0.51.9 \ No newline at end of file +realm/SwiftLint@0.52.4 +nicklockwood/SwiftFormat@0.52.2 \ No newline at end of file diff --git a/README.md b/README.md index 808657d..1816c3e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Swift Assimp +[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fctreffs%2FSwiftAssimp%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/ctreffs/SwiftAssimp) +[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fctreffs%2FSwiftAssimp%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/ctreffs/SwiftAssimp) [![macOS](https://github.com/ctreffs/SwiftAssimp/actions/workflows/ci-macos.yml/badge.svg)](https://github.com/ctreffs/SwiftAssimp/actions/workflows/ci-macos.yml) [![Linux](https://github.com/ctreffs/SwiftAssimp/actions/workflows/ci-linux.yml/badge.svg)](https://github.com/ctreffs/SwiftAssimp/actions/workflows/ci-linux.yml) [![license](https://img.shields.io/badge/license-BSD3-brightgreen.svg)](LICENSE) -[![swift version](https://img.shields.io/badge/swift-5.3+-brightgreen.svg)](https://swift.org/download) -[![platforms](https://img.shields.io/badge/platforms-%20macOS%20-brightgreen.svg)](#) -[![platforms](https://img.shields.io/badge/platforms-linux-brightgreen.svg)](#) + This is a **thin** Swift wrapper around the popular and excellent [**Open Asset Import Library**](https://github.com/assimp/assimp) library. It provides a **swifty** and **typesafe** API. @@ -40,7 +40,7 @@ import PackageDescription let package = Package( name: "YourPackageName", dependencies: [ - .package(name: "Assimp", url: "https://github.com/ctreffs/SwiftAssimp.git", from: "1.3.1") + .package(name: "Assimp", url: "https://github.com/ctreffs/SwiftAssimp.git", from: "2.1.0") ], targets: [ .target( @@ -65,23 +65,6 @@ apt-get install libassimp-dev depending on you platform. -### ⚠️ Caution macOS homebrew users - -Swift package manager relies on the [pkg-config](http://pkg-config.freedesktop.org) tool to find system installed libraries. -Assimp version 5 contains a regression, which provides a broken pkg-config file (assimp.pc). -Therefore SPM is not able to find the include headers out of the box resulting in the error: -`shims.h:1:10: error: 'assimp/cimport.h' file not found`. -This is a known bug and is tracked here and here . -However there is a fix that requires one manual step. - -Depending on your assimp version run the following command in your Terminal: - -- print the currently installed assimp version: `printBrewAssimpVersion` - - for version 5.0.0: `make copyMacPkgConfig500` - - for version 5.0.1: `make copyMacPkgConfig501` - -This will copy a corrected pkg-config file to the appropriate library location. You will need to repeat this step when updating assimp via homebrew until a fix is provided by the assimp developers. -Be sure to close Xcode before retrying to build. ## 📝 Code Example diff --git a/Sources/Assimp/AiCamera.swift b/Sources/Assimp/AiCamera.swift index 8f7b441..15e809d 100644 --- a/Sources/Assimp/AiCamera.swift +++ b/Sources/Assimp/AiCamera.swift @@ -2,7 +2,7 @@ // AiCamera.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/AiFace.swift b/Sources/Assimp/AiFace.swift index ae585cb..95a08f2 100644 --- a/Sources/Assimp/AiFace.swift +++ b/Sources/Assimp/AiFace.swift @@ -2,7 +2,7 @@ // AiFace.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/AiLight.swift b/Sources/Assimp/AiLight.swift index af1986c..892b76c 100644 --- a/Sources/Assimp/AiLight.swift +++ b/Sources/Assimp/AiLight.swift @@ -2,7 +2,7 @@ // AiLight.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/AiMatKey.swift b/Sources/Assimp/AiMatKey.swift index 0a6f927..3aa38f8 100644 --- a/Sources/Assimp/AiMatKey.swift +++ b/Sources/Assimp/AiMatKey.swift @@ -2,7 +2,7 @@ // AiMatKey.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. public struct AiMatKey: RawRepresentable { diff --git a/Sources/Assimp/AiMaterial.swift b/Sources/Assimp/AiMaterial.swift index 9c6c987..5cf3f1f 100644 --- a/Sources/Assimp/AiMaterial.swift +++ b/Sources/Assimp/AiMaterial.swift @@ -2,7 +2,7 @@ // AiMaterial.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/AiMaterialProperty.swift b/Sources/Assimp/AiMaterialProperty.swift index 79f6f5e..f9b35f7 100644 --- a/Sources/Assimp/AiMaterialProperty.swift +++ b/Sources/Assimp/AiMaterialProperty.swift @@ -2,7 +2,7 @@ // AiMaterialProperty.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp @@ -125,7 +125,7 @@ public struct AiMaterialProperty: AiMaterialPropertyIdentifiable { return String(bytes: bytes, length: dataLength - 1 - MemoryLayout.stride) } - internal func getString(pMat: UnsafePointer) -> String? { + func getString(pMat: UnsafePointer) -> String? { var pOut = aiString() let result = aiGetMaterialString(pMat, diff --git a/Sources/Assimp/AiMesh.swift b/Sources/Assimp/AiMesh.swift index ee441c1..88d1c27 100644 --- a/Sources/Assimp/AiMesh.swift +++ b/Sources/Assimp/AiMesh.swift @@ -2,7 +2,7 @@ // AiMesh.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/AiNode.swift b/Sources/Assimp/AiNode.swift index a842ff8..1b379fc 100644 --- a/Sources/Assimp/AiNode.swift +++ b/Sources/Assimp/AiNode.swift @@ -2,7 +2,7 @@ // AiNode.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/AiPostProcessStep.swift b/Sources/Assimp/AiPostProcessStep.swift index a94fc0c..8ac9f88 100644 --- a/Sources/Assimp/AiPostProcessStep.swift +++ b/Sources/Assimp/AiPostProcessStep.swift @@ -2,7 +2,7 @@ // AiPostProcessStep.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/AiScene.swift b/Sources/Assimp/AiScene.swift index ceaa4a2..b65542f 100644 --- a/Sources/Assimp/AiScene.swift +++ b/Sources/Assimp/AiScene.swift @@ -2,7 +2,7 @@ // AiScene.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/AiShadingMode.swift b/Sources/Assimp/AiShadingMode.swift index 317f7f2..26d2dc8 100644 --- a/Sources/Assimp/AiShadingMode.swift +++ b/Sources/Assimp/AiShadingMode.swift @@ -2,7 +2,7 @@ // AiShadingMode.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/AiTexture.swift b/Sources/Assimp/AiTexture.swift index e7d892b..fe47f7d 100644 --- a/Sources/Assimp/AiTexture.swift +++ b/Sources/Assimp/AiTexture.swift @@ -2,7 +2,7 @@ // AiTexture.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/AiTextureType.swift b/Sources/Assimp/AiTextureType.swift index 3a5abe3..aad94fd 100644 --- a/Sources/Assimp/AiTextureType.swift +++ b/Sources/Assimp/AiTextureType.swift @@ -2,7 +2,7 @@ // AiTextureType.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp @@ -110,9 +110,3 @@ public struct AiTextureType: RawRepresentable { } extension AiTextureType: Equatable {} - -extension AiTextureType: CustomDebugStringConvertible { - public var debugDescription: String { - String(cString: TextureTypeToString(aiTextureType(rawValue: rawValue))) - } -} diff --git a/Sources/Assimp/Assimp.swift b/Sources/Assimp/Assimp.swift index 00f7b39..143df49 100644 --- a/Sources/Assimp/Assimp.swift +++ b/Sources/Assimp/Assimp.swift @@ -2,7 +2,7 @@ // Assimp.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/CArray.swift b/Sources/Assimp/CArray.swift index da13b96..3579283 100644 --- a/Sources/Assimp/CArray.swift +++ b/Sources/Assimp/CArray.swift @@ -2,7 +2,7 @@ // CArray.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. enum CArray { diff --git a/Sources/Assimp/String+aiString.swift b/Sources/Assimp/String+aiString.swift index 711da38..215779c 100644 --- a/Sources/Assimp/String+aiString.swift +++ b/Sources/Assimp/String+aiString.swift @@ -2,7 +2,7 @@ // String+aiString.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Sources/Assimp/simd+aiVector.swift b/Sources/Assimp/simd+aiVector.swift index 2e57d15..c4c24dd 100644 --- a/Sources/Assimp/simd+aiVector.swift +++ b/Sources/Assimp/simd+aiVector.swift @@ -2,7 +2,7 @@ // simd+aiVector.swift // SwiftAssimp // -// Copyright © 2019-2022 Christian Treffs. All rights reserved. +// Copyright © 2019-2023 Christian Treffs. All rights reserved. // Licensed under BSD 3-Clause License. See LICENSE file for details. @_implementationOnly import CAssimp diff --git a/Tests/AssimpTests/AssimpTests.swift b/Tests/AssimpTests/AssimpTests.swift index 1893af0..1e9778c 100644 --- a/Tests/AssimpTests/AssimpTests.swift +++ b/Tests/AssimpTests/AssimpTests.swift @@ -155,7 +155,7 @@ final class AssimpTests: XCTestCase { // Materials - XCTAssertEqual(scene.materials[0].numProperties, 16) + XCTAssertGreaterThanOrEqual(scene.materials[0].numProperties, 12) XCTAssertEqual(scene.materials[0].numAllocated, 20) XCTAssertEqual(scene.materials[0].properties[0].key, "?mat.name") @@ -295,7 +295,7 @@ final class AssimpTests: XCTestCase { // Materials - XCTAssertEqual(scene.materials[0].numProperties, 50) + XCTAssertGreaterThanOrEqual(scene.materials[0].numProperties, 50) XCTAssertEqual(scene.materials[0].numAllocated, 80) XCTAssertEqual(scene.materials[0].properties[0].key, "?mat.name") diff --git a/assimp5.0.0.mac.pc b/assimp5.0.0.mac.pc deleted file mode 100644 index 8357fe0..0000000 --- a/assimp5.0.0.mac.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr/local/Cellar/assimp/5.0.0 -exec_prefix=/usr/local/Cellar/assimp/5.0.0/ -libdir=/usr/local/Cellar/assimp/5.0.0/lib -includedir=/usr/local/Cellar/assimp/5.0.0/include - -Name: Assimp -Description: Import various well-known 3D model formats in an uniform manner. -Version: 5.0.0 -Libs: -L${libdir} -lassimp -Libs.private: -lz -Cflags: -I${includedir} diff --git a/assimp5.0.1.mac.pc b/assimp5.0.1.mac.pc deleted file mode 100644 index c9410cd..0000000 --- a/assimp5.0.1.mac.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=/usr/local/Cellar/assimp/5.0.1 -exec_prefix=/usr/local/Cellar/assimp/5.0.1/ -libdir=/usr/local/Cellar/assimp/5.0.1/lib -includedir=/usr/local/Cellar/assimp/5.0.1/include - -Name: Assimp -Description: Import various well-known 3D model formats in an uniform manner. -Version: 5.0.1 -Libs: -L${libdir} -lassimp -Libs.private: -lz -Cflags: -I${includedir}