Skip to content

Support use #include <tommath.h> for SwiftPM dependencies #518

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

Closed
wants to merge 4 commits into from
Closed
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
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import PackageDescription

let package = Package(
name: "tommath",
name: "TomMath",
platforms: [
.macOS(.v10_10), .iOS(.v9), .tvOS(.v9)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "libtommath",
targets: ["libtommath"])
targets: [ "libtommath" ])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
Expand All @@ -30,10 +30,10 @@ let package = Package(
cSettings: [
.unsafeFlags(["-flto=thin"]) // for Dead Code Elimination
]),
.testTarget(name: "TommathTests",
dependencies: ["libtommath"],
.testTarget(name: "TomMathTests",
dependencies: [ "libtommath" ],
path: "demo",
sources: ["tommath_tests.swift"])
sources: [ "tommath_tests.swift" ])
],
cLanguageStandard: .gnu11,
cxxLanguageStandard: .gnucxx14
Expand Down
2 changes: 1 addition & 1 deletion demo/tommath_tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func mp_get_u32(_ a: UnsafePointer<mp_int>) -> UInt32 {
return UInt32(bitPattern: mp_get_i32(a))
}

class LibTommathTests: XCTestCase {
class TomMathTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
Expand Down
2 changes: 1 addition & 1 deletion modulemap/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module libtommath [extern_c] {
header "../tommath.h"
header "tommath.h"
export *
}
9 changes: 9 additions & 0 deletions modulemap/tommath.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* It's necessary for targets which come from package dependencies (C libraries).
* an additional header search path argument `-I /path/to/this/directory`
* will automatically added to the include directory.
*
* This allows projects to use #include <tommath.h> syntax which are not within the package.
*/

#include "../tommath.h"