[MachO] Add skeletal support for DriverKit platform
Define the platform ID = 10, and simple mappings between platform ID & name. Reviewed By: MaskRay, cishida Differential Revision: https://reviews.llvm.org/D85594
This commit is contained in:
parent
36f524f454
commit
eef41efe00
|
@ -495,7 +495,8 @@ enum PlatformType {
|
|||
PLATFORM_MACCATALYST = 6,
|
||||
PLATFORM_IOSSIMULATOR = 7,
|
||||
PLATFORM_TVOSSIMULATOR = 8,
|
||||
PLATFORM_WATCHOSSIMULATOR = 9
|
||||
PLATFORM_WATCHOSSIMULATOR = 9,
|
||||
PLATFORM_DRIVERKIT = 10,
|
||||
};
|
||||
|
||||
// Values for tools enum in build_tool_version.
|
||||
|
|
|
@ -615,6 +615,7 @@ public:
|
|||
case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator";
|
||||
case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator";
|
||||
case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator";
|
||||
case MachO::PLATFORM_DRIVERKIT: return "driverkit";
|
||||
default:
|
||||
std::string ret;
|
||||
raw_string_ostream ss(ret);
|
||||
|
|
|
@ -29,7 +29,8 @@ enum class PlatformKind : unsigned {
|
|||
macCatalyst = MachO::PLATFORM_MACCATALYST,
|
||||
iOSSimulator = MachO::PLATFORM_IOSSIMULATOR,
|
||||
tvOSSimulator = MachO::PLATFORM_TVOSSIMULATOR,
|
||||
watchOSSimulator = MachO::PLATFORM_WATCHOSSIMULATOR
|
||||
watchOSSimulator = MachO::PLATFORM_WATCHOSSIMULATOR,
|
||||
driverKit = MachO::PLATFORM_DRIVERKIT,
|
||||
};
|
||||
|
||||
using PlatformSet = SmallSet<PlatformKind, 3>;
|
||||
|
@ -42,4 +43,4 @@ StringRef getPlatformName(PlatformKind Platform);
|
|||
} // end namespace MachO.
|
||||
} // end namespace llvm.
|
||||
|
||||
#endif // LLVM_TEXTAPI_MACHO_PLATFORM_H
|
||||
#endif // LLVM_TEXTAPI_MACHO_PLATFORM_H
|
||||
|
|
|
@ -580,6 +580,7 @@ static const char *getPlatformName(MachO::PlatformType Type) {
|
|||
case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator";
|
||||
case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator";
|
||||
case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator";
|
||||
case MachO::PLATFORM_DRIVERKIT: return "driverkit";
|
||||
}
|
||||
llvm_unreachable("Invalid Mach-O platform type");
|
||||
}
|
||||
|
|
|
@ -1152,6 +1152,7 @@ static Triple::OSType getOSTypeFromPlatform(MachO::PlatformType Type) {
|
|||
case MachO::PLATFORM_IOSSIMULATOR: /* silence warning */ break;
|
||||
case MachO::PLATFORM_TVOSSIMULATOR: /* silence warning */ break;
|
||||
case MachO::PLATFORM_WATCHOSSIMULATOR: /* silence warning */ break;
|
||||
case MachO::PLATFORM_DRIVERKIT: /* silence warning */ break;
|
||||
}
|
||||
llvm_unreachable("Invalid mach-o platform type");
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ PlatformKind mapToPlatformKind(const Triple &Target) {
|
|||
case Triple::WatchOS:
|
||||
return Target.isSimulatorEnvironment() ? PlatformKind::watchOSSimulator
|
||||
: PlatformKind::watchOS;
|
||||
// TODO: add bridgeOS once in llvm::Triple
|
||||
// TODO: add bridgeOS & driverKit once in llvm::Triple
|
||||
}
|
||||
llvm_unreachable("Unknown Target Triple");
|
||||
}
|
||||
|
@ -83,6 +83,8 @@ StringRef getPlatformName(PlatformKind Platform) {
|
|||
return "tvOS Simulator";
|
||||
case PlatformKind::watchOSSimulator:
|
||||
return "watchOS Simulator";
|
||||
case PlatformKind::driverKit:
|
||||
return "driverKit";
|
||||
}
|
||||
llvm_unreachable("Unknown llvm.MachO.PlatformKind enum");
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ Expected<Target> Target::create(StringRef TargetValue) {
|
|||
.Case("ios-simulator", PlatformKind::iOSSimulator)
|
||||
.Case("tvos-simulator", PlatformKind::tvOSSimulator)
|
||||
.Case("watchos-simulator", PlatformKind::watchOSSimulator)
|
||||
.Case("driverkit", PlatformKind::driverKit)
|
||||
.Default(PlatformKind::unknown);
|
||||
|
||||
if (Platform == PlatformKind::unknown) {
|
||||
|
|
|
@ -407,6 +407,9 @@ template <> struct ScalarTraits<Target> {
|
|||
case PlatformKind::watchOSSimulator:
|
||||
OS << "watchos-simulator";
|
||||
break;
|
||||
case PlatformKind::driverKit:
|
||||
OS << "driverkit";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,9 @@ void ScalarTraits<PlatformSet>::output(const PlatformSet &Values, void *IO,
|
|||
case PlatformKind::macCatalyst:
|
||||
OS << "iosmac";
|
||||
break;
|
||||
case PlatformKind::driverKit:
|
||||
OS << "driverkit";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -758,6 +758,30 @@ TEST(TBDv4, Target_i386_watchos_simulator) {
|
|||
stripWhitespace(Buffer.c_str()));
|
||||
}
|
||||
|
||||
TEST(TBDv4, Target_i386_driverkit) {
|
||||
static const char TBDv4i386DriverKit[] = "--- !tapi-tbd\n"
|
||||
"tbd-version: 4\n"
|
||||
"targets: [ i386-driverkit ]\n"
|
||||
"install-name: Test.dylib\n"
|
||||
"...\n";
|
||||
|
||||
Expected<TBDFile> Result =
|
||||
TextAPIReader::get(MemoryBufferRef(TBDv4i386DriverKit, "Test.tbd"));
|
||||
EXPECT_TRUE(!!Result);
|
||||
TBDFile File = std::move(Result.get());
|
||||
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
||||
EXPECT_EQ(ArchitectureSet(AK_i386), File->getArchitectures());
|
||||
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
||||
EXPECT_EQ(PlatformKind::driverKit, *File->getPlatforms().begin());
|
||||
|
||||
SmallString<4096> Buffer;
|
||||
raw_svector_ostream OS(Buffer);
|
||||
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
||||
EXPECT_TRUE(!WriteResult);
|
||||
EXPECT_EQ(stripWhitespace(TBDv4i386DriverKit),
|
||||
stripWhitespace(Buffer.c_str()));
|
||||
}
|
||||
|
||||
TEST(TBDv4, Swift_1) {
|
||||
static const char TBDv4SwiftVersion1[] = "--- !tapi-tbd\n"
|
||||
"tbd-version: 4\n"
|
||||
|
|
Loading…
Reference in New Issue