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 = ""
|
||||
for path in paths: args.add("--path:" & path & " ")
|
||||
for bin in pkgInfo.bin:
|
||||
echo("Building ", pkginfo.name, "/", bin, "...")
|
||||
doCmd("nimrod c -d:release " & args & realDir / bin.changeFileExt("nim"))
|
||||
echo("Building ", pkginfo.name, "/", bin, " using ", pkgInfo.backend,
|
||||
" backend...")
|
||||
doCmd("nimrod $# -d:release $#" %
|
||||
[pkgInfo.backend, args & realDir / bin.changeFileExt("nim")])
|
||||
|
||||
proc installFromDir(dir: string, latest: bool): string =
|
||||
## Returns where package has been installed to.
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ type
|
|||
requires*: seq[tuple[name: string, ver: PVersionRange]]
|
||||
bin*: seq[string]
|
||||
srcDir*: string
|
||||
backend*: string
|
||||
|
||||
TPackage* = object
|
||||
name*: string
|
||||
|
|
@ -46,6 +47,7 @@ proc initPackageInfo(): TPackageInfo =
|
|||
result.requires = @[]
|
||||
result.bin = @[]
|
||||
result.srcDir = ""
|
||||
result.backend = "c"
|
||||
|
||||
proc validatePackageInfo(pkgInfo: TPackageInfo, path: string) =
|
||||
if pkgInfo.name == "":
|
||||
|
|
@ -58,6 +60,8 @@ proc validatePackageInfo(pkgInfo: TPackageInfo, path: string) =
|
|||
quit("Incorrect .babel file: " & path & " does not contain a description field.")
|
||||
if pkgInfo.license == "":
|
||||
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] =
|
||||
try:
|
||||
|
|
@ -111,6 +115,10 @@ proc readPackageInfo*(path: string): TPackageInfo =
|
|||
of "bin":
|
||||
for i in ev.value.split(','):
|
||||
result.bin.add(i.addFileExt(ExeExt))
|
||||
of "backend":
|
||||
result.backend = ev.value.toLower()
|
||||
case result.backend.normalize
|
||||
of "javascript": result.backend = "js"
|
||||
else:
|
||||
quit("Invalid field: " & ev.key, QuitFailure)
|
||||
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
|
||||
no file extension required. This option turns your package into a *binary
|
||||
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]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue