summaryrefslogtreecommitdiff
path: root/Omni/Bild.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Omni/Bild.hs')
-rwxr-xr-x[-rw-r--r--]Omni/Bild.hs65
1 files changed, 30 insertions, 35 deletions
diff --git a/Omni/Bild.hs b/Omni/Bild.hs
index 648bfcb..92bbb78 100644..100755
--- a/Omni/Bild.hs
+++ b/Omni/Bild.hs
@@ -1,3 +1,4 @@
+#!/usr/bin/env run.sh
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
@@ -479,15 +480,13 @@ cab =
outToPath :: Meta.Out -> FilePath
outToPath = \case
- Meta.Bin o -> cab </> "bin" </> o
- Meta.Lib o -> cab </> "lib" </> o
- Meta.None -> mempty
+ Just o -> cab </> "bin" </> o
+ Nothing -> mempty
outname :: Meta.Out -> FilePath
outname = \case
- Meta.Bin o -> o
- Meta.Lib o -> o
- Meta.None -> mempty
+ Just o -> o
+ Nothing -> mempty
bindir, intdir, nixdir, vardir :: FilePath
bindir = cab </> "bin"
@@ -500,8 +499,7 @@ createHier :: String -> IO ()
createHier root =
traverse_
(Dir.createDirectoryIfMissing True)
- [ root </> (outToPath <| Meta.Bin ""),
- root </> (outToPath <| Meta.Lib ""),
+ [ root </> (outToPath <| Just ""),
root </> intdir,
root </> nixdir,
root </> vardir
@@ -524,7 +522,7 @@ analyze hmap ns = case Map.lookup ns hmap of
Just _ -> pure hmap
where
analyzeOne :: Namespace -> IO (Maybe Target)
- analyzeOne namespace@(Namespace _ ext) = do
+ analyzeOne namespace@(Namespace parts ext) = do
let path = Namespace.toPath namespace
root <- Env.getEnv "CODEROOT"
let abspath = root </> path
@@ -537,6 +535,10 @@ analyze hmap ns = case Map.lookup ns hmap of
IO.hSetEncoding h IO.utf8_bom
>> Text.IO.hGetContents h
/> Text.lines
+ -- if the file is exe but doesn't have 'out' metadata, just use the
+ -- dot-separated namespace instead
+ isExe <- Dir.getPermissions quapath /> Dir.executable
+ let defaultOut = isExe ?: (Just <| Namespace.dotSeparated parts, Nothing)
case ext of
-- basically we don't support building these
Namespace.Css -> pure Nothing
@@ -569,7 +571,7 @@ analyze hmap ns = case Map.lookup ns hmap of
sysdeps = psys,
langdeps = pdep,
outPath = outToPath pout,
- out = pout,
+ out = pout <|> defaultOut,
packageSet = "python.packages",
mainModule = Namespace.toModule namespace,
rundeps = prun,
@@ -586,13 +588,13 @@ analyze hmap ns = case Map.lookup ns hmap of
wrapper = Nothing,
compiler = Gcc,
builder = "c",
- out = pout,
+ out = pout <|> defaultOut,
packageSet = "c.packages",
mainModule = Namespace.toModule namespace,
compilerFlags = case pout of
- Meta.Bin o ->
+ Just o ->
["-o", o, path] <> Set.toList parg |> map Text.pack
- _ -> panic "can only bild C exes, not libs",
+ Nothing -> panic "can only bild C exes, not libs",
outPath = outToPath pout,
-- implement detectCImports, then I can fill this out
srcs = Set.empty,
@@ -627,18 +629,18 @@ analyze hmap ns = case Map.lookup ns hmap of
"$CODEROOT" </> quapath
]
++ case pout of
- Meta.Bin o ->
+ Just o ->
[ "-main-is",
Namespace.toHaskellModule namespace,
"-o",
o
]
- _ -> []
+ Nothing -> []
|> map Text.pack,
sysdeps = Meta.detect (Meta.sys "--") contentLines,
outPath = outToPath pout,
rundeps = prun,
- out = pout,
+ out = pout <|> defaultOut,
..
}
|> Just
@@ -689,8 +691,8 @@ analyze hmap ns = case Map.lookup ns hmap of
str <| "import " <> root </> "Omni/Bild.nix {}"
]
|> map Text.pack,
- out = Meta.None,
- outPath = outToPath Meta.None,
+ out = Nothing,
+ outPath = outToPath Nothing,
srcs = Set.empty,
packageSet = "",
mainModule = Namespace.toModule namespace,
@@ -718,12 +720,12 @@ analyze hmap ns = case Map.lookup ns hmap of
|> map Text.pack,
builder = "base",
outPath = outToPath pout,
- out = pout,
+ out = pout <|> defaultOut,
srcs = Set.empty, -- implement detectSchemeImports
-- TODO: wrapper should just be removed, instead rely on
-- upstream nixpkgs builders to make wrappers
wrapper =
- (pout == Meta.None)
+ isNothing pout
?: ( Nothing,
[ "#!/usr/bin/env bash",
"guile -C \""
@@ -754,17 +756,17 @@ analyze hmap ns = case Map.lookup ns hmap of
mainModule = Namespace.toModule namespace,
wrapper = Nothing,
sysdeps = psys <> Set.singleton "rustc",
- out = pout,
+ out = pout <|> defaultOut,
compiler = Rustc,
compilerFlags = case pout of
- Meta.Bin o ->
+ Just o ->
map
Text.pack
[ "$CODEROOT" </> path,
"-o",
o
]
- _ -> panic "can't build rust libs",
+ Nothing -> panic "can't build rust libs",
builder = "base",
outPath = outToPath pout,
-- implement detectRustImports
@@ -916,31 +918,24 @@ build andTest loud jobs cpus analysis =
forM (Map.elems analysis) <| \target@Target {..} ->
fst </ case compiler of
CPython -> case out of
- Meta.Bin _ ->
+ Just _ ->
Log.info ["bild", "nix", "python", nschunk namespace]
>> nixBuild loud jobs cpus target
+> (\r -> (isSuccess (fst r) && andTest) ?: (test loud target, pure r))
- _ ->
+ Nothing ->
Log.info ["bild", "nix", "python", nschunk namespace, "cannot build library"]
>> pure (Exit.ExitSuccess, mempty)
Gcc ->
- Log.info ["bild", label, "gcc", nschunk namespace]
+ Log.info ["bild", "nix", "gcc", nschunk namespace]
>> nixBuild loud jobs cpus target
- where
- label = case out of
- Meta.Bin _ -> "bin"
- _ -> "lib"
Ghc -> case out of
- Meta.None -> pure (Exit.ExitSuccess, mempty)
- Meta.Bin _ -> do
+ Nothing -> pure (Exit.ExitSuccess, mempty)
+ Just _ -> do
Log.info ["bild", "nix", user <> "@" <> host, nschunk namespace]
result <- nixBuild loud jobs cpus target
if andTest && (isSuccess <| fst result)
then test loud target
else pure result
- Meta.Lib _ -> do
- Log.info ["bild", "dev", "ghc-lib", nschunk namespace]
- proc loud namespace (toNixFlag compiler) compilerFlags
Guile -> do
Log.info ["bild", "dev", "guile", nschunk namespace]
_ <- proc loud namespace (toNixFlag compiler) compilerFlags