Merge branch 'master' into araq-compiler-api2
This commit is contained in:
commit
9c81e28343
15 changed files with 141 additions and 119 deletions
40
src/nimblepkg/common.nim
Normal file
40
src/nimblepkg/common.nim
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# BSD License. Look at license.txt for more info.
|
||||
#
|
||||
# Various miscellaneous common types reside here, to avoid problems with
|
||||
# recursive imports
|
||||
|
||||
when not defined(nimscript):
|
||||
import sets
|
||||
|
||||
import version
|
||||
export version.NimbleError
|
||||
|
||||
type
|
||||
BuildFailed* = object of NimbleError
|
||||
|
||||
PackageInfo* = object
|
||||
mypath*: string ## The path of this .nimble file
|
||||
isNimScript*: bool ## Determines if this pkg info was read from a nims file
|
||||
isMinimal*: bool
|
||||
isInstalled*: bool ## Determines if the pkg this info belongs to is installed
|
||||
postHooks*: HashSet[string] ## Useful to know so that Nimble doesn't execHook unnecessarily
|
||||
preHooks*: HashSet[string]
|
||||
name*: string
|
||||
version*: string
|
||||
author*: string
|
||||
description*: string
|
||||
license*: string
|
||||
skipDirs*: seq[string]
|
||||
skipFiles*: seq[string]
|
||||
skipExt*: seq[string]
|
||||
installDirs*: seq[string]
|
||||
installFiles*: seq[string]
|
||||
installExt*: seq[string]
|
||||
requires*: seq[PkgTuple]
|
||||
bin*: seq[string]
|
||||
binDir*: string
|
||||
srcDir*: string
|
||||
backend*: string
|
||||
|
||||
const
|
||||
nimbleVersion* = "0.7.10"
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
# BSD License. Look at license.txt for more info.
|
||||
import parsecfg, streams, strutils, os, tables, Uri
|
||||
|
||||
import tools, version, nimbletypes
|
||||
import tools, version, common
|
||||
|
||||
type
|
||||
Config* = object
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import parseutils, os, osproc, strutils, tables, pegs
|
||||
|
||||
import packageinfo, packageparser, version, tools, nimbletypes, options
|
||||
import packageinfo, packageparser, version, tools, common, options
|
||||
|
||||
type
|
||||
DownloadMethod* {.pure.} = enum
|
||||
|
|
@ -174,13 +174,10 @@ proc doDownload*(url: string, downloadDir: string, verRange: VersionRange,
|
|||
if verRange.spe == newSpecial(getHeadName(downMethod)):
|
||||
doClone(downMethod, url, downloadDir) # Grab HEAD.
|
||||
else:
|
||||
# Mercurial requies a clone and checkout. The git clone operation is
|
||||
# already fragmented into multiple steps so we just call doClone().
|
||||
if downMethod == DownloadMethod.git:
|
||||
doClone(downMethod, url, downloadDir, $verRange.spe)
|
||||
else:
|
||||
doClone(downMethod, url, downloadDir, tip = false)
|
||||
doCheckout(downMethod, downloadDir, $verRange.spe)
|
||||
# Grab the full repo.
|
||||
doClone(downMethod, url, downloadDir, tip = false)
|
||||
# Then perform a checkout operation to get the specified branch/commit.
|
||||
doCheckout(downMethod, downloadDir, $verRange.spe)
|
||||
result = verRange
|
||||
else:
|
||||
case downMethod
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
# BSD License. Look at license.txt for more info.
|
||||
#
|
||||
# Various miscellaneous common types reside here, to avoid problems with
|
||||
# recursive imports
|
||||
|
||||
import sets
|
||||
|
||||
import version
|
||||
export version.NimbleError
|
||||
|
||||
type
|
||||
BuildFailed* = object of NimbleError
|
||||
|
||||
PackageInfo* = object
|
||||
mypath*: string ## The path of this .nimble file
|
||||
isNimScript*: bool ## Determines if this pkg info was read from a nims file
|
||||
isMinimal*: bool
|
||||
isInstalled*: bool ## Determines if the pkg this info belongs to is installed
|
||||
postHooks*: HashSet[string] ## Useful to know so that Nimble doesn't execHook unnecessarily
|
||||
preHooks*: HashSet[string]
|
||||
name*: string
|
||||
version*: string
|
||||
author*: string
|
||||
description*: string
|
||||
license*: string
|
||||
skipDirs*: seq[string]
|
||||
skipFiles*: seq[string]
|
||||
skipExt*: seq[string]
|
||||
installDirs*: seq[string]
|
||||
installFiles*: seq[string]
|
||||
installExt*: seq[string]
|
||||
requires*: seq[PkgTuple]
|
||||
bin*: seq[string]
|
||||
binDir*: string
|
||||
srcDir*: string
|
||||
backend*: string
|
||||
|
|
@ -8,13 +8,14 @@ import
|
|||
compiler/ast, compiler/modules, compiler/passes, compiler/passaux,
|
||||
compiler/condsyms, compiler/sem, compiler/semdata,
|
||||
compiler/llstream, compiler/vm, compiler/vmdef, compiler/commands,
|
||||
compiler/msgs, compiler/magicsys, compiler/lists, compiler/idents
|
||||
compiler/msgs, compiler/magicsys, compiler/lists, compiler/idents,
|
||||
compiler/nimconf
|
||||
|
||||
from compiler/scriptconfig import setupVM
|
||||
from compiler/astalgo import strTableGet
|
||||
import compiler/options as compiler_options
|
||||
|
||||
import nimbletypes, version, options, packageinfo
|
||||
import common, version, options, packageinfo
|
||||
import os, strutils, strtabs, times, osproc, sets
|
||||
|
||||
type
|
||||
|
|
@ -27,6 +28,7 @@ type
|
|||
|
||||
const
|
||||
internalCmd = "NimbleInternal"
|
||||
nimscriptApi = staticRead("nimscriptapi.nim")
|
||||
|
||||
proc raiseVariableError(ident, typ: string) {.noinline.} =
|
||||
raise newException(NimbleError,
|
||||
|
|
@ -178,24 +180,20 @@ proc setupVM(module: PSym; scriptName: string,
|
|||
flags[a.getString 0] = a.getString 1
|
||||
|
||||
proc findNimscriptApi(options: Options): string =
|
||||
## Returns the directory containing ``nimscriptapi.nim``
|
||||
var inPath = false
|
||||
## Returns the directory containing ``nimscriptapi.nim`` or an empty string
|
||||
## if it cannot be found.
|
||||
result = ""
|
||||
# Try finding it in exe's path
|
||||
if fileExists(getAppDir() / "nimblepkg" / "nimscriptapi.nim"):
|
||||
result = getAppDir()
|
||||
inPath = true
|
||||
|
||||
if not inPath:
|
||||
if result.len == 0:
|
||||
let pkgs = getInstalledPkgsMin(options.getPkgsDir(), options)
|
||||
var pkg: PackageInfo
|
||||
if pkgs.findPkg(("nimble", newVRAny()), pkg):
|
||||
let pkgDir = pkg.getRealDir()
|
||||
if fileExists(pkgDir / "nimblepkg" / "nimscriptapi.nim"):
|
||||
result = pkgDir
|
||||
inPath = true
|
||||
|
||||
if not inPath:
|
||||
raise newException(NimbleError, "Cannot find nimscriptapi.nim")
|
||||
|
||||
proc getNimPrefixDir(): string = splitPath(findExe("nim")).head.parentDir
|
||||
|
||||
|
|
@ -213,12 +211,20 @@ proc execScript(scriptName: string, flags: StringTableRef, options: Options) =
|
|||
|
||||
# Ensure that "nimblepkg/nimscriptapi" is in the PATH.
|
||||
let nimscriptApiPath = findNimscriptApi(options)
|
||||
appendStr(searchPaths, nimscriptApiPath)
|
||||
if nimscriptApiPath.len > 0:
|
||||
# TODO: Once better output is implemented show a message here.
|
||||
appendStr(searchPaths, nimscriptApiPath)
|
||||
else:
|
||||
let tmpNimscriptApiPath = getTempDir() / "nimblepkg" / "nimscriptapi.nim"
|
||||
createDir(tmpNimscriptApiPath.splitFile.dir)
|
||||
if not existsFile(tmpNimscriptApiPath):
|
||||
writeFile(tmpNimscriptApiPath, nimscriptApi)
|
||||
appendStr(searchPaths, getTempDir())
|
||||
|
||||
setDefaultLibpath()
|
||||
initDefines()
|
||||
loadConfigs(DefaultConfig)
|
||||
passes.gIncludeFile = includeModule
|
||||
passes.gImportModule = importModule
|
||||
initDefines()
|
||||
|
||||
defineSymbol("nimscript")
|
||||
defineSymbol("nimconfig")
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import json, strutils, os, parseopt, strtabs, uri, tables
|
||||
from httpclient import Proxy, newProxy
|
||||
|
||||
import config, version, tools, nimbletypes
|
||||
import config, version, tools, common
|
||||
|
||||
type
|
||||
Options* = object
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright (C) Dominik Picheta. All rights reserved.
|
||||
# BSD License. Look at license.txt for more info.
|
||||
import parsecfg, json, streams, strutils, parseutils, os, sets, tables
|
||||
import version, tools, nimbletypes, options
|
||||
import version, tools, common, options
|
||||
|
||||
type
|
||||
Package* = object
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright (C) Dominik Picheta. All rights reserved.
|
||||
# BSD License. Look at license.txt for more info.
|
||||
import parsecfg, json, streams, strutils, parseutils, os, tables
|
||||
import version, tools, nimbletypes, nimscriptsupport, options, packageinfo
|
||||
import version, tools, common, nimscriptsupport, options, packageinfo
|
||||
|
||||
## Contains procedures for parsing .nimble files. Moved here from ``packageinfo``
|
||||
## because it depends on ``nimscriptsupport`` (``nimscriptsupport`` also
|
||||
|
|
@ -250,7 +250,7 @@ proc getInstalledPkgs*(libsDir: string, options: Options):
|
|||
if nimbleFile != "":
|
||||
let meta = readMetaData(path)
|
||||
try:
|
||||
var pkg = readPackageInfo(nimbleFile, options, true)
|
||||
var pkg = readPackageInfo(nimbleFile, options, onlyMinimalInfo=false)
|
||||
pkg.isInstalled = true
|
||||
result.add((pkg, meta))
|
||||
except ValidationError:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
## nim-lang/packages automatically.
|
||||
|
||||
import httpclient, base64, strutils, rdstdin, json, os, browsers, times, uri
|
||||
import tools, nimbletypes
|
||||
import tools, common
|
||||
|
||||
type
|
||||
Auth = object
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
# Various miscellaneous utility functions reside here.
|
||||
import osproc, pegs, strutils, os, uri, sets, json, parseutils
|
||||
import version, packageinfo, nimbletypes
|
||||
import version, packageinfo, common
|
||||
|
||||
proc extractBin(cmd: string): string =
|
||||
if cmd[0] == '"':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue