diff --git a/nimterop/conan.nim b/nimterop/conan.nim index ee74141..cc060f8 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) =