Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read version from nimble file #60

Merged
merged 9 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion futhark.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.9.1" # Remember to update the version in futhark.nim as well
version = "0.9.1"
author = "PMunch"
description = "A package which uses libclang to parse C headers into Nim files for easy interop"
license = "MIT"
Expand All @@ -15,3 +15,4 @@ requires "nim >= 1.4.8"
requires "https://github.com/PMunch/libclang-nim#head"
requires "termstyle"
requires "macroutils"
requires "https://github.com/PMunch/nimbleutils >= 0.3.0"
16 changes: 15 additions & 1 deletion src/futhark.nim
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import macros, strutils, os, json, tables, sets, sugar, hashes, std/compilesettings, sequtils
import macroutils except Lit
import pkg/nimbleutils

const
Stringable = {nnkStrLit..nnkTripleStrLit, nnkCommentStmt, nnkIdent, nnkSym}
VERSION = "0.9.1"
builtins = ["addr", "and", "as", "asm",
"bind", "block", "break",
"case", "cast", "concept", "const", "continue", "converter",
Expand Down Expand Up @@ -32,6 +32,20 @@ const
futharkRebuild = defined(futharkRebuild) or opirRebuild
preAnsiFuncDecl = defined(preAnsiFuncDecl)
echoForwards = defined(echoForwards)
VERSION = block:
# source style, go up one dir
var nimblePath = currentSourcePath().parentDir().parentDir() / "futhark.nimble"
if not fileExists(nimblePath):
# installed style, nimble file in same dir
nimblePath = currentSourcePath().parentDir() / "futhark.nimble"
if not fileExists(nimblePath):
# try find by name
nimblePath = "futhark"
try:
$getPackage(nimblePath).version
except CatchableError:
warning "Couldn't find futhark version from 'nimble dump " & nimblePath & "'"
"unknown"

template strCmp(node, value: untyped): untyped = node.kind in Stringable and node.strVal == value

Expand Down