Skip to content

Commit

Permalink
Add option to compile to obj file
Browse files Browse the repository at this point in the history
  • Loading branch information
vyPal committed Jan 4, 2024
1 parent 19f57f0 commit 9bbbaa6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions example/src/use_externally.cffc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package external;

extern vararg func printf(fmt: *i8): i32;

export func testing(): i64 {
printf("Hello, World!\n");
return 0;
}
11 changes: 10 additions & 1 deletion src/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func init() {
Usage: "Save additional build files for debugging. ",
Aliases: []string{"d"},
},
&cli.BoolFlag{
Name: "obj",
Usage: "Compile to an object file instead of an executable. ",
},
},
Action: build,
},
Expand Down Expand Up @@ -156,7 +160,12 @@ func build(c *cli.Context) error {

var stderr bytes.Buffer

args := append([]string{"clang", llData}, imports...)
extra := ""
if c.Bool("obj") {
extra = "-c"
}

args := append([]string{"clang", extra, llData}, imports...)
args = append(args, "-o", outName)
cmd := exec.Command(args[0], args[1:]...)

Expand Down

0 comments on commit 9bbbaa6

Please sign in to comment.