-- | A hacky way to automatically compile the C
-- code using GCC, assumes the RTS is in ~/.c_of_scheme/
compileC :: [CExtDecl] -> IO ()
compileC code = do
  UserEntry{homeDirectory = hd} <- getRealUserID >>= getUserEntryForID
  let cFile = "out.c"
      cBits = hd ++ "/.c_of_scheme/"
      rts   = cBits ++ "rts.c"
      gc    = cBits ++ "gc.c"
  writeFile cFile (renderC code)
  output <- system $ "gcc -g -I" ++ unwords [cBits, cFile, rts, gc] ++ "  `pkg-config --cflags --libs glib-2.0`"
  print output -- Prints ExitSuccess or failure, the only output of the compiler ATM (usability!)

-- | The IO part of the compiler, handling loading and parsing files
-- and joining together all the compilation glue of compileScheme and friends
compileC :: [CExtDecl] -> IO ()
compileC code = do
  UserEntry{homeDirectory = hd} <- getRealUserID >>= getUserEntryForID
  let cFile = "out.c"
      cBits = hd ++ "/.c_of_scheme/"
      rts   = cBits ++ "rts.c"
      gc    = cBits ++ "gc.c"
  writeFile cFile (renderC code)
  output <- system $ "gcc -g -I" ++ unwords [cBits, cFile, rts, gc] ++ "  `pkg-config --cflags --libs glib-2.0`"
  print output -- Prints ExitSuccess or failure, the only output of the compiler ATM (usability!)

-- | The IO part of the compiler, handling loading and parsing files
-- and joining together all the compilation glue of compileScheme and friends
compileC code = do
  UserEntry{homeDirectory = hd} <- getRealUserID >>= getUserEntryForID
  let cFile = "out.c"
      cBits = hd ++ "/.c_of_scheme/"
      rts   = cBits ++ "rts.c"
      gc    = cBits ++ "gc.c"
  writeFile cFile (renderC code)
  output <- system $ "gcc -g -I" ++ unwords [cBits, cFile, rts, gc] ++ "  `pkg-config --cflags --libs glib-2.0`"
  print output -- Prints ExitSuccess or failure, the only output of the compiler ATM (usability!)

-- | The IO part of the compiler, handling loading and parsing files
-- and joining together all the compilation glue of compileScheme and friends