Small refactoring.
This commit is contained in:
parent
788f93a4e7
commit
a5f325f032
2 changed files with 40 additions and 44 deletions
|
|
@ -305,44 +305,6 @@ proc buildFromDir(pkgInfo: PackageInfo, paths: seq[string], forRelease: bool) =
|
||||||
args = @[]
|
args = @[]
|
||||||
buildFromDir(pkgInfo, paths, args)
|
buildFromDir(pkgInfo, paths, args)
|
||||||
|
|
||||||
proc saveNimbleMeta(pkgDestDir, url, vcsRevision: string,
|
|
||||||
filesInstalled, bins: HashSet[string],
|
|
||||||
isLink: bool = false) =
|
|
||||||
## Saves the specified data into a ``nimblemeta.json`` file inside
|
|
||||||
## ``pkgDestDir``.
|
|
||||||
##
|
|
||||||
## filesInstalled - A list of absolute paths to files which have been
|
|
||||||
## installed.
|
|
||||||
## bins - A list of binary filenames which have been installed for this
|
|
||||||
## package.
|
|
||||||
##
|
|
||||||
## isLink - Determines whether the installed package is a .nimble-link.
|
|
||||||
# TODO: Move to packageinstaller.nim
|
|
||||||
var nimblemeta = %{"url": %url}
|
|
||||||
if not vcsRevision.isNil:
|
|
||||||
nimblemeta["vcsRevision"] = %vcsRevision
|
|
||||||
let files = newJArray()
|
|
||||||
nimblemeta["files"] = files
|
|
||||||
for file in filesInstalled:
|
|
||||||
files.add(%changeRoot(pkgDestDir, "", file))
|
|
||||||
let binaries = newJArray()
|
|
||||||
nimblemeta["binaries"] = binaries
|
|
||||||
for bin in bins:
|
|
||||||
binaries.add(%bin)
|
|
||||||
nimblemeta["isLink"] = %isLink
|
|
||||||
writeFile(pkgDestDir / "nimblemeta.json", $nimblemeta)
|
|
||||||
|
|
||||||
proc saveNimbleMeta(pkgDestDir, pkgDir, vcsRevision: string) =
|
|
||||||
## Overload of saveNimbleMeta for linked (.nimble-link) packages.
|
|
||||||
##
|
|
||||||
## pkgDestDir - The directory where the package has been installed.
|
|
||||||
## For example: ~/.nimble/pkgs/jester-#head/
|
|
||||||
##
|
|
||||||
## pkgDir - The directory where the original package files are.
|
|
||||||
## For example: ~/projects/jester/
|
|
||||||
saveNimbleMeta(pkgDestDir, "file://" & pkgDir, vcsRevision,
|
|
||||||
initSet[string](), initSet[string](), true)
|
|
||||||
|
|
||||||
proc removePkgDir(dir: string, options: Options) =
|
proc removePkgDir(dir: string, options: Options) =
|
||||||
## Removes files belonging to the package in ``dir``.
|
## Removes files belonging to the package in ``dir``.
|
||||||
try:
|
try:
|
||||||
|
|
@ -940,9 +902,6 @@ proc developFromDir(dir: string, options: Options) =
|
||||||
let contents = pkgInfo.myPath & "\n" & pkgInfo.getRealDir()
|
let contents = pkgInfo.myPath & "\n" & pkgInfo.getRealDir()
|
||||||
writeFile(pkgDestDir / pkgInfo.name.addFileExt("nimble-link"), contents)
|
writeFile(pkgDestDir / pkgInfo.name.addFileExt("nimble-link"), contents)
|
||||||
|
|
||||||
# TODO: Handle dependencies of the package we are developing (they need to be
|
|
||||||
# installed).
|
|
||||||
|
|
||||||
# Save a nimblemeta.json file.
|
# Save a nimblemeta.json file.
|
||||||
saveNimbleMeta(pkgDestDir, "file://" & dir, vcsRevisionInDir(dir))
|
saveNimbleMeta(pkgDestDir, "file://" & dir, vcsRevisionInDir(dir))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
# Copyright (C) Dominik Picheta. All rights reserved.
|
# Copyright (C) Dominik Picheta. All rights reserved.
|
||||||
# BSD License. Look at license.txt for more info.
|
# BSD License. Look at license.txt for more info.
|
||||||
import os, strutils
|
import os, strutils, sets, json
|
||||||
|
|
||||||
# Local imports
|
# Local imports
|
||||||
import cli, common, options
|
import cli, common, options, tools
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
# This is just for Win XP support.
|
# This is just for Win XP support.
|
||||||
|
|
@ -67,3 +67,40 @@ proc setupBinSymlink*(symlinkDest, symlinkFilename: string,
|
||||||
result.add bashDest.extractFilename
|
result.add bashDest.extractFilename
|
||||||
else:
|
else:
|
||||||
{.error: "Sorry, your platform is not supported.".}
|
{.error: "Sorry, your platform is not supported.".}
|
||||||
|
|
||||||
|
proc saveNimbleMeta*(pkgDestDir, url, vcsRevision: string,
|
||||||
|
filesInstalled, bins: HashSet[string],
|
||||||
|
isLink: bool = false) =
|
||||||
|
## Saves the specified data into a ``nimblemeta.json`` file inside
|
||||||
|
## ``pkgDestDir``.
|
||||||
|
##
|
||||||
|
## filesInstalled - A list of absolute paths to files which have been
|
||||||
|
## installed.
|
||||||
|
## bins - A list of binary filenames which have been installed for this
|
||||||
|
## package.
|
||||||
|
##
|
||||||
|
## isLink - Determines whether the installed package is a .nimble-link.
|
||||||
|
var nimblemeta = %{"url": %url}
|
||||||
|
if not vcsRevision.isNil:
|
||||||
|
nimblemeta["vcsRevision"] = %vcsRevision
|
||||||
|
let files = newJArray()
|
||||||
|
nimblemeta["files"] = files
|
||||||
|
for file in filesInstalled:
|
||||||
|
files.add(%changeRoot(pkgDestDir, "", file))
|
||||||
|
let binaries = newJArray()
|
||||||
|
nimblemeta["binaries"] = binaries
|
||||||
|
for bin in bins:
|
||||||
|
binaries.add(%bin)
|
||||||
|
nimblemeta["isLink"] = %isLink
|
||||||
|
writeFile(pkgDestDir / "nimblemeta.json", $nimblemeta)
|
||||||
|
|
||||||
|
proc saveNimbleMeta*(pkgDestDir, pkgDir, vcsRevision: string) =
|
||||||
|
## Overload of saveNimbleMeta for linked (.nimble-link) packages.
|
||||||
|
##
|
||||||
|
## pkgDestDir - The directory where the package has been installed.
|
||||||
|
## For example: ~/.nimble/pkgs/jester-#head/
|
||||||
|
##
|
||||||
|
## pkgDir - The directory where the original package files are.
|
||||||
|
## For example: ~/projects/jester/
|
||||||
|
saveNimbleMeta(pkgDestDir, "file://" & pkgDir, vcsRevision,
|
||||||
|
initSet[string](), initSet[string](), true)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue