-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implements makefile generator and the
--run
option (#61)
* implements makefile generator and the `--run` option * install make for windows * fixes syntax * pass CC as parameters * progress * implements opt:speed and opt:size * improve tests * test cpp * adds docs * fixes * improve * cut extccomp to the bone * remove extccomp * simplifiy * typo
- Loading branch information
Showing
11 changed files
with
179 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import std/[os, strformat] | ||
import noptions | ||
|
||
proc generateMakefile*(s: State, path: string; moduleNames: seq[string]; app: string; nifcache: string; compileOption: string) = | ||
var h = open(path, fmWrite) | ||
var makefileContent = "program:" | ||
var programBody = "" | ||
var objectBody = "" | ||
let cc = | ||
case s.config.backend | ||
of backendC: | ||
"$(CC)" | ||
of backendCpp: | ||
"$(CXX)" | ||
else: | ||
quit "unreachable" | ||
let cflags = | ||
case s.config.backend | ||
of backendC: | ||
"$(CFLAGS)" | ||
of backendCpp: | ||
"$(CXXFLAGS)" | ||
else: | ||
quit "unreachable" | ||
for i in 0..<moduleNames.len: | ||
makefileContent.add " " & moduleNames[i] & ".o" | ||
programBody.add " " & nifcache / moduleNames[i] & ".o" | ||
objectBody.add &"{moduleNames[i]}.o:\n {cc} {cflags} -c " & | ||
nifcache / moduleNames[i] & ".c -o " & | ||
nifcache / moduleNames[i] & ".o\n" | ||
|
||
makefileContent.add &"\n {cc} -o " & app & programBody & "\n\n" & objectBody | ||
|
||
h.write(makefileContent) | ||
h.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
type | ||
Backend* = enum | ||
backendInvalid = "" # for parseEnum | ||
backendC = "c" | ||
backendCpp = "cpp" | ||
|
||
Option* = enum | ||
optOptimizeSpeed, optOptimizeSize | ||
|
||
SystemCC* = enum | ||
ccNone, ccGcc, ccCLang | ||
|
||
ConfigRef* {.acyclic.} = ref object ## every global configuration | ||
cCompiler*: SystemCC | ||
backend*: Backend | ||
options*: set[Option] | ||
|
||
State* = object | ||
selects*: seq[string] # names of modules with functions with selectany pragmas | ||
config*: ConfigRef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters