From c359cc0226effd3b3dc47af74defb6b6b7bc7bca Mon Sep 17 00:00:00 2001 From: Ganesh Viswanathan Date: Tue, 16 Jun 2020 20:41:32 -0500 Subject: [PATCH] Fix lib copy issue --- nimterop/build.nim | 20 +++++++++++++++++--- nimterop/conan.nim | 2 ++ tests/getheader.nims | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/nimterop/build.nim b/nimterop/build.nim index 6cb497d..b5cdc59 100644 --- a/nimterop/build.nim +++ b/nimterop/build.nim @@ -252,6 +252,17 @@ proc getFileDate*(fullpath: string): string = (result, ret) = execAction(cmd) +proc touchFile*(fullpath: string) = + ## Touch file to update modified date + var + cmd = + when defined(Windows): + &"cmd /c copy /b {fullpath.sanitizePath}+" + else: + &"touch {fullpath.sanitizePath}" + + discard execAction(cmd) + proc getProjectCacheDir*(name: string, forceClean = true): string = ## Get a cache directory where all nimterop artifacts can be stored ## @@ -1367,19 +1378,22 @@ macro getHeader*( `ldeps`* = block: var ldeps = ldeps + copied: seq[string] for i in 0 ..< ldeps.len: let lname = ldeps[i].extractFilenameStatic() ldeptgt = joinPathStatic(`libdir`, lname) - if not fileExists(ldeptgt) or getFileDate(ldeps[i]) > getFileDate(ldeptgt): - echo "# Copying " & lname & " to " & `libdir` + if not fileExists(ldeptgt) or getFileDate(ldeps[i]) != getFileDate(ldeptgt): cpFile(ldeps[i], ldeptgt, psymlink = true) + copied.add lname ldeps[i] = ldeptgt + if copied.len != 0: + echo "# Copying dependencies: " & copied.join(" ") & "\n# to " & `libdir` ldeps static: # Copy shared libraries and dependencies to `libdir` - if not fileExists(`lpath`) or getFileDate(lpath) > getFileDate(`lpath`): + if not fileExists(`lpath`) or getFileDate(lpath) != getFileDate(`lpath`): echo "# Copying " & `lpath`.extractFilenameStatic() & " to " & `libdir` cpFile(lpath, `lpath`) diff --git a/nimterop/conan.nim b/nimterop/conan.nim index f8740d0..fcb0495 100644 --- a/nimterop/conan.nim +++ b/nimterop/conan.nim @@ -346,6 +346,8 @@ proc downloadConan*(pkg: ConanPackage, outdir: string, clean = true) = elif clean: cleanDir(outdir) + echo &"# Downloading {pkg.name} v{pkg.version} from Conan" + pkg.getConanBuilds() doAssert pkg.recipes.len != 0, &"Failed to download {pkg.name} v{pkg.version} from Conan - check https://conan.io/center" diff --git a/tests/getheader.nims b/tests/getheader.nims index 1d0ba1d..7a3c176 100644 --- a/tests/getheader.nims +++ b/tests/getheader.nims @@ -40,6 +40,7 @@ when defined(posix): # conan static testCall(cmd & " -d:libssh2Conan -d:libssh2SetVer=1.9.0 -d:libssh2Static" & sshcmd, zexp, 0) +<<<<<<< HEAD else: # conan static for Windows testCall(cmd & " -d:zlibConan -d:zlibSetVer=1.2.11 -d:zlibStatic" & zrcmd, zexp, 0) @@ -48,6 +49,8 @@ else: testCall(cmd & " -d:libssh2JBB -d:libssh2SetVer=1.9.0" & sshcmd, zexp, 0) testCall(cmd & " -d:zlibJBB -d:zlibSetVer=1.2.11" & zrcmd, zexp, 0) testCall(cmd & " -d:zlibJBB -d:zlibSetVer=1.2.11 -d:zlibStatic" & zrcmd, zexp, 0) +======= +>>>>>>> c35eb74... Add tests for conan, recurse implies preprocess # git testCall(cmd & " -d:envTest" & zrcmd, zexp, 0)