+std::string Options::getSDKVersionStr() const
+{
+ return getVersionString32(fSDKVersion);
+}
+
+std::string Options::getPlatformStr() const
+{
+ switch (fPlatform) {
+ case Options::kPlatformOSX:
+ return "MacOSX";
+ case Options::kPlatformiOS:
+ if (targetIOSSimulator())
+ return "iPhoneSimulator";
+ else
+ return "iPhoneOS";
+ case Options::kPlatformWatchOS:
+ if (targetIOSSimulator())
+ return "watchOS Simulator";
+ else
+ return "watchOS";
+#if SUPPORT_APPLE_TV
+ case Options::kPlatform_tvOS:
+ if (targetIOSSimulator())
+ return "AppleTVSimulator";
+ else
+ return "AppleTVOS";
+ break;
+#endif
+ case Options::kPlatformUnknown:
+ return "Unknown";
+ }
+}
+
+std::vector<std::string> Options::writeBitcodeLinkOptions() const
+{
+ std::vector<std::string> linkCommand;
+ switch ( fOutputKind ) {
+ case Options::kDynamicLibrary:
+ linkCommand.push_back("-dylib");
+ linkCommand.push_back("-compatibility_version");
+ if ( fDylibCompatVersion != 0 ) {
+ linkCommand.push_back(getVersionString32(fDylibCompatVersion));
+ } else {
+ linkCommand.push_back(getVersionString32(currentVersion32()));
+ }
+ if ( fDylibCurrentVersion != 0 ) {
+ linkCommand.push_back("-current_version");
+ linkCommand.push_back(getVersionString64(fDylibCurrentVersion));
+ }
+ linkCommand.push_back("-install_name");
+ linkCommand.push_back(installPath());
+ break;
+ case Options::kDynamicExecutable:
+ linkCommand.push_back("-execute");
+ break;
+ case Options::kObjectFile:
+ linkCommand.push_back("-r");
+ break;
+ default:
+ throwf("could not write bitcode options file output kind\n");
+ }
+
+ if (!fImplicitlyLinkPublicDylibs)
+ linkCommand.push_back("-no_implicit_dylibs");
+
+ // Add deployment target.
+ // Platform is allowed to be unknown for "ld -r".
+ switch (fPlatform) {
+ case Options::kPlatformOSX:
+ linkCommand.push_back("-macosx_version_min");
+ linkCommand.push_back(getVersionString32((unsigned)fMacVersionMin));
+ break;
+ case Options::kPlatformiOS:
+ if (targetIOSSimulator())
+ linkCommand.push_back("-ios_simulator_version_min");
+ else
+ linkCommand.push_back("-ios_version_min");
+ linkCommand.push_back(getVersionString32((unsigned)fIOSVersionMin));
+ break;
+ case Options::kPlatformWatchOS:
+ if (targetIOSSimulator())
+ linkCommand.push_back("-watchos_simulator_version_min");
+ else
+ linkCommand.push_back("-watchos_version_min");
+ linkCommand.push_back(getVersionString32((unsigned)fIOSVersionMin));
+ break;
+#if SUPPORT_APPLE_TV
+ case Options::kPlatform_tvOS:
+ if (targetIOSSimulator())
+ linkCommand.push_back("-tvos_simulator_version_min");
+ else
+ linkCommand.push_back("-tvos_version_min");
+ linkCommand.push_back(getVersionString32((unsigned)fIOSVersionMin));
+ break;
+#endif
+ case Options::kPlatformUnknown:
+ if ( fOutputKind != Options::kObjectFile ) {
+ throwf("platform is unknown for final bitcode bundle,"
+ "deployment target and min version is required for -bitcode_bundle");
+ }
+ break;
+ }
+
+
+ // entry name
+ if ( fEntryName ) {
+ linkCommand.push_back("-e");
+ linkCommand.push_back(fEntryName);
+ }
+
+ // Write rpaths
+ if (!fRPaths.empty()) {
+ for (std::vector<const char*>::const_iterator it=fRPaths.begin(); it != fRPaths.end(); ++it) {
+ linkCommand.push_back("-rpath");
+ linkCommand.push_back(*it);
+ }
+ }
+
+ // Other bitcode compatiable options
+ if ( fObjCABIVersion1Override ) {
+ linkCommand.push_back("-objc_abi_version");
+ linkCommand.push_back("1");
+ } else if ( fObjCABIVersion2Override ) {
+ linkCommand.push_back("-objc_abi_version");
+ linkCommand.push_back("2");
+ }
+ if ( fExecutablePath ) {
+ linkCommand.push_back("-executable_path");
+ linkCommand.push_back(fExecutablePath);
+ }
+ if ( fDeadStrip )
+ linkCommand.push_back("-dead_strip");
+ if ( fExportDynamic )
+ linkCommand.push_back("-export_dynamic");
+ if ( fMarkAppExtensionSafe && fCheckAppExtensionSafe )
+ linkCommand.push_back("-application_extension");
+
+ if ( fSourceVersionLoadCommandForceOn )
+ linkCommand.push_back("-add_source_version");
+ if ( fSourceVersion != 0 ) {
+ linkCommand.push_back("-source_version");
+ linkCommand.push_back(getVersionString64(fSourceVersion));
+ }
+
+ // linker flag added by swift driver
+ // rdar://problem/20108072
+ if ( !fObjcCategoryMerging )
+ linkCommand.push_back("-no_objc_category_merging");
+
+ return linkCommand;
+}