summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/nimrod.nim2
-rw-r--r--compiler/service.nim2
-rw-r--r--compiler/tccgen.nim8
3 files changed, 5 insertions, 7 deletions
diff --git a/compiler/nimrod.nim b/compiler/nimrod.nim
index efe3d83bf..ea7621b09 100644
--- a/compiler/nimrod.nim
+++ b/compiler/nimrod.nim
@@ -58,7 +58,7 @@ proc handleCmdLine() =
     if msgs.gErrorCounter == 0:
       when hasTinyCBackend:
         if gCmd == cmdRun:
-          tccgen.run()
+          tccgen.run(service.arguments)
       if optRun in gGlobalOptions:
         if gCmd == cmdCompileToJS:
           var ex: string
diff --git a/compiler/service.nim b/compiler/service.nim
index 2b861e1c7..eab995276 100644
--- a/compiler/service.nim
+++ b/compiler/service.nim
@@ -59,7 +59,7 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
       inc argsCount
           
   if pass == passCmd2:
-    if optRun notin gGlobalOptions and arguments != "":
+    if optRun notin gGlobalOptions and arguments != "" and options.command != "run":
       rawMessage(errArgsNeedRunOption, [])
 
 proc serve*(action: proc (){.nimcall.}) =
diff --git a/compiler/tccgen.nim b/compiler/tccgen.nim
index 9ed6db8a1..a571d416e 100644
--- a/compiler/tccgen.nim
+++ b/compiler/tccgen.nim
@@ -68,11 +68,9 @@ proc compileCCode*(ccode: string) =
     setupEnvironment()
   discard compileString(gTinyC, ccode)
   
-proc run*() =
-  var a: array[0..1, cstring]
-  a[0] = ""
-  a[1] = ""
-  var err = tinyc.run(gTinyC, 0'i32, cast[cstringArray](addr(a))) != 0'i32
+proc run*(args: string) =
+  var s = @[cstring(gProjectName)] & map(split(args), proc(x: string): cstring = cstring(x))
+  var err = tinyc.run(gTinyC, cint(len(s)), cast[cstringArray](addr(s[0]))) != 0'i32
   closeCCState(gTinyC)
   if err: rawMessage(errExecutionOfProgramFailed, "")