diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2018-04-11 21:45:53 +0300 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2018-04-11 21:45:53 +0300 |
| commit | ee12442c3872c5c99b4575797410e5f564ef118b (patch) | |
| tree | c881802fbe1942b16735d95e0dc327ad42449716 /src/nimpb_protoc.nim | |
| parent | 641e564c7d231b536e9e44c04c95307fef7cfe06 (diff) | |
| parent | 1e7e3f6b331c2030e908c6aed515ca4d407559f7 (diff) | |
| download | nimpb_protoc-ee12442c3872c5c99b4575797410e5f564ef118b.tar.gz nimpb_protoc-ee12442c3872c5c99b4575797410e5f564ef118b.zip | |
Merge branch 'moving-back-to-nimpb-repo'
Diffstat (limited to 'src/nimpb_protoc.nim')
| -rw-r--r-- | src/nimpb_protoc.nim | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/nimpb_protoc.nim b/src/nimpb_protoc.nim new file mode 100644 index 0000000..951849a --- /dev/null +++ b/src/nimpb_protoc.nim @@ -0,0 +1,50 @@ +import os +import strformat + +when defined(windows): + const compilerId = "win32" +elif defined(linux): + when defined(i386): + const arch = "x86_32" + elif defined(amd64): + const arch = "x86_64" + elif defined(arm64): + const arch = "aarch_64" + else: + {.fatal:"unsupported architecture".} + const compilerId = "linux-" & arch +elif defined(macosx): + when defined(amd64): + const arch = "x86_64" + else: + {.fatal:"unsupported architecture".} + const compilerId = "osx-" & arch +else: + {.fatal:"unsupported platform".} + +when defined(windows): + const exeSuffix = ".exe" +else: + const exeSuffix = "" + +let + paths = @[ + # getAppDir() / "src" / "nimpb_protocpkg" / "protobuf", + # getAppDir() / "nimpb_protocpkg" / "protobuf", + parentDir(currentSourcePath()) / "nimpb_protocpkg" / "protobuf", + ] + +proc getCompilerPath*(): string = + let + compilerName = &"protoc-{compilerId}{exeSuffix}" + + for path in paths: + if fileExists(path / compilerName): + return path / compilerName + + raise newException(Exception, &"{compilerName} not found!") + +proc getProtoIncludeDir*(): string = + for path in paths: + if fileExists(path / "include"): + return path / "include" |
