diff options
author | nea <nea@nea.moe> | 2023-01-24 22:17:31 +0100 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-01-24 22:17:31 +0100 |
commit | 9981add49d62b039ae61edfece584fe038ef07a5 (patch) | |
tree | e212984f4c70f64601096b8e5de138aadafe31ff /src/main/frege/buildclient/config | |
parent | 00b782440054102c405c2001835cc817c1947037 (diff) | |
download | buildclient-master.tar.gz buildclient-master.tar.bz2 buildclient-master.zip |
Diffstat (limited to 'src/main/frege/buildclient/config')
-rw-r--r-- | src/main/frege/buildclient/config/BuildConfig.fr | 17 | ||||
-rw-r--r-- | src/main/frege/buildclient/config/BuildParser.fr | 7 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/main/frege/buildclient/config/BuildConfig.fr b/src/main/frege/buildclient/config/BuildConfig.fr index 7c3290f..616b0bd 100644 --- a/src/main/frege/buildclient/config/BuildConfig.fr +++ b/src/main/frege/buildclient/config/BuildConfig.fr @@ -50,7 +50,6 @@ maybeOr :: a -> Maybe a -> a maybeOr _ (Just x) = x maybeOr x Nothing = x - data ArchiveFormat = Zip derive Show ArchiveFormat @@ -74,14 +73,22 @@ findSource (ASTDirective _ [ASTWord name] _) = fail ("Unknown source type " ++ n findSource _ = fail "Please provide a source type" -data BuildSystem = GradleBuild { task::String, project :: Maybe String } +data BuildSystem = GradleBuild { task::String, project :: Maybe String, extraProperties :: [(String, String)] } derive Show BuildSystem findBuildSystem :: ASTDirective -> Either String BuildSystem -findBuildSystem (ASTDirective _ [ASTWord "gradle"] block) = do - task <- getTypedArg "task" "gradle task" block expectString - return $ GradleBuild task $ (getArgDirective "project" block >>= expectString) +findBuildSystem (ASTDirective _ [ASTWord "gradle"] block) = + do + task <- getTypedArg "task" "gradle task" block expectString + let extraProperties = findDirectives "property" block >>= parseExtraProperty + return $ GradleBuild task (getArgDirective "project" block >>= expectString) extraProperties + where + parseExtraProperty directive = maybeToList $ do + name <- (getArg directive 0 >>= expectString) + value <- (getArg directive 1 >>= expectString) + return (name,value) + findBuildSystem _ = fail "Please provide a build system" parseBuildConfig :: [ASTDirective] -> Either String BuildConfig diff --git a/src/main/frege/buildclient/config/BuildParser.fr b/src/main/frege/buildclient/config/BuildParser.fr index 367b177..961be01 100644 --- a/src/main/frege/buildclient/config/BuildParser.fr +++ b/src/main/frege/buildclient/config/BuildParser.fr @@ -113,3 +113,10 @@ findDirective name (directive:ds) | directive.name == name = Just directive | otherwise = findDirective name ds findDirective _ [] = Nothing + +findDirectives :: String -> [ASTDirective] -> [ASTDirective] +findDirectives = findDirectives' [] + where findDirectives' acc name (a:as) + | name == a.name = findDirectives' (a:acc) name as + | otherwise = findDirectives' acc name as + findDirectives' acc _ [] = acc |