From 9c1820ed5858297e3b02d1467bd400fb19e47b89 Mon Sep 17 00:00:00 2001 From: Sergey Khliustin Date: Mon, 18 Jul 2022 00:46:48 +0200 Subject: [PATCH] Fixed building pods containing *.c sources --- Examples/PodSpecs/nanopb.podspec.json | 62 +++++++++++++++++++++++++++ Sources/PodToBUILD/ObjcLibrary.swift | 6 +-- 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 Examples/PodSpecs/nanopb.podspec.json diff --git a/Examples/PodSpecs/nanopb.podspec.json b/Examples/PodSpecs/nanopb.podspec.json new file mode 100644 index 0000000..57478e9 --- /dev/null +++ b/Examples/PodSpecs/nanopb.podspec.json @@ -0,0 +1,62 @@ +{ + "name": "nanopb", + "version": "1.30906.0", + "summary": "Protocol buffers with small code size.", + "description": "Nanopb is a small code-size Protocol Buffers implementation\nin ansi C. It is especially suitable for use in\nmicrocontrollers, but fits any memory restricted system.", + "homepage": "https://github.com/nanopb/nanopb", + "license": { + "type": "zlib", + "file": "LICENSE.txt" + }, + "authors": { + "Petteri Aimonen": "jpa@nanopb.mail.kapsi.fi" + }, + "source": { + "git": "https://github.com/nanopb/nanopb.git", + "tag": "0.3.9.6" + }, + "requires_arc": false, + "xcconfig": { + "GCC_PREPROCESSOR_DEFINITIONS": "$(inherited) PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 PB_ENABLE_MALLOC=1" + }, + "source_files": "*.{h,c}", + "public_header_files": "*.h", + "platforms": { + "osx": null, + "ios": null, + "tvos": null, + "watchos": null + }, + "subspecs": [ + { + "name": "encode", + "public_header_files": [ + "pb.h", + "pb_encode.h", + "pb_common.h" + ], + "source_files": [ + "pb.h", + "pb_common.h", + "pb_common.c", + "pb_encode.h", + "pb_encode.c" + ] + }, + { + "name": "decode", + "public_header_files": [ + "pb.h", + "pb_decode.h", + "pb_common.h" + ], + "source_files": [ + "pb.h", + "pb_common.h", + "pb_common.c", + "pb_decode.h", + "pb_decode.c" + ] + } + ] +} diff --git a/Sources/PodToBUILD/ObjcLibrary.swift b/Sources/PodToBUILD/ObjcLibrary.swift index 915b7d9..7614a37 100644 --- a/Sources/PodToBUILD/ObjcLibrary.swift +++ b/Sources/PodToBUILD/ObjcLibrary.swift @@ -565,15 +565,15 @@ public struct ObjcLibrary: BazelTarget, UserConfigurable, SourceExcludable { // Logically, this segment of the code is identical to the ruby // code. It would look like: // return boolValue ? arcSources : GlobNode.empty - // however, bazel native rules don't allow cpp inside of the - // `non_arc_sourcs`. The following code opts in cpp sources only. + // however, bazel native rules don't allow cpp and c inside of the + // `non_arc_sourcs`. The following code opts in cpp and c sources only. // the fobjc-arc _feature_ does not apply to the cpp language // inside of clang return boolValue ? arcSources : GlobNode(include: arcSources.include.map { $0.compactMapInclude { incPart -> String? in let suffix = String(incPart.split(separator: ".").last!) - if suffix == "cpp" || suffix == "cxx" || suffix == "cc" { + if suffix == "cpp" || suffix == "cxx" || suffix == "cc" || suffix == "c" { return incPart } return nil