Skip to content

Commit

Permalink
Merge pull request #1048 from actonlang/1047-auto-stub
Browse files Browse the repository at this point in the history
  • Loading branch information
plajjan authored Nov 4, 2022
2 parents f62e8c3 + fd12a03 commit 58d2ac7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ builtin/ty/out/types/__builtin__.ty: builtin/ty/src/__builtin__.act $(ACTONC)

# Build our standard library
stdlib/out/dev/lib/libActonProject.a: $(STDLIB_SRCFILES) dist/types/__builtin__.ty $(DIST_HFILES) $(ACTONC) $(DEPSA)
cd stdlib && ../$(ACTC) build --always-build --dev
cd stdlib && ../$(ACTC) build --always-build --auto-stub --dev

stdlib/out/rel/lib/libActonProject.a: $(STDLIB_SRCFILES) dist/types/__builtin__.ty $(DIST_HFILES) $(ACTONC) $(DEPSA)
cd stdlib && ../$(ACTC) build --always-build
cd stdlib && ../$(ACTC) build --always-build --auto-stub
cp -a stdlib/out/types/. dist/types/


Expand Down
4 changes: 4 additions & 0 deletions compiler/Acton/CommandLineParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ data CompileOptions = CompileOptions {
ccmd :: Bool,
verbose :: Bool,
timing :: Bool,
autostub :: Bool,
stub :: Bool,
cpedantic :: Bool,
quiet :: Bool,
Expand All @@ -54,6 +55,7 @@ data CompileOptions = CompileOptions {
data BuildOptions = BuildOptions {
alwaysB :: Bool,
devB :: Bool,
autostubB :: Bool,
rootB :: String,
quietB :: Bool,
timingB :: Bool
Expand Down Expand Up @@ -117,6 +119,7 @@ compileOptions = CompileOptions
<*> switch (long "ccmd" <> help "Show CC / LD commands")
<*> switch (long "verbose" <> help "Print progress info during execution")
<*> switch (long "timing" <> help "Print timing information")
<*> switch (long "auto-stub" <> help "Allow automatic stub detection")
<*> switch (long "stub" <> help "Stub (.ty) file generation only")
<*> switch (long "cpedantic" <> help "Pedantic C compilation with -Werror")
<*> switch (long "quiet" <> help "Don't print stuff")
Expand All @@ -130,6 +133,7 @@ buildCommand = Build <$> (
BuildOptions
<$> switch (long "always-build" <> help "Development mode; include debug symbols etc")
<*> switch (long "dev" <> help "Development mode; include debug symbols etc")
<*> switch (long "auto-stub" <> help "Allow automatic stub detection")
<*> strOption (long "root" <> metavar "ROOTACTOR" <> value "" <> help "Set root actor")
<*> switch (long "quiet" <> help "Don't print stuff")
<*> switch (long "timing" <> help "Print timing information")
Expand Down
9 changes: 5 additions & 4 deletions compiler/ActonCompiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ main = do arg <- C.parseCmdLine
case arg of
C.VersionOpt opts -> printVersion opts
C.CmdOpt (C.New opts) -> createProject (C.file opts)
C.CmdOpt (C.Build opts) -> buildProject $ defaultOpts {C.alwaysbuild = C.alwaysB opts, C.dev = C.devB opts, C.root = C.rootB opts, C.quiet = C.quietB opts, C.timing = C.timingB opts}
C.CmdOpt (C.Build opts) -> buildProject $ defaultOpts {C.alwaysbuild = C.alwaysB opts, C.autostub = C.autostubB opts, C.dev = C.devB opts, C.root = C.rootB opts, C.quiet = C.quietB opts, C.timing = C.timingB opts}
C.CmdOpt (C.Cloud opts) -> undefined
C.CmdOpt (C.Doc opts) -> printDocs opts
C.CompileOpt nms opts -> compileFiles opts (catMaybes $ map filterActFile nms)

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 False False "" "" ""


-- Auxiliary functions ---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -367,9 +367,10 @@ parseActFile opts paths actFile = do
where detectStubMode :: Paths -> String -> C.CompileOptions -> IO Bool
detectStubMode paths srcfile opts = do
exists <- doesFileExist cFile
when (exists && C.debug opts) $ do putStrLn("Found matching C file (" ++ makeRelative (srcDir paths) cFile
let doStub = exists && C.autostub opts
when (doStub && C.debug opts) $ do putStrLn("Found matching C file (" ++ makeRelative (srcDir paths) cFile
++ "), assuming stub compilation for " ++ makeRelative (srcDir paths) srcfile)
return ((takeFileName srcfile) == "__builtin__.act" || C.stub opts || exists)
return ((takeFileName srcfile) == "__builtin__.act" || C.stub opts || doStub)
where cFile = replaceExtension srcfile ".c"


Expand Down

0 comments on commit 58d2ac7

Please sign in to comment.