kit 0.5 → 0.5.1
raw patch · 4 files changed
+27/−25 lines, 4 files
Files
- Kit/Main.hs +1/−0
- Kit/Model.hs +13/−11
- Kit/Project.hs +12/−13
- kit.cabal +1/−1
Kit/Main.hs view
@@ -87,6 +87,7 @@ writeFile "KitSpec" $ encode verifySpec doUpdate inDirectory "Kits" $ do+ system $ "open KitDeps.xcodeproj" system $ "xcodebuild -sdk " ++ sdk putStrLn "OK." puts "End checks."
Kit/Model.hs view
@@ -9,7 +9,9 @@ specDependencies :: [Kit], specSourceDirectory :: FilePath, specTestDirectory :: FilePath,- specLibDirectory :: FilePath+ specLibDirectory :: FilePath,+ specPrefixFile :: FilePath,+ specConfigFile :: FilePath } deriving (Show, Read) type Version = String@@ -22,24 +24,22 @@ kitFileName :: Kit -> String kitFileName k = kitName k ++ "-" ++ kitVersion k - kitConfigFile :: Kit -> String- kitConfigFile kit = kitFileName kit </> (kitName kit ++ ".xcconfig")- defaultSpecForKit :: Kit -> KitSpec- defaultSpecForKit kit = KitSpec kit [] "src" "test" "lib" -- TODO make this and the json reading use the same defaults+ defaultSpecForKit kit = KitSpec kit [] "src" "test" "lib" "Prefix.pch" "Config.xcconfig"+ -- TODO make this and the json reading use the same defaults+ -- I suspect that to do this I'll need update functions for each of+ -- fields in the KitSpec record.+ -- Look at the 'lenses' package on haskell. instance JSON Kit where- showJSON kit = makeObj- [ ("name", showJSON $ kitName kit)- , ("version", showJSON $ kitVersion kit)- ]+ showJSON kit = makeObj [ ("name", w kitName) , ("version", w kitVersion) ] where w f = showJSON . f $ kit readJSON (JSObject obj) = Kit <$> f "name" <*> f "version" where f x = f' obj x instance JSON KitSpec where- showJSON spec = makeObj- [ ("name", showJSON $ kitName kit)+ showJSON spec = makeObj [+ ("name", showJSON $ kitName kit) , ("version", showJSON $ kitVersion kit) , ("dependencies", showJSON $ specDependencies spec) ]@@ -51,6 +51,8 @@ <*> (f "source-directory" <|> pure "src") <*> (f "test-directory" <|> pure "test") <*> (f "lib-directory" <|> pure "lib")+ <*> (f "prefix-header" <|> pure "Prefix.pch")+ <*> (f "xcconfig" <|> pure "Config.xcconfig") where f x = f' obj x f' obj x = mLookup x (fromJSObject obj) >>= readJSON
Kit/Project.hs view
@@ -47,8 +47,8 @@ headers = findSrc ".h" sources = fmap join $ T.sequence [findSrc ".m", findSrc ".mm", findSrc ".c"] libs = find (specLibDirectory spec) ".a" - config = readConfig kit- prefix = readHeader kit+ config = readConfig spec+ prefix = readHeader spec in KitContents <$> headers <*> sources <*> libs <*> config <*> prefix generateXCodeProject :: [Kit] -> KitIO ()@@ -83,18 +83,19 @@ writeFile xcodeConfigFile $ kitHeaders ++ "\n" ++ prefixHeaders ++ "\n" ++ configToString combinedConfig writeFile kitUpdateMakeFilePath kitUpdateMakeFile - kitPrefixFile = "Prefix.pch"-- readHeader :: Kit -> IO (Maybe String)- readHeader kit = do- let fp = kitFileName kit </> kitPrefixFile+ -- Report missing file+ readHeader :: KitSpec -> IO (Maybe String)+ readHeader spec = do+ let fp = (kitFileName . specKit $ spec) </> specPrefixFile spec exists <- doesFileExist fp contents <- T.sequence (fmap readFile $ justTrue exists fp) return contents - readConfig :: Kit -> IO (Maybe XCConfig)- readConfig kit = do- let fp = kitConfigFile kit+ -- TODO make this report missing file+ readConfig :: KitSpec -> IO (Maybe XCConfig)+ readConfig spec = do+ let kit = specKit spec+ let fp = kitFileName kit </> specConfigFile spec exists <- doesFileExist fp contents <- T.sequence (fmap readFile $ justTrue exists fp) return $ fmap (fileContentsToXCC $ kitName kit) contents@@ -146,7 +147,5 @@ readSpecContents kitSpecPath = checkExists kitSpecPath >>= liftIO . readFile parses :: String -> Either KitError KitSpec- parses contents = case (decode contents) of- Ok a -> Right a- Error a -> Left a+ parses contents = resultToEither (decode contents)
kit.cabal view
@@ -1,5 +1,5 @@ name: kit-version: 0.5+version: 0.5.1 cabal-version: >=1.2 build-type: Simple license: BSD3