It was pointed out that I had hard-coded PlatformKind. This is rectifying that.
Differential Revision: https://reviews.llvm.org/D67255
llvm-svn: 371248
--- /dev/null
+# 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 }
+...
--- /dev/null
+# 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 }
+...
--- /dev/null
+# 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 }
+...
--- /dev/null
+# 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 }
+...
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.
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.
[](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:
}
}(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;