libtommath
libtommath copied to clipboard
Support use `#include <tommath.h>` for SwiftPM dependencies
for https://github.com/libtom/libtomcrypt/pull/575
How about setting the include path correctly instead? Or is that not possible in this swift package manager thing?
@royjit maybe you can give some hints here how this is done properly!? Adding another header simply doesn't look right to me ...
How about setting the include path correctly instead? Or is that not possible in this swift package manager thing?
A depend on package B use dependencies: [.package(url:...)] in Package.swift of A
A import B use #include <B.h> in source
SwiftPM find B.h in publicHeadersPath on Package.swift of B
now, SwiftPM can't find tommath.h on path publicHeadersPath: "modulemap" defined in Package.swift of libtommath
After reading SE-0038 I'm still not entirely sure if that's the correct way to do things.
@ddunbar sorry highlighting you here, but you are the author of said specification and maybe you can shed some light on this? ... please also read through the comments in libtom/libtomcrypt#575 for further context ...
Reply to https://github.com/libtom/libtomcrypt/pull/575#discussion_r762003741
Why is this building mtest if it's on the exclude list?
https://github.com/libtom/libtommath/blob/2cec6addaf4acbd8250611ec4cecadf1f4d655ee/Package.swift#L27
Why is this building
mtestif it's on the exclude list?
It seems .unsafeFlags(["-flto=thin", "-fmodule-map-file=modulemap/module.modulemap"]) is ignored.
a new module.modulemap created:
module libtommath {
umbrella "/a/b/c/libtommath"
export *
}
umbrella "/a/b/c/libtommath" expose all symbols in *.h
@sjaeckel
How about build libtomcrypt as objective-c source and add @import TomMath; in math/ltm_desc.c ?
I tried, it works and just math/ltm_desc.c modified.
Package.swift of libtomcrypt
.unsafeFlags(["-xobjective-c"]),
math/ltm_desc.c
#ifdef SWIFT_PACKAGE
@import TomMath;
#else
#include <tommath.h>
#endif
Using Modules To enable modules, pass the command-line flag -fmodules. This will make any modules-enabled software libraries available as modules as well as introducing any modules-specific syntax.
I can't figure it out yet
creating-c-language-targets To allow a Swift target to import a C language target, add a target dependency in the manifest file. Swift Package Manager will automatically generate a modulemap for each C language library target for these 3 cases:
If
include/Foo/Foo.hexists andFoois the only directory under the include directory, and the include directory contains no header files, theninclude/Foo/Foo.hbecomes the umbrella header.If
include/Foo.hexists andincludecontains no other subdirectory, then include/Foo.h becomes the umbrella header.Otherwise, the
includedirectory becomes an umbrella directory, which means that all headers under it will be included in the module.In case of complicated
includelayouts or headers that are not compatible with modules, a custommodule.modulemapcan be provided in theincludedirectory.
Keep trying
Swift 5.2 Issue with headers in same dir as .c/m files
https://forums.swift.org/t/swift-5-2-issue-with-headers-in-same-dir-as-c-m-files/33292
[PackageLoading] Handle header files in TargetSourcesBuilder https://github.com/apple/swift-package-manager/pull/2555
keeping a close watch on it.
Why is this building
mtestif it's on the exclude list?
I found it, it'is a bug: https://bugs.swift.org/browse/SR-14456
https://forums.swift.org/t/unable-to-exclude-specific-headers-from-a-target/51017
I'm closing this as there was no action for too long. Please re-open if you have further questions/comments/improvements and still want this to be merged.