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

View file

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

View file

@ -1,11 +1,13 @@
# Babel # Babel
Babel is a work in progress package manager for Nimrod. 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 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 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. 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 ## Contribution
If you would like to help, feel free to fork and make any additions you see If you would like to help, feel free to fork and make any additions you see