aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2019-08-22 14:34:52 -0700
committerGanesh Viswanathan <dev@genotrance.com>2019-08-22 14:34:52 -0700
commitc3734587a174ea2fc7e19943e6d11d024f06e091 (patch)
tree78f3812444047e296eea61aaf25cb3ba9c24f3b6
parent86ebf622e1946225914a02779f9d4c60b63b80ac (diff)
downloadnimterop-c3734587a174ea2fc7e19943e6d11d024f06e091.tar.gz
nimterop-c3734587a174ea2fc7e19943e6d11d024f06e091.zip
rmFile/Dir, build/autogen, check if build command workedv0.1.0
-rw-r--r--nimterop/git.nim36
1 files changed, 32 insertions, 4 deletions
diff --git a/nimterop/git.nim b/nimterop/git.nim
index 443f9a5..72315a6 100644
--- a/nimterop/git.nim
+++ b/nimterop/git.nim
@@ -72,6 +72,25 @@ proc mvFile*(source, dest: string) =
## Move a file from source to destination at compile time
cpFile(source, dest, move=true)
+proc rmFile*(source: string, dir = false) =
+ ## Remove a file or pattern at compile time
+ let
+ source = source.replace("/", $DirSep)
+ cmd =
+ when defined(Windows):
+ if dir:
+ "rd /s/q"
+ else:
+ "del /s/q/f"
+ else:
+ "rm -rf"
+
+ discard execAction(&"{cmd} {source.quoteShell}")
+
+proc rmDir*(source: string) =
+ ## Remove a directory or pattern at compile time
+ rmFile(source, dir = true)
+
proc extractZip*(zipfile, outdir: string) =
## Extract a zip file using powershell on Windows and unzip on other
## systems to the specified output directory
@@ -191,10 +210,13 @@ proc configure*(path, check: string, flags = "") =
echo "# Configuring " & path
if not fileExists(path / "configure"):
- if fileExists(path / "autogen.sh"):
- echo "# Running autogen.sh"
+ for i in @[path / "autogen.sh", path / "build" / "autogen.sh"]:
+ if fileExists(i):
+ echo "# Running autogen.sh"
- discard execAction(&"cd {path.quoteShell} && bash autogen.sh")
+ discard execAction(&"cd {i.parentDir().quoteShell} && bash autogen.sh")
+
+ break
if fileExists(path / "configure"):
echo "# Running configure " & flags
@@ -206,6 +228,8 @@ proc configure*(path, check: string, flags = "") =
echo execAction(cmd)
+ doAssert (path / check).fileExists(), "# Configure failed"
+
proc cmake*(path, check, flags: string) =
## Run the `cmake` command to generate all Makefiles or other
## build scripts in the specified path
@@ -233,6 +257,8 @@ proc cmake*(path, check, flags: string) =
echo execAction(cmd)
+ doAssert (path / check).fileExists(), "# cmake failed"
+
proc make*(path, check: string, flags = "") =
## Run the `make` command to build all binaries in the specified path
##
@@ -263,4 +289,6 @@ proc make*(path, check: string, flags = "") =
if flags.len != 0:
cmd &= &" {flags}"
- echo execAction(cmd) \ No newline at end of file
+ echo execAction(cmd)
+
+ doAssert (path / check).fileExists(), "# make failed"