-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test Build nimble with
-d:nimNimbleBootstrap
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import std/[os, uri, strformat] | ||
import std/private/gitutils | ||
|
||
when defined(nimPreviewSlimSystem): | ||
import std/assertions | ||
|
||
proc exec(cmd: string) = | ||
echo "deps.cmd: " & cmd | ||
let status = execShellCmd(cmd) | ||
doAssert status == 0, cmd | ||
|
||
proc execRetry(cmd: string) = | ||
let ok = retryCall(call = block: | ||
let status = execShellCmd(cmd) | ||
let result = status == 0 | ||
if not result: | ||
echo fmt"failed command: '{cmd}', status: {status}" | ||
result) | ||
doAssert ok, cmd | ||
|
||
proc cloneDependency(destDirBase: string, url: string, commit = commitHead, | ||
appendRepoName = true) = | ||
let destDirBase = destDirBase.absolutePath | ||
let p = url.parseUri.path | ||
let name = p.splitFile.name | ||
var destDir = destDirBase | ||
if appendRepoName: destDir = destDir / name | ||
let quotedDestDir = destDir.quoteShell | ||
if not dirExists(destDir): | ||
# note: old code used `destDir / .git` but that wouldn't prevent git clone | ||
# from failing | ||
execRetry fmt"git clone -q {url} {quotedDestDir}" | ||
if isGitRepo(destDir): | ||
let oldDir = getCurrentDir() | ||
setCurrentDir(destDir) | ||
try: | ||
execRetry "git fetch -q" | ||
exec fmt"git checkout -q {commit}" | ||
finally: | ||
setCurrentDir(oldDir) | ||
else: | ||
quit "FAILURE: " & destdir & " already exists but is not a git repo" | ||
|
||
proc command = | ||
const distDir = "dist" | ||
const commit = "3fa15df7d27ecef624ed932d60f63d6a8949618d" | ||
cloneDependency(distDir, "https://github.com/nim-lang/checksums.git", commit) | ||
|
||
command() |