Skip to content

Commit

Permalink
Update project (#23)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ctreffs authored Aug 25, 2023
1 parent 6d0fb10 commit 63ea8f1
Show file tree
Hide file tree
Showing 24 changed files with 45 additions and 85 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,32 @@ jobs:
image: swift:${{ matrix.swift }}
steps:
- name: Checkout
uses: actions/checkout@master
uses: actions/[email protected]

- 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
10 changes: 5 additions & 5 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ 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--*
~/Library/Caches/Homebrew/downloads/*--assimp-*
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
Expand Down
4 changes: 2 additions & 2 deletions Mintfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
realm/[email protected].2
nicklockwood/SwiftFormat@0.51.9
realm/[email protected].4
nicklockwood/SwiftFormat@0.52.2
25 changes: 4 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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(
Expand All @@ -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 <https://github.com/assimp/assimp/issues/3174> and here <https://github.com/assimp/assimp/issues/2804>.
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

Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiCamera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiFace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiLight.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiMatKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiMaterial.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/Assimp/AiMaterialProperty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -125,7 +125,7 @@ public struct AiMaterialProperty: AiMaterialPropertyIdentifiable {
return String(bytes: bytes, length: dataLength - 1 - MemoryLayout<Int32>.stride)
}

internal func getString(pMat: UnsafePointer<aiMaterial>) -> String? {
func getString(pMat: UnsafePointer<aiMaterial>) -> String? {
var pOut = aiString()

let result = aiGetMaterialString(pMat,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiMesh.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiPostProcessStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiShadingMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/AiTexture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions Sources/Assimp/AiTextureType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -110,9 +110,3 @@ public struct AiTextureType: RawRepresentable {
}

extension AiTextureType: Equatable {}

extension AiTextureType: CustomDebugStringConvertible {
public var debugDescription: String {
String(cString: TextureTypeToString(aiTextureType(rawValue: rawValue)))
}
}
2 changes: 1 addition & 1 deletion Sources/Assimp/Assimp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/CArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/String+aiString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Assimp/simd+aiVector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Tests/AssimpTests/AssimpTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down
11 changes: 0 additions & 11 deletions assimp5.0.0.mac.pc

This file was deleted.

11 changes: 0 additions & 11 deletions assimp5.0.1.mac.pc

This file was deleted.

0 comments on commit 63ea8f1

Please sign in to comment.