diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2020-06-18 14:52:27 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2020-06-18 14:52:27 -0500 |
| commit | cfe78d641a26cf55b3f3b1d8661fc3394e233f21 (patch) | |
| tree | bfd5e919d8a30f9b9f9dacf6f2deb67e316ef79f | |
| parent | 36622e60a4ff111e405458e360e9203e8bd06a3f (diff) | |
| download | nimterop-cfe78d641a26cf55b3f3b1d8661fc3394e233f21.tar.gz nimterop-cfe78d641a26cf55b3f3b1d8661fc3394e233f21.zip | |
Use marshal pre 1.2.0
| -rw-r--r-- | nimterop/conan.nim | 23 | ||||
| -rw-r--r-- | nimterop/jbb.nim | 19 |
2 files changed, 31 insertions, 11 deletions
diff --git a/nimterop/conan.nim b/nimterop/conan.nim index 2f2c65c..41648a3 100644 --- a/nimterop/conan.nim +++ b/nimterop/conan.nim @@ -1,4 +1,9 @@ -import json, os, strformat, strutils, tables +import os, strformat, strutils, tables + +when (NimMajor, NimMinor, NimPatch) < (1, 2, 0): + import marshal +else: + import json type ConanPackage* = ref object @@ -272,10 +277,13 @@ proc loadConanInfo*(outdir: string): ConanPackage = file = outdir / conanInfo if fileExists(file): - try: - result = to(readFile(file).parseJson(), ConanPackage) - except: - discard + when (NimMajor, NimMinor, NimPatch) < (1, 2, 0): + result = to[ConanPackage](readFile(file)) + else: + try: + result = to(readFile(file).parseJson(), ConanPackage) + except: + discard proc saveConanInfo*(pkg: ConanPackage, outdir: string) = ## Save downloaded package info to `outdir/conaninfo.json` @@ -283,7 +291,10 @@ proc saveConanInfo*(pkg: ConanPackage, outdir: string) = let file = outdir / conanInfo - writeFile(file, $(%pkg)) + when (NimMajor, NimMinor, NimPatch) < (1, 2, 0): + writeFile(file, $$pkg) + else: + writeFile(file, $(%pkg)) proc parseConanManifest(pkg: ConanPackage, outdir: string) = # Get all library info from downloaded conan package diff --git a/nimterop/jbb.nim b/nimterop/jbb.nim index b5e66fb..c282197 100644 --- a/nimterop/jbb.nim +++ b/nimterop/jbb.nim @@ -1,5 +1,8 @@ import json, os, strutils +when (NimMajor, NimMinor, NimPatch) < (1, 2, 0): + import marshal + type JBBPackage* = ref object ## JBBPackage type that stores package information @@ -143,10 +146,13 @@ proc loadJBBInfo*(outdir: string): JBBPackage = file = outdir / jbbInfo if fileExists(file): - try: - result = to(readFile(file).parseJson(), JBBPackage) - except: - discard + when (NimMajor, NimMinor, NimPatch) < (1, 2, 0): + result = to[JBBPackage](readFile(file)) + else: + try: + result = to(readFile(file).parseJson(), JBBPackage) + except: + discard proc saveJBBInfo*(pkg: JBBPackage, outdir: string) = ## Save downloaded package info to `outdir/jbbinfo.json` @@ -154,7 +160,10 @@ proc saveJBBInfo*(pkg: JBBPackage, outdir: string) = let file = outdir / jbbInfo - writeFile(file, $(%pkg)) + when (NimMajor, NimMinor, NimPatch) < (1, 2, 0): + writeFile(file, $$pkg) + else: + writeFile(file, $(%pkg)) proc dlJBBRequires*(pkg: JBBPackage, outdir: string) proc downloadJBB*(pkg: JBBPackage, outdir: string, main = true) = |
