pas2c is now fully parametric with command line options (maybe unC0Rr needs to clean this up a little)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/Main.hs Sun Nov 04 06:11:39 2012 +0100
@@ -0,0 +1,44 @@
+module Main( main ) where
+
+import System( getArgs )
+import System.Console.GetOpt
+import System.Environment
+import System.Exit
+import System.IO
+import Data.Maybe( fromMaybe )
+import Pas2C
+
+main = do
+ args <- getArgs
+ if length args == 0
+ then do
+ name <- getProgName
+ hPutStrLn stderr $ usageInfo header options
+ exitFailure
+ else do
+ case getOpt RequireOrder options args of
+ (flags, [], []) ->
+ if length args == 8 then do
+ pas2C (args !! 1) ((args !! 3)++"/") ((args !! 5)++"/") ((args !! 7)++"/")
+ else do
+ if length args == 6 then do
+ pas2C (args !! 1) ((args !! 3)++"/") ((args !! 5)++"/") "./"
+ else do
+ error $ usageInfo header options
+ (_, nonOpts, []) -> error $ "unrecognized arguments: " ++ unwords nonOpts
+ (_, _, msgs) -> error $ usageInfo header options
+
+
+data Flag = HelpMessage | Name String | Input String | Output String | Alternate String
+
+options :: [OptDescr Flag]
+options = [
+ Option ['h'] ["help"] (NoArg HelpMessage) "print this help message",
+ Option ['n'] ["name"] (ReqArg Name "MAIN") "name of the main Pascal module",
+ Option ['i'] ["input"] (ReqArg Input "DIR") "input directory, where .pas files will be read",
+ Option ['o'] ["output"] (ReqArg Output "DIR") "output directory, where .c/.h files will be written",
+ Option ['a'] ["alternate"] (ReqArg Alternate "DIR") "alternate input directory, for out of source builds"
+ ]
+
+header = "Freepascal to C conversion!\n"
+
--- a/tools/pas2c.hs Sun Nov 04 03:04:20 2012 +0100
+++ b/tools/pas2c.hs Sun Nov 04 06:11:39 2012 +0100
@@ -1,5 +1,5 @@
{-# LANGUAGE ScopedTypeVariables #-}
-module Main where
+module Pas2C where
import Text.PrettyPrint.HughesPJ
import Data.Maybe
@@ -1083,9 +1083,3 @@
op2C "/" = "/(float)"
op2C a = a
-main = do
- let programName = "hwengine"
- let inputPath = "../hedgewars/"
- let outputPath = "./"
- let alternateInputPath = "./"
- pas2C programName inputPath alternateInputPath outputPath