Building a Swift package containing a module.modulemap and C files

Hello,

At this point in time, the Swift PM doesn’t handle C code. And though
Swift PM’s goal is not probably to compile C code, we are wondering about
the following scenario: A swift package that consists of the expected
Package.swift file, a module.modulemap file, and C files. In a situation
like this, the Swift package cannot be compiled by the Swift PM.

A possible solution for this could be to have an indication that the C
code present in the package should be compiled with the C compiler and a
way to specify what flags should be passed to the C compiler. For example,
the Package.swift file could include a directive to kick off a Ninja or
Makefile that is then responsible for compiling and linking the C code.

Is this something that would or could be considered to be within scope of
the Swift PM?

Regards,
   Ricardo Olivieri
   Software Engineer

Hello,

At this point in time, the Swift PM doesn’t handle C code. And though Swift PM’s goal is not probably to compile C code, we are wondering about the following scenario: A swift package that consists of the expected Package.swift file, a module.modulemap file, and C files. In a situation like this, the Swift package cannot be compiled by the Swift PM.

A possible solution for this could be to have an indication that the C code present in the package should be compiled with the C compiler and a way to specify what flags should be passed to the C compiler. For example, the Package.swift file could include a directive to kick off a Ninja or Makefile that is then responsible for compiling and linking the C code.

Is this something that would or could be considered to be within scope of the Swift PM?

Yes, certainly.

I have a proposal for initial support for this here:
  https://github.com/ddunbar/swift-evolution/blob/8c8272b423bdc26fe49f3d1a36ab13a3a976f519/proposals/NNNN-swiftpm-c-language-targets.md
and it is on the short list of things I want to work on, but I've unfortunately been hit with a bunch of other distractions and sickness so it hasn't gotten much attention yet.

- Daniel

···

On Jan 20, 2016, at 9:03 AM, Ricardo N Olivieri via swift-build-dev <swift-build-dev@swift.org> wrote:

Regards,
  Ricardo Olivieri
  Software Engineer
_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev