diff options
-rw-r--r-- | llvm/test/tools/llvm-ifs/ios-tbd.ifs | 22 | ||||
-rw-r--r-- | llvm/test/tools/llvm-ifs/macos-tbd.ifs | 22 | ||||
-rw-r--r-- | llvm/test/tools/llvm-ifs/tvos-tbd.ifs | 22 | ||||
-rw-r--r-- | llvm/test/tools/llvm-ifs/watchos-tbd.ifs | 22 | ||||
-rw-r--r-- | llvm/tools/llvm-ifs/llvm-ifs.cpp | 38 |
5 files changed, 119 insertions, 7 deletions
diff --git a/llvm/test/tools/llvm-ifs/ios-tbd.ifs b/llvm/test/tools/llvm-ifs/ios-tbd.ifs new file mode 100644 index 00000000000..13671b02c5c --- /dev/null +++ b/llvm/test/tools/llvm-ifs/ios-tbd.ifs @@ -0,0 +1,22 @@ +# RUN: llvm-ifs --action write-bin -o - %s | FileCheck %s + +# CHECK: --- !tapi-tbd-v3 +# CHECK-NEXT: archs: [ arm64 ] +# CHECK-NEXT: platform: ios +# CHECK-NEXT: flags: [ flat_namespace, not_app_extension_safe ] +# CHECK-NEXT: install-name: '' +# CHECK-NEXT: current-version: 0 +# CHECK-NEXT: compatibility-version: 0 +# CHECK-NEXT: objc-constraint: none +# CHECK-NEXT: exports: +# CHECK-NEXT: - archs: [ arm64 ] +# CHECK-NEXT: symbols: [ __Z3fooi ] +# CHECK-NEXT: ... + +--- !experimental-ifs-v1 +IfsVersion: 1.0 +Triple: arm64-apple-ios +ObjectFileFormat: TBD +Symbols: + __Z3fooi: { Type: Func } +... diff --git a/llvm/test/tools/llvm-ifs/macos-tbd.ifs b/llvm/test/tools/llvm-ifs/macos-tbd.ifs new file mode 100644 index 00000000000..bd84806fb21 --- /dev/null +++ b/llvm/test/tools/llvm-ifs/macos-tbd.ifs @@ -0,0 +1,22 @@ +# RUN: llvm-ifs --action write-bin -o - %s | FileCheck %s + +# CHECK: --- !tapi-tbd-v3 +# CHECK-NEXT: archs: [ arm64 ] +# CHECK-NEXT: platform: macosx +# CHECK-NEXT: flags: [ flat_namespace, not_app_extension_safe ] +# CHECK-NEXT: install-name: '' +# CHECK-NEXT: current-version: 0 +# CHECK-NEXT: compatibility-version: 0 +# CHECK-NEXT: objc-constraint: none +# CHECK-NEXT: exports: +# CHECK-NEXT: - archs: [ arm64 ] +# CHECK-NEXT: symbols: [ __Z3fooi ] +# CHECK-NEXT: ... + +--- !experimental-ifs-v1 +IfsVersion: 1.0 +Triple: arm64-apple-macosx +ObjectFileFormat: TBD +Symbols: + __Z3fooi: { Type: Func } +... diff --git a/llvm/test/tools/llvm-ifs/tvos-tbd.ifs b/llvm/test/tools/llvm-ifs/tvos-tbd.ifs new file mode 100644 index 00000000000..08c8478c1da --- /dev/null +++ b/llvm/test/tools/llvm-ifs/tvos-tbd.ifs @@ -0,0 +1,22 @@ +# RUN: llvm-ifs --action write-bin -o - %s | FileCheck %s + +# CHECK: --- !tapi-tbd-v3 +# CHECK-NEXT: archs: [ arm64 ] +# CHECK-NEXT: platform: tvos +# CHECK-NEXT: flags: [ flat_namespace, not_app_extension_safe ] +# CHECK-NEXT: install-name: '' +# CHECK-NEXT: current-version: 0 +# CHECK-NEXT: compatibility-version: 0 +# CHECK-NEXT: objc-constraint: none +# CHECK-NEXT: exports: +# CHECK-NEXT: - archs: [ arm64 ] +# CHECK-NEXT: symbols: [ __Z3fooi ] +# CHECK-NEXT: ... + +--- !experimental-ifs-v1 +IfsVersion: 1.0 +Triple: arm64-apple-tvos +ObjectFileFormat: TBD +Symbols: + __Z3fooi: { Type: Func } +... diff --git a/llvm/test/tools/llvm-ifs/watchos-tbd.ifs b/llvm/test/tools/llvm-ifs/watchos-tbd.ifs new file mode 100644 index 00000000000..74a9d962a3e --- /dev/null +++ b/llvm/test/tools/llvm-ifs/watchos-tbd.ifs @@ -0,0 +1,22 @@ +# RUN: llvm-ifs --action write-bin -o - %s | FileCheck %s + +# CHECK: --- !tapi-tbd-v3 +# CHECK-NEXT: archs: [ arm64 ] +# CHECK-NEXT: platform: watchos +# CHECK-NEXT: flags: [ flat_namespace, not_app_extension_safe ] +# CHECK-NEXT: install-name: '' +# CHECK-NEXT: current-version: 0 +# CHECK-NEXT: compatibility-version: 0 +# CHECK-NEXT: objc-constraint: none +# CHECK-NEXT: exports: +# CHECK-NEXT: - archs: [ arm64 ] +# CHECK-NEXT: symbols: [ __Z3fooi ] +# CHECK-NEXT: ... + +--- !experimental-ifs-v1 +IfsVersion: 1.0 +Triple: arm64-apple-watchos +ObjectFileFormat: TBD +Symbols: + __Z3fooi: { Type: Func } +... diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp index 3377985ae4a..17463578275 100644 --- a/llvm/tools/llvm-ifs/llvm-ifs.cpp +++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp @@ -154,8 +154,8 @@ template <> struct CustomMappingTraits<std::set<IFSSymbol>> { IO.mapRequired(Sym.Name.c_str(), const_cast<IFSSymbol &>(Sym)); } }; -} // End yaml namespace -} // End llvm namespace +} // namespace yaml +} // namespace llvm // A cumulative representation of ELF stubs. // Both textual and binary stubs will read into and write from this object. @@ -196,8 +196,8 @@ template <> struct MappingTraits<IFSStub> { IO.mapRequired("Symbols", Stub.Symbols); } }; -} // End yaml namespace -} // End llvm namespace +} // namespace yaml +} // namespace llvm static Expected<std::unique_ptr<IFSStub>> readInputFile(StringRef FilePath) { // Read in file. @@ -224,7 +224,7 @@ int writeTbdStub(const llvm::Triple &T, const std::set<IFSSymbol> &Symbols, [](const llvm::Triple &T) -> llvm::Expected<llvm::MachO::Architecture> { switch (T.getArch()) { default: - return createStringError(errc::not_supported, "Invalid Architecture."); + return createStringError(errc::not_supported, "Invalid Architecture.\n"); case llvm::Triple::ArchType::x86: return AK_i386; case llvm::Triple::ArchType::x86_64: @@ -236,15 +236,39 @@ int writeTbdStub(const llvm::Triple &T, const std::set<IFSSymbol> &Symbols, } }(T); + auto PlatformKindOrError = + [](const llvm::Triple &T) -> llvm::Expected<llvm::MachO::PlatformKind> { + if (T.isMacOSX()) + return llvm::MachO::PlatformKind::macOS; + if (T.isTvOS()) + return llvm::MachO::PlatformKind::tvOS; + if (T.isWatchOS()) + return llvm::MachO::PlatformKind::watchOS; + // Note: put isiOS last because tvOS and watchOS are also iOS according + // to the Triple. + if (T.isiOS()) + return llvm::MachO::PlatformKind::iOS; + + // TODO: Add an option for ForceTriple, but keep ForceFormat for now. + if (ForceFormat == "TBD") + return llvm::MachO::PlatformKind::macOS; + + return createStringError(errc::not_supported, "Invalid Platform.\n"); + }(T); + if (!ArchOrError) return -1; + if (!PlatformKindOrError) + return -1; + Architecture Arch = ArchOrError.get(); + PlatformKind Plat = PlatformKindOrError.get(); InterfaceFile File; - File.setFileType(FileType::TBD_V3); + File.setFileType(FileType::TBD_V3); // Only supporting v3 for now. File.setArchitectures(Arch); - File.setPlatform(PlatformKind::macOS); + File.setPlatform(Plat); for (const auto &Symbol : Symbols) { auto Name = Symbol.Name; |