diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-20 14:52:02 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-20 14:52:02 -0500 |
| commit | 9ab85c33379f98229235a30dbf5108ad31a01d1f (patch) | |
| tree | 47bdaf08057e54fa85f7dd9500c29d0e0e7a0e1b /Omni/Bild.hs | |
| parent | 22e4ad1406100fc4377568fe1aa4cb235be21257 (diff) | |
bild: fix --plan to output only JSON without logging
- Remove Log.wipe from --plan output path - Add isPlanMode parameter
to analyzeAll to skip LogC.withLineManager when planning - Update all
analyzeAll call sites to pass isPlanMode flag - Remove grep workaround
from repl.sh (no longer needed)
Now 'bild --plan' outputs clean JSON that can be piped directly to jq.
This fixes typecheck.sh and other tools that rely on clean JSON output.
Amp-Thread-ID:
https://ampcode.com/threads/T-4e6225cf-3e78-4538-963c-5377bbbccee8
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Omni/Bild.hs')
| -rw-r--r-- | Omni/Bild.hs | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/Omni/Bild.hs b/Omni/Bild.hs index aac0d2d..53d96a5 100644 --- a/Omni/Bild.hs +++ b/Omni/Bild.hs @@ -190,7 +190,7 @@ test_bildBild = case Namespace.fromPath root path of Nothing -> Test.assertFailure "can't find ns for bild" Just ns -> - analyzeAll [ns] + analyzeAll False [ns] +> build False False 1 2 +> \case [Exit.ExitFailure _] -> @@ -207,7 +207,7 @@ test_bildExamples = |> traverse Dir.makeAbsolute /> map (Namespace.fromPath root) /> catMaybes - +> analyzeAll + +> analyzeAll False +> build False False 4 1 +> \case [] -> Test.assertFailure "asdf" @@ -226,7 +226,8 @@ move args = do +> traverse Dir.makeAbsolute +> traverse (namespaceFromPathOrDie root) /> filter isBuildableNs - analysis <- analyzeAll namespaces + let isPlanMode = args `Cli.has` Cli.longOption "plan" + analysis <- analyzeAll isPlanMode namespaces printOrBuild root analysis |> Timeout.timeout (toMillis minutes) +> \case @@ -253,7 +254,7 @@ move args = do >> Log.br >> exitWith (ExitFailure 1) | args `Cli.has` Cli.longOption "plan" = - Log.wipe >> putJSON targets >> pure [Exit.ExitSuccess] + putJSON targets >> pure [Exit.ExitSuccess] | otherwise = do nproc <- GHC.getNumProcessors createHier root @@ -463,7 +464,7 @@ dev_getTarget fp = do |> \case Nothing -> panic "Could not get namespace from path" Just ns -> - analyzeAll [ns] + analyzeAll False [ns] /> Map.lookup ns /> \case Nothing -> panic "Could not retrieve target from analysis" @@ -551,12 +552,19 @@ removeVersion = takeWhile (/= '.') .> butlast2 type Analysis = Map Namespace Target -analyzeAll :: [Namespace] -> IO Analysis -analyzeAll nss = do - LogC.withLineManager nss <| \lineMgr -> do - LogC.initializeLines lineMgr - targets <- mapConcurrentlyBounded 8 analyzeOne nss - pure <| Map.fromList <| catMaybes <| zipWith (\ns mt -> (ns,) </ mt) nss targets +analyzeAll :: Bool -> [Namespace] -> IO Analysis +analyzeAll isPlanMode nss = do + if isPlanMode + then do + -- Plan mode: no logging, just analyze + targets <- mapConcurrentlyBounded 8 analyzeOne nss + pure <| Map.fromList <| catMaybes <| zipWith (\ns mt -> (ns,) </ mt) nss targets + else do + -- Normal mode: use concurrent logging + LogC.withLineManager nss <| \lineMgr -> do + LogC.initializeLines lineMgr + targets <- mapConcurrentlyBounded 8 analyzeOne nss + pure <| Map.fromList <| catMaybes <| zipWith (\ns mt -> (ns,) </ mt) nss targets where analyzeOne :: Namespace -> IO (Maybe Target) analyzeOne namespace@(Namespace parts ext) = do |
