FUSE module for swift

I am having trouble using this C API due to use of some build defines, but I could be doing it wrong.

Current trying to compile a test it on macOS with the following modules.map:

module CFuseLinux [system] {
    header "/usr/include/fuse.h"
    link "fuse"
    export *
}

module COSXFuse [system] {
    header "/usr/local/include/fuse.h"
    link "libfuse"
    export *
}

module CFuseBrew [system] {
    header "/usr/local/include/fuse/fuse.h"
    link "libfuse"
    export *
}

Having a test case that simply tries to import the CFuseBrew one:

#if os(Linux)
import CFuseLinux
#else
import CFuseBrew
#endif

using the following command:

swift test -Xswiftc -DFUSE_USE_VERSION=25 -Xswiftc -D_FILE_OFFSET_BITS=64

But it does not seem that the defines has the effect I want since it fails with:

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/usr/local/include/fuse/fuse.h"
        ^
/usr/local/include/fuse/fuse.h:26:10: note: in file included from /usr/local/include/fuse/fuse.h:26:
#include "fuse_common.h"
         ^
/usr/local/include/fuse/fuse_common.h:32:2: error: Please add -D_FILE_OFFSET_BITS=64 to your compile flags!
#error Please add -D_FILE_OFFSET_BITS=64 to your compile flags!
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "/usr/local/include/fuse/fuse.h"
        ^
/usr/local/include/fuse/fuse.h:26:10: note: in file included from /usr/local/include/fuse/fuse.h:26:
#include "fuse_common.h"
         ^
/usr/local/include/fuse/fuse_common.h:271:8: error: On Darwin API version 25 or greater must be used
# error On Darwin API version 25 or greater must be used
             ^
/Users/dennis/Projects/cfuse/Tests/CFuseTests/first.swift:5:8: error: could not build Objective-C module 'CFuseBrew'
import CFuseBrew

What am I doing wrong? Is it possible to define build options in modules.map? The project can be found at GitHub - schafdog/cfuse: C FUSE bindings for Swift

cheers,
:-Dennis

To pass in the option to Clang, use -Xcc instead of -Xswiftc, like:

swift test -Xswiftc -DFUSE_USE_VERSION=25 -Xcc -D_FILE_OFFSET_BITS=64

As far as in the module map file, I don’t know if that’s supported[1]. You might be able to make your own header that defines it before including fuse.h, and use that for your module.

[1] Modules — Clang 18.0.0git documentation

···

On Jan 5, 2017, at 3:30 PM, Dennis Schafroth via swift-users <swift-users@swift.org> wrote:

I am having trouble using this C API due to use of some build defines, but I could be doing it wrong.

Current trying to compile a test it on macOS with the following modules.map:

module CFuseLinux [system] {
    header "/usr/include/fuse.h"
    link "fuse"
    export *
}

module COSXFuse [system] {
    header "/usr/local/include/fuse.h"
    link "libfuse"
    export *
}

module CFuseBrew [system] {
    header "/usr/local/include/fuse/fuse.h"
    link "libfuse"
    export *
}

Having a test case that simply tries to import the CFuseBrew one:

if os(Linux)
import CFuseLinux
#else
import CFuseBrew
#endif

using the following command:

swift test -Xswiftc -DFUSE_USE_VERSION=25 -Xswiftc -D_FILE_OFFSET_BITS=64

But it does not seem that the defines has the effect I want since it fails with:

<module-includes>:1:9: note: in file included from <module-includes>:1:
import "/usr/local/include/fuse/fuse.h"
        ^
/usr/local/include/fuse/fuse.h:26:10: note: in file included from /usr/local/include/fuse/fuse.h:26:
#include "fuse_common.h"
         ^
/usr/local/include/fuse/fuse_common.h:32:2: error: Please add -D_FILE_OFFSET_BITS=64 to your compile flags!
error Please add -D_FILE_OFFSET_BITS=64 to your compile flags!
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
import "/usr/local/include/fuse/fuse.h"
        ^
/usr/local/include/fuse/fuse.h:26:10: note: in file included from /usr/local/include/fuse/fuse.h:26:
#include "fuse_common.h"
         ^
/usr/local/include/fuse/fuse_common.h:271:8: error: On Darwin API version 25 or greater must be used
# error On Darwin API version 25 or greater must be used
             ^
/Users/dennis/Projects/cfuse/Tests/CFuseTests/first.swift:5:8: error: could not build Objective-C module 'CFuseBrew'
import CFuseBrew

What am I doing wrong? Is it possible to define build options in modules.map? The project can be found at GitHub - schafdog/cfuse: C FUSE bindings for Swift

cheers,
:-Dennis
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users