Implemented 'backend' option.
This commit is contained in:
parent
4bfbc1aeff
commit
2a8d3082d4
3 changed files with 16 additions and 2 deletions
|
|
@ -211,8 +211,10 @@ proc buildFromDir(pkgInfo: TPackageInfo, paths: seq[string]) =
|
||||||
var args = ""
|
var args = ""
|
||||||
for path in paths: args.add("--path:" & path & " ")
|
for path in paths: args.add("--path:" & path & " ")
|
||||||
for bin in pkgInfo.bin:
|
for bin in pkgInfo.bin:
|
||||||
echo("Building ", pkginfo.name, "/", bin, "...")
|
echo("Building ", pkginfo.name, "/", bin, " using ", pkgInfo.backend,
|
||||||
doCmd("nimrod c -d:release " & args & realDir / bin.changeFileExt("nim"))
|
" backend...")
|
||||||
|
doCmd("nimrod $# -d:release $#" %
|
||||||
|
[pkgInfo.backend, args & realDir / bin.changeFileExt("nim")])
|
||||||
|
|
||||||
proc installFromDir(dir: string, latest: bool): string =
|
proc installFromDir(dir: string, latest: bool): string =
|
||||||
## Returns where package has been installed to.
|
## Returns where package has been installed to.
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ type
|
||||||
requires*: seq[tuple[name: string, ver: PVersionRange]]
|
requires*: seq[tuple[name: string, ver: PVersionRange]]
|
||||||
bin*: seq[string]
|
bin*: seq[string]
|
||||||
srcDir*: string
|
srcDir*: string
|
||||||
|
backend*: string
|
||||||
|
|
||||||
TPackage* = object
|
TPackage* = object
|
||||||
name*: string
|
name*: string
|
||||||
|
|
@ -46,6 +47,7 @@ proc initPackageInfo(): TPackageInfo =
|
||||||
result.requires = @[]
|
result.requires = @[]
|
||||||
result.bin = @[]
|
result.bin = @[]
|
||||||
result.srcDir = ""
|
result.srcDir = ""
|
||||||
|
result.backend = "c"
|
||||||
|
|
||||||
proc validatePackageInfo(pkgInfo: TPackageInfo, path: string) =
|
proc validatePackageInfo(pkgInfo: TPackageInfo, path: string) =
|
||||||
if pkgInfo.name == "":
|
if pkgInfo.name == "":
|
||||||
|
|
@ -58,6 +60,8 @@ proc validatePackageInfo(pkgInfo: TPackageInfo, path: string) =
|
||||||
quit("Incorrect .babel file: " & path & " does not contain a description field.")
|
quit("Incorrect .babel file: " & path & " does not contain a description field.")
|
||||||
if pkgInfo.license == "":
|
if pkgInfo.license == "":
|
||||||
quit("Incorrect .babel file: " & path & " does not contain a license field.")
|
quit("Incorrect .babel file: " & path & " does not contain a license field.")
|
||||||
|
if pkgInfo.backend notin ["c", "cc", "objc", "cpp", "js"]:
|
||||||
|
raise newException(EBabel, "'" & pkgInfo.backend & "' is an invalid backend.")
|
||||||
|
|
||||||
proc parseRequires(req: string): tuple[name: string, ver: PVersionRange] =
|
proc parseRequires(req: string): tuple[name: string, ver: PVersionRange] =
|
||||||
try:
|
try:
|
||||||
|
|
@ -111,6 +115,10 @@ proc readPackageInfo*(path: string): TPackageInfo =
|
||||||
of "bin":
|
of "bin":
|
||||||
for i in ev.value.split(','):
|
for i in ev.value.split(','):
|
||||||
result.bin.add(i.addFileExt(ExeExt))
|
result.bin.add(i.addFileExt(ExeExt))
|
||||||
|
of "backend":
|
||||||
|
result.backend = ev.value.toLower()
|
||||||
|
case result.backend.normalize
|
||||||
|
of "javascript": result.backend = "js"
|
||||||
else:
|
else:
|
||||||
quit("Invalid field: " & ev.key, QuitFailure)
|
quit("Invalid field: " & ev.key, QuitFailure)
|
||||||
of "deps", "dependencies":
|
of "deps", "dependencies":
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,10 @@ the package after checking out the latest version.
|
||||||
* ``bin`` - A list of files which should be built separated by commas with
|
* ``bin`` - A list of files which should be built separated by commas with
|
||||||
no file extension required. This option turns your package into a *binary
|
no file extension required. This option turns your package into a *binary
|
||||||
package*, babel will build the files specified and install them appropriately.
|
package*, babel will build the files specified and install them appropriately.
|
||||||
|
* ``backend`` - Specifies the backend which will be used to build the files
|
||||||
|
listed in ``bin``. Possible values include: ``c``, ``cc``, ``cpp``, ``objc``,
|
||||||
|
``js``.
|
||||||
|
**Default**: c
|
||||||
|
|
||||||
### [Deps]/[Dependencies]
|
### [Deps]/[Dependencies]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue