Skip to content

[WIP] Add Support for XCFrameworks#244

Closed
evandcoleman wants to merge 1 commit into
tmspzz:masterfrom
evandcoleman:feature/xcframeworks
Closed

[WIP] Add Support for XCFrameworks#244
evandcoleman wants to merge 1 commit into
tmspzz:masterfrom
evandcoleman:feature/xcframeworks

Conversation

@evandcoleman

@evandcoleman evandcoleman commented Apr 15, 2021

Copy link
Copy Markdown
Contributor

Addresses #238

A first pass at adding XCFramework support to Rome. This is my first time writing any Haskell so please be kind. This is not a complete implementation, but it's in a place where it's usable. I'd love if someone with more Haskell experience could pick this up and bring it across the finish line. Or maybe even just point me in the right direction.

Changes

  • Added a --use-xcframeworks flag to the upload, download, and list commands

Known Issues

  • Running with --use-xcframeworks and a --platform ignores frameworks that aren't xcframeworks (workaround is to run it twice with and without the use xcframeworks option)
  • Running with --use-xcframeworks and a --platform places all frameworks inside a platform specific folder in the cache

P.S: We love Rome at The Knot. It's undoubtedly saved us hundreds (if not thousands) of developer hours in the two years we've been using it. Thank you so much for building such a useful tool.

Comment thread src/Lib.hs
listMode
(_useXcFrameworks useXcFrameworksFlag)
(reverseRepositoryMap <> if _noSkipCurrent noSkipCurrentFlag then currentInvertedMap else M.empty)
(frameworkVersions <> if _noSkipCurrent noSkipCurrentFlag

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Found Redundant bracket

if _noSkipCurrent noSkipCurrentFlag then
  (currentFrameworkVersions `filterOutFrameworksAndVersionsIfNotIn`
     finalIgnoreNames)
  else []

Why Not

if _noSkipCurrent noSkipCurrentFlag then
  currentFrameworkVersions `filterOutFrameworksAndVersionsIfNotIn`
    finalIgnoreNames
  else []

Comment thread src/Lib.hs

frameworkNameWithFrameworkExtension = appendFrameworkExtensionTo f
platformBuildDirectory = carthageArtifactsBuildDirectoryForPlatform platform f
frameworkNameWithFrameworkExtension =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Found Reduce duplication

frameworkNameWithFrameworkExtension
  = if useXcFrameworks then appendXcFrameworkExtensionTo f else
      appendFrameworkExtensionTo f
platformBuildDirectory
  = if useXcFrameworks then carthageBuildDirectory else
      carthageArtifactsBuildDirectoryForPlatform platform f
frameworkDirectory
  = platformBuildDirectory </> frameworkNameWithFrameworkExtension
dSYMNameWithDSYMExtension
  = frameworkNameWithFrameworkExtension <> ".dSYM"
dSYMdirectory
  = platformBuildDirectory </> dSYMNameWithDSYMExtension
bcSymbolMapPath d
  = platformBuildDirectory </> bcsymbolmapNameFrom d

Why Not

Combine with src/Lib.hs:928:3

Comment thread src/Lib.hs

frameworkNameWithFrameworkExtension = appendFrameworkExtensionTo f
platformBuildDirectory = carthageArtifactsBuildDirectoryForPlatform platform f
frameworkNameWithFrameworkExtension =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Found Reduce duplication

frameworkNameWithFrameworkExtension
  = if useXcFrameworks then appendXcFrameworkExtensionTo f else
      appendFrameworkExtensionTo f
platformBuildDirectory
  = if useXcFrameworks then carthageBuildDirectory else
      carthageArtifactsBuildDirectoryForPlatform platform f
frameworkDirectory
  = platformBuildDirectory </> frameworkNameWithFrameworkExtension
dSYMNameWithDSYMExtension
  = frameworkNameWithFrameworkExtension <> ".dSYM"
dSYMdirectory
  = platformBuildDirectory </> dSYMNameWithDSYMExtension
bcSymbolMapPath d
  = platformBuildDirectory </> bcsymbolmapNameFrom d

Why Not

Combine with src/Lib.hs:829:3

Comment thread src/Lib.hs
e2 <- runExceptT $ do
frameworkBinary <- getFrameworkFromS3 s3BucketName reverseRomeMap fVersion platform
frameworkBinary <- getFrameworkFromS3 s3BucketName useXcFrameworks reverseRomeMap fVersion platform
saveBinaryToLocalCache lCacheDir frameworkBinary (prefix </> remoteFrameworkUploadPath) fwn verbose

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Found Reduce duplication

saveBinaryToLocalCache lCacheDir frameworkBinary
  (prefix </> remoteFrameworkUploadPath)
  fwn
  verbose
deleteFrameworkDirectory fVersion platform verbose
unzipBinary frameworkBinary fwn frameworkZipName verbose <*
  ifExists frameworkExecutablePath
    (makeExecutable frameworkExecutablePath)

Why Not

Combine with src/Lib.hs:1220:17

Comment thread src/Lib.hs
where
frameworkZipName = frameworkArchiveName f version
remoteFrameworkUploadPath = remoteFrameworkPath platform reverseRomeMap f version
frameworkZipName = frameworkArchiveName f version useXcFrameworks

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Found Reduce duplication

frameworkZipName = frameworkArchiveName f version useXcFrameworks
remoteFrameworkUploadPath
  = remoteFrameworkPath useXcFrameworks platform reverseRomeMap f
      version
remoteBcSymbolmapUploadPathFromDwarf dwarfUUID
  = remoteBcsymbolmapPath dwarfUUID platform reverseRomeMap f version
dSYMZipName = dSYMArchiveName f version
remotedSYMUploadPath
  = remoteDsymPath platform reverseRomeMap f version
platformBuildDirectory
  = carthageArtifactsBuildDirectoryForPlatform platform f
dSYMName = fwn <> ".dSYM"
frameworkExecutablePath
  = frameworkBuildBundleForPlatform platform f </> fwn

Why Not

Combine with src/Lib.hs:1278:3

@hlintBot

hlintBot commented Apr 15, 2021

Copy link
Copy Markdown
18 Warnings
⚠️ PR is classed as Work in Progress
⚠️ src/Caches/Local/Downloading.hs#L187 - Found Reduce duplication

frameworkNameWithFrameworkExtension = appendFrameworkExtensionTo f
platformBuildDirectory
  = carthageArtifactsBuildDirectoryForPlatform platform f
frameworkDirectory
  = platformBuildDirectory </> frameworkNameWithFrameworkExtension

Why Not

Combine with src/Caches/Local/Downloading.hs:215:3

    
⚠️ src/Caches/Local/Downloading.hs#L207 - Found Use tuple-section

\ e -> (dwarfUUID, e)

Why Not

(dwarfUUID,)

    
⚠️ src/Caches/S3/Downloading.hs#L189 - Found Use tuple-section

\ e -> (dwarfUUID, e)

Why Not

(dwarfUUID,)

    
⚠️ src/CommandParsers.hs#L98 - Found Use <$>

pure Upload <*> udcPayloadParser

Why Not

Upload <$> udcPayloadParser

    
⚠️ src/CommandParsers.hs#L101 - Found Use <$>

pure Download <*> udcPayloadParser

Why Not

Download <$> udcPayloadParser

    
⚠️ src/Engine/Downloading.hs#L141 - Found Use tuple-section

\ e -> (dwarfUUID, e)

Why Not

(dwarfUUID,)

    
⚠️ src/Lib.hs#L239 - Found Reduce duplication

let finalRepositoryMapEntries
      = if _noIgnore noIgnoreFlag then repositoryMapEntries else
          repositoryMapEntries `filterRomeFileEntriesByPlatforms`
            ignoreMapEntries
let repositoryMap = toRepositoryMap finalRepositoryMapEntries
let reverseRepositoryMap
      = toInvertedRepositoryMap finalRepositoryMapEntries
let finalIgnoreNames
      = if _noIgnore noIgnoreFlag then [] else ignoreFrameworks

Why Not

Combine with src/Lib.hs:323:5

    
⚠️ src/Lib.hs#L248 - Found Reduce duplication

let filteredCurrentMapEntries
      = currentMapEntries `filterRomeFileEntriesByPlatforms`
          ignoreMapEntries
let currentFrameworks
      = concatMap (snd . romeFileEntryToTuple) filteredCurrentMapEntries
let currentFrameworkVersions
      = map (flip FrameworkVersion currentVersion) currentFrameworks
let currentInvertedMap
      = toInvertedRepositoryMap filteredCurrentMapEntries

Why Not

Combine with src/Lib.hs:347:17

    
⚠️ src/Lib.hs#L977 - Found Reduce duplication

saveBinaryToLocalCache lCacheDir versionFileBinary
  (prefix </> versionFileRemotePath)
  versionFileName
  verbose
liftIO $ saveBinaryToFile versionFileBinary versionFileLocalPath
sayFunc $
  "Copied " <> versionFileName <> " to: " <> versionFileLocalPath

Why Not

Combine with src/Lib.hs:1349:15

    
⚠️ src/Lib.hs#L988 - Found Reduce duplication

versionFileName
  = versionFileNameForProjectName $ fst projectNameAndVersion
versionFileLocalPath = carthageBuildDirectory </> versionFileName
versionFileRemotePath = remoteVersionFilePath projectNameAndVersion

Why Not

Combine with src/Lib.hs:1360:3

    
⚠️ src/Lib.hs#L1084 - Found Reduce duplication

let symbolmapLoggingName
      = fwn <> "." <> bcsymbolmapNameFrom dwarfUUID
let bcsymbolmapZipName d = bcsymbolmapArchiveName d version
let localBcsymbolmapPathFrom d
      = platformBuildDirectory </> bcsymbolmapNameFrom d

Why Not

Combine with src/Lib.hs:1239:17

    
⚠️ src/Lib.hs#L1088 - Found Reduce duplication

saveBinaryToLocalCache lCacheDir symbolmapBinary
  (prefix </> remoteBcSymbolmapUploadPathFromDwarf dwarfUUID)
  fwn
  verbose
deleteFile (localBcsymbolmapPathFrom dwarfUUID) verbose `catch`
  (\ e ->
     if isDoesNotExistError e then
       when verbose $ sayFunc ("Error :" <> displayException e) else
       throwM e)
unzipBinary symbolmapBinary symbolmapLoggingName
  (bcsymbolmapZipName dwarfUUID)
  verbose

Why Not

Combine with src/Lib.hs:1243:17

    
⚠️ src/Lib.hs#L1117 - Found Reduce duplication

saveBinaryToLocalCache lCacheDir dSYMBinary
  (prefix </> remotedSYMUploadPath)
  dSYMName
  verbose
deleteDSYMDirectory fVersion platform verbose
unzipBinary dSYMBinary dSYMName dSYMZipName verbose

Why Not

Combine with src/Lib.hs:1271:17

    
⚠️ src/Lib.hs#L1151 - Found Use lambda-case

\ e ->
  case e of
      ErrorGettingDwarfUUIDs -> sayFunc $
                                  "Error: Cannot retrieve symbolmaps ids for " <> fwn
      (FailedDwarfUUIDs dwardUUIDsAndErrors) -> mapM_ (sayFunc . snd)
                                                  dwardUUIDsAndErrors

Why Not

\case
    ErrorGettingDwarfUUIDs -> sayFunc $
                                "Error: Cannot retrieve symbolmaps ids for " <> fwn
    (FailedDwarfUUIDs dwardUUIDsAndErrors) -> mapM_ (sayFunc . snd)
                                                dwardUUIDsAndErrors

    
⚠️ src/Lib.hs#L1303 - Found Use lambda-case

\ e ->
  case e of
      ErrorGettingDwarfUUIDs -> sayFunc $
                                  "Error: Cannot retrieve symbolmaps ids for " <> fwn
      (FailedDwarfUUIDs dwardUUIDsAndErrors) -> mapM_ (sayFunc . snd)
                                                  dwardUUIDsAndErrors

Why Not

\case
    ErrorGettingDwarfUUIDs -> sayFunc $
                                "Error: Cannot retrieve symbolmaps ids for " <> fwn
    (FailedDwarfUUIDs dwardUUIDsAndErrors) -> mapM_ (sayFunc . snd)
                                                dwardUUIDsAndErrors

    
⚠️ src/Types/Commands.hs#L28 - Found Use newtype instead of data

data RomeUtilsPayload = RomeUtilsPayload{_subcommand ::
                                         RomeUtilsSubcommand}
                          deriving (Show, Eq)

Why Not

newtype RomeUtilsPayload = RomeUtilsPayload{_subcommand ::
                                            RomeUtilsSubcommand}
                             deriving (Show, Eq)

    
⚠️ src/Utils.hs#L345 - Found Use tuple-section

\ f -> (f, g)

Why Not

(, g)

    

Generated by 🚫 Danger

@evandcoleman evandcoleman changed the title Add Support for XCFrameworks [WIP] Add Support for XCFrameworks Apr 15, 2021
@tmspzz

tmspzz commented Apr 22, 2021

Copy link
Copy Markdown
Owner

@evandcoleman I missed this, will review asap

@tmspzz

tmspzz commented Apr 22, 2021

Copy link
Copy Markdown
Owner

@evandcoleman can you elaborate a bit more on the use of --platforms with .xcframeworks?

Does it even make sense to allow both flags? Why not just error out if both --platforms and --use-xcframeworks are specified.

Comment thread src/Lib.hs
, SkipLocalCacheFlag {- skipLocalCache -}
, NoSkipCurrentFlag {- noSkipCurrentFlag -}
, ConcurrentlyFlag) {- concurrentlyFlag -}
, NoSkipCurrentFlag {- skipLocalCache -}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a weird rename. This is supposed to skip the current framework. Not the local cache. Unless I made a mistake that is.

@evandcoleman

Copy link
Copy Markdown
Contributor Author

@evandcoleman can you elaborate a bit more on the use of --platforms with .xcframeworks?

Does it even make sense to allow both flags? Why not just error out if both --platforms and --use-xcframeworks are specified.

I think we'll want to support including both flags. In the case of Carthage frameworks that are closed-source and distributed as a compiled binary, those still get placed in a platform specific folder in the Carthage build folder.

@tmspzz

tmspzz commented Apr 26, 2021

Copy link
Copy Markdown
Owner

@evandcoleman can you elaborate a bit more on the use of --platforms with .xcframeworks?
Does it even make sense to allow both flags? Why not just error out if both --platforms and --use-xcframeworks are specified.

I think we'll want to support including both flags. In the case of Carthage frameworks that are closed-source and distributed as a compiled binary, those still get placed in a platform specific folder in the Carthage build folder.

But that only makes sense for regular frameworks. Carthage puts .xcframeworks outside of platform folders if I recall correctly.

@evandcoleman

Copy link
Copy Markdown
Contributor Author

Carthage puts .xcframeworks outside of platform folders if I recall correctly.

Yup! That is the case, but I'm thinking of frameworks such as the Braze SDK. Their Carthage framework is only distributed as a prebuilt (.framework) binary. Without the platform flag and with the xcframework flag, should Rome fail in that case? Or maybe fallback to looking for a regular framework and assume we want all platforms?

@tmspzz

tmspzz commented Apr 28, 2021

Copy link
Copy Markdown
Owner

Without the platform flag and with the xcframework flag, should Rome fail in that case?

I think it should fail. Either it finds and xcframeworks or it doesn't. No fallbacks.

@damiankolasinski

Copy link
Copy Markdown

Any update here guys? Can't wait for this one 😄 @tmspzz @evandcoleman

@mpdifran

Copy link
Copy Markdown
Contributor

@evandcoleman @tmspzz Anything we can do to help get this in, even in an MVP form?

@jangelsb

jangelsb commented Jul 7, 2021

Copy link
Copy Markdown

Super excited for this! Let us know if there is anything we can do to help

@jesus-mg-ios

Copy link
Copy Markdown

@tmspzz @evandcoleman

@evandcoleman

Copy link
Copy Markdown
Contributor Author

Unfortunately, I don't really have the time to spend on this. It's currently in a semi-working state which has been usable for my company. If someone with more Haskell experience than me wants to take this on, then by all means.

@mpdifran

mpdifran commented Aug 3, 2021

Copy link
Copy Markdown
Contributor

What's left to do to get this in? Would it make sense to get this in partially working, and open another PR to fix the remaining issues?

@evandcoleman

Copy link
Copy Markdown
Contributor Author

@mpdifran See the comments above from @tmspzz. He indicated the changes that should be made.

@tmspzz

tmspzz commented Oct 14, 2021

Copy link
Copy Markdown
Owner

Closing in favor of #247

@tmspzz tmspzz closed this Oct 14, 2021
@tmspzz

tmspzz commented Oct 14, 2021

Copy link
Copy Markdown
Owner

thanks @evandcoleman for the amazing work! Now @vikrem will push it over the finish line. 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants