From 9ab85c33379f98229235a30dbf5108ad31a01d1f Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Thu, 20 Nov 2025 14:52:02 -0500 Subject: 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 --- Omni/Bild.hs | 30 +++++++++++++++++++----------- Omni/Ide/repl.sh | 3 +-- 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'Omni') 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,) [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,) do + LogC.initializeLines lineMgr + targets <- mapConcurrentlyBounded 8 analyzeOne nss + pure <| Map.fromList <| catMaybes <| zipWith (\ns mt -> (ns,) IO (Maybe Target) analyzeOne namespace@(Namespace parts ext) = do diff --git a/Omni/Ide/repl.sh b/Omni/Ide/repl.sh index ad6bc02..6225078 100755 --- a/Omni/Ide/repl.sh +++ b/Omni/Ide/repl.sh @@ -30,8 +30,7 @@ fi shift fi targets="${*:?}" - # Extract only the JSON line from bild --plan output (skip progress indicators) - json=$(bild --plan "${targets[@]}" 2>&1 | grep -E '^\{') + json=$(bild --plan "${targets[@]}" 2>&1) mapfile -t langdeps < <(jq --raw-output '.[].langdeps | select(length > 0) | join("\n")' <<< "$json") mapfile -t sysdeps < <(jq --raw-output '.[].sysdeps | select(length > 0) | join("\n")' <<< "$json") mapfile -t rundeps < <(jq --raw-output '.[].rundeps | select(length > 0) | join("\n")' <<< "$json") -- cgit v1.2.3