Version isn't appended to the package folder name in lib/ anymore, the .babel file is copied too.
This commit is contained in:
parent
6da098b46c
commit
7620271015
2 changed files with 27 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import parser, version, osproc, strutils, re, os, parseutils
|
import "babel/parser", "babel/version", osproc, strutils, re, os, parseutils
|
||||||
|
|
||||||
type
|
type
|
||||||
EInstall = object of EBase
|
EInstall = object of EBase
|
||||||
|
|
@ -37,10 +37,15 @@ proc dependExists(name: string, verRange: PVersionRange): Bool =
|
||||||
for kind, path in walkDir(getBabelDir() / "lib"):
|
for kind, path in walkDir(getBabelDir() / "lib"):
|
||||||
if kind == pcDir:
|
if kind == pcDir:
|
||||||
var dir = path.extractFilename()
|
var dir = path.extractFilename()
|
||||||
if dir.startsWith(name):
|
if dir == name:
|
||||||
var ver = copy(dir, name.len() + 1)
|
var conf = parseBabel(path / dir.addFileExt(".babel"))
|
||||||
if withinRange(newVersion(ver), verRange):
|
var verRet = conf.verify()
|
||||||
return True
|
if verRet == "":
|
||||||
|
if withinRange(newVersion(conf.version), verRange):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
raise newException(EInstall, "Package has an invalid .babel file: " &
|
||||||
|
verRet)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -75,13 +80,14 @@ proc createDirs(dirs: seq[string]) =
|
||||||
|
|
||||||
proc copyFiles(proj: TProject) =
|
proc copyFiles(proj: TProject) =
|
||||||
# This will create a $home/.babel and lib/ or bin/. It will also copy all the
|
# This will create a $home/.babel and lib/ or bin/. It will also copy all the
|
||||||
# files listed in proj.modules and proj.files.
|
# files listed in proj.modules and proj.files and the .babel file.
|
||||||
var babelDir = getBabelDir()
|
var babelDir = getBabelDir()
|
||||||
|
|
||||||
var dirs = @[babelDir, babelDir / "lib", babelDir / "bin"]
|
var dirs = @[babelDir, babelDir / "lib", babelDir / "bin"]
|
||||||
|
|
||||||
if proj.library:
|
if proj.library:
|
||||||
var projDir = babelDir / "lib" / (proj.name & "-" & proj.version)
|
# TODO: How will we handle multiple versions?
|
||||||
|
var projDir = babelDir / "lib" / proj.name # $babel/lib/name
|
||||||
dirs.add(projDir)
|
dirs.add(projDir)
|
||||||
createDirs(dirs)
|
createDirs(dirs)
|
||||||
# Copy the files
|
# Copy the files
|
||||||
|
|
@ -95,6 +101,12 @@ proc copyFiles(proj: TProject) =
|
||||||
copyFile(i, projDir / i)
|
copyFile(i, projDir / i)
|
||||||
echo(" Done!")
|
echo(" Done!")
|
||||||
|
|
||||||
|
# Copy the .babel file.
|
||||||
|
var babelFile = proj.name.addFileExt("babel")
|
||||||
|
stdout.write("Copying " & babelFile & "...")
|
||||||
|
copyFile(babelFile, projDir / babelFile)
|
||||||
|
echo(" Done!")
|
||||||
|
|
||||||
elif proj.executable:
|
elif proj.executable:
|
||||||
# TODO: Copy files for executable.
|
# TODO: Copy files for executable.
|
||||||
assert(false)
|
assert(false)
|
||||||
|
|
@ -135,4 +147,4 @@ proc install*(name: string, filename: string = "") =
|
||||||
echo("Package " & name & " successfully installed.")
|
echo("Package " & name & " successfully installed.")
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
install("babel")
|
install(paramStr(1))
|
||||||
|
|
|
||||||
11
parser.nim
11
parser.nim
|
|
@ -1,4 +1,4 @@
|
||||||
import parsecfg, streams, strutils, version
|
import parsecfg, streams, strutils
|
||||||
|
|
||||||
type
|
type
|
||||||
TProject* = object
|
TProject* = object
|
||||||
|
|
@ -16,6 +16,7 @@ type
|
||||||
files*: seq[string] # files
|
files*: seq[string] # files
|
||||||
|
|
||||||
executable*: bool
|
executable*: bool
|
||||||
|
exeFile*: string
|
||||||
|
|
||||||
unknownFields*: seq[string] # TODO:
|
unknownFields*: seq[string] # TODO:
|
||||||
|
|
||||||
|
|
@ -91,12 +92,14 @@ proc parseBabel*(file: string): TProject =
|
||||||
result.modules = e.value.parseList()
|
result.modules = e.value.parseList()
|
||||||
else:
|
else:
|
||||||
p.parseErr("Unknown key: " & e.key)
|
p.parseErr("Unknown key: " & e.key)
|
||||||
of "executable":
|
of "exe":
|
||||||
case normalize(e.key)
|
case normalize(e.key)
|
||||||
of "depends":
|
of "depends":
|
||||||
result.depends = e.value.parseList()
|
result.depends = e.value.parseList()
|
||||||
of "extrafiles":
|
of "files":
|
||||||
result.files = e.value.parseList()
|
result.files = e.value.parseList()
|
||||||
|
of "exe":
|
||||||
|
result.exeFile = e.value
|
||||||
else:
|
else:
|
||||||
p.parseErr("Unknown key: " & e.key)
|
p.parseErr("Unknown key: " & e.key)
|
||||||
|
|
||||||
|
|
@ -108,7 +111,7 @@ proc parseBabel*(file: string): TProject =
|
||||||
case normalize(e.section):
|
case normalize(e.section):
|
||||||
of "library":
|
of "library":
|
||||||
result.library = True
|
result.library = True
|
||||||
of "bin":
|
of "exe":
|
||||||
result.executable = True
|
result.executable = True
|
||||||
of "package":
|
of "package":
|
||||||
nil
|
nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue