Skip to content

Commit

Permalink
Add --list-imports to show list of imports
Browse files Browse the repository at this point in the history
  • Loading branch information
plajjan authored and Kristian Larsson committed Jan 22, 2025
1 parent 02ce405 commit 9d763e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compiler/actonc/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ main = do
C.debug = C.debugB opts,
C.dev = C.devB opts,
C.db = C.dbB opts,
C.listimports = C.listimportsB opts,
C.only_build = C.only_buildB opts,
C.skip_build = C.skip_buildB opts,
C.no_threads = C.no_threadsB opts,
Expand Down Expand Up @@ -120,7 +121,7 @@ main = do

defaultOpts = C.CompileOptions False False False False False False False False False False False False
False False False False False False False False False False False False
False False "" "" "" C.defTarget "" False []
False False False "" "" "" C.defTarget "" False []


-- Auxiliary functions ---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -380,6 +381,12 @@ compileFiles opts srcFiles = do
removeOrphanFiles (projTypes paths)

tasks <- mapM (parseActFile opts paths) srcFiles
iff (C.listimports opts) $ do
let module_imports = map (\t -> concat [ modNameToString (name t), ": ", (concat $ intersperse " " (map (modNameToString) (importsOf t))) ] ) tasks
let output = concat $ intersperse "\n" module_imports
putStrLn output
System.Exit.exitSuccess

-- figure out binTasks, if --root is provided, use that, otherwise
-- presumptuously use all non-stub source compile tasks, which get filtered
-- out later on (after we parsed the project source files) in case they
Expand Down
4 changes: 4 additions & 0 deletions compiler/lib/src/Acton/CommandLineParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ data CompileOptions = CompileOptions {
quiet :: Bool,
debug :: Bool,
dev :: Bool,
listimports :: Bool,
only_build :: Bool,
skip_build :: Bool,
no_threads :: Bool,
Expand All @@ -81,6 +82,7 @@ data BuildOptions = BuildOptions {
no_threadsB :: Bool,
debugB :: Bool,
devB :: Bool,
listimportsB :: Bool,
only_buildB :: Bool,
skip_buildB :: Bool,
autostubB :: Bool,
Expand Down Expand Up @@ -159,6 +161,7 @@ compileOptions = CompileOptions
<*> switch (long "quiet" <> help "Don't print stuff")
<*> switch (long "debug" <> help "Print debug stuff")
<*> switch (long "dev" <> help "Development mode; include debug symbols etc")
<*> switch (long "list-imports" <> help "List module imports")
<*> switch (long "only-build" <> help "Only perform final build of .c files, do not compile .act files")
<*> switch (long "skip-build" <> help "Skip final bulid of .c files")
<*> switch (long "no-threads" <> help "Don't use threads")
Expand All @@ -179,6 +182,7 @@ buildCommand = Build <$> (
<*> switch (long "no-threads" <> help "Don't use threads")
<*> switch (long "debug" <> help "Print debug stuff")
<*> switch (long "dev" <> help "Development mode; include debug symbols etc")
<*> switch (long "list-imports" <> help "List module imports")
<*> switch (long "only-build" <> help "Only perform final build of .c files, do not compile .act files")
<*> switch (long "skip-build" <> help "Skip final build of .c files")
<*> switch (long "auto-stub" <> help "Allow automatic stub detection")
Expand Down

0 comments on commit 9d763e1

Please sign in to comment.