.babel files are now copied to packages/, fixed some slight errors.

This commit is contained in:
Dominik Picheta 2011-01-28 21:03:51 +00:00
commit 6dda085611
3 changed files with 30 additions and 19 deletions

View file

@ -34,11 +34,11 @@ proc dependExists(name: string, verRange: PVersionRange): Bool =
nimVer & " " & $verRange)
else: return True
else:
for kind, path in walkDir(getBabelDir() / "lib"):
if kind == pcDir:
var dir = path.extractFilename()
if dir == name:
var conf = parseBabel(path / dir.addFileExt(".babel"))
for kind, path in walkDir(getBabelDir() / "packages"):
if kind == pcFile:
var file = path.extractFilename()
if file == name.addFileExt("babel"):
var conf = parseBabel(path)
var verRet = conf.verify()
if verRet == "":
if withinRange(newVersion(conf.version), verRange):
@ -83,7 +83,7 @@ proc copyFiles(proj: TProject) =
# files listed in proj.modules and proj.files and the .babel file.
var babelDir = getBabelDir()
var dirs = @[babelDir, babelDir / "lib", babelDir / "bin"]
var dirs = @[babelDir, babelDir / "lib", babelDir / "bin", babelDir / "packages"]
if proj.library:
# TODO: How will we handle multiple versions?
@ -92,19 +92,21 @@ proc copyFiles(proj: TProject) =
createDirs(dirs)
# Copy the files
for i in items(proj.modules):
stdout.write("Copying " & i.addFileExt("nim") & "...")
copyFile(i.addFileExt("nim"), projDir / i.addFileExt("nim"))
var file = proj.confDir / i.addFileExt("nim")
stdout.write("Copying " & file & "...")
copyFile(file, projDir / i.addFileExt("nim"))
echo(" Done!")
if proj.files.len > 0:
for i in items(proj.files):
stdout.write("Copying " & i.addFileExt("nim") & "...")
copyFile(i, projDir / i)
var file = proj.confDir / i
stdout.write("Copying " & file & "...")
copyFile(file, projDir / i)
echo(" Done!")
# Copy the .babel file.
var babelFile = proj.name.addFileExt("babel")
# Copy the .babel file into the packages folder.
var babelFile = proj.confDir / proj.name.addFileExt("babel")
stdout.write("Copying " & babelFile & "...")
copyFile(babelFile, projDir / babelFile)
copyFile(babelFile, babelDir / "packages" / babelFile)
echo(" Done!")
elif proj.executable:
@ -141,10 +143,10 @@ proc install*(name: string, filename: string = "") =
else:
echo("All dependencies verified!")
echo("Installing " & name & "...")
echo("Installing " & babelFile.name & "...")
babelFile.copyFiles()
echo("Package " & name & " successfully installed.")
echo("Package " & babelFile.name & " successfully installed.")
when isMainModule:
install(paramStr(1))

View file

@ -1,4 +1,4 @@
import parsecfg, streams, strutils
import parsecfg, streams, strutils, os
type
TProject* = object
@ -20,6 +20,8 @@ type
unknownFields*: seq[string] # TODO:
confDir*: string # Directory of the babel file, "" if current work dir.
EParseErr* = object of EInvalidValue
proc initProj(): TProject =
@ -36,9 +38,12 @@ proc initProj(): TProject =
result.depends = @[]
result.modules = @[]
result.files = @[]
result.exeFile = ""
result.unknownFields = @[]
result.confDir = ""
proc parseList(s: string): seq[string] =
result = @[]
var many = s.split({',', ';'})
@ -51,6 +56,8 @@ proc parseErr(p: TCfgParser, msg: string) =
proc parseBabel*(file: string): TProject =
result = initProj()
result.confDir = splitFile(file).dir
var f = newFileStream(file, fmRead)
if f != nil:
var p: TCfgParser

View file

@ -1,11 +1,13 @@
# Babel
Babel is a work in progress package manager for Nimrod.
##Babel's folder structure
## Babel's folder structure
Babel stores everything that has been installed in ~/.babel on Unix systems and
in your $home/babel on Windows. Libraries are installed in lib/ in folders
which names contain both the name and version of the package, the folders
which names contain the name of the package, the folders
contain the modules and any other files that the package wished to install.
Applications are installed into bin/. There is also a packages/ directory which
contains all the packages' .babel files.
## Contribution
If you would like to help, feel free to fork and make any additions you see