Add getheader test
This commit is contained in:
parent
182d473973
commit
ba2bd6e40a
4 changed files with 99 additions and 12 deletions
|
|
@ -6,13 +6,13 @@ language: c
|
|||
|
||||
env:
|
||||
- BRANCH=0.19.6
|
||||
- BRANCH=0.20.0
|
||||
- BRANCH=0.20.2
|
||||
- BRANCH=devel
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- "$HOME/.choosenim/toolchains/nim-0.19.6"
|
||||
- "$HOME/.choosenim/toolchains/nim-0.20.0"
|
||||
- "$HOME/.choosenim/toolchains/nim-0.20.2"
|
||||
|
||||
install:
|
||||
# `set -u` failed for ubuntu: /home/travis/.travis/job_stages: line 107: secure: unbound variable
|
||||
|
|
|
|||
|
|
@ -13,25 +13,29 @@ when (NimMajor, NimMinor, NimPatch) < (0, 19, 9):
|
|||
type Time {.importc: "time_t", header: "<time.h>".} = distinct int64
|
||||
elif defined(posix):
|
||||
import posix
|
||||
type time_t* = Time
|
||||
type
|
||||
time_t* = Time
|
||||
wchar_t* {.importc.} = object
|
||||
else:
|
||||
import std/time_t as time_t_temp
|
||||
type time_t* = time_t_temp.Time
|
||||
|
||||
when defined(c):
|
||||
# http://www.cplusplus.com/reference/cwchar/wchar_t/
|
||||
# In C++, wchar_t is a distinct fundamental type (and thus it is
|
||||
# not defined in <cwchar> nor any other header).
|
||||
type
|
||||
wchar_t* {.importc, header:"<cwchar>".} = object
|
||||
elif defined(cpp):
|
||||
type
|
||||
wchar_t* {.importc.} = object
|
||||
|
||||
type
|
||||
ptrdiff_t* = ByteAddress
|
||||
|
||||
type
|
||||
va_list* {.importc, header:"<stdarg.h>".} = object
|
||||
|
||||
when defined(c):
|
||||
# http://www.cplusplus.com/reference/cwchar/wchar_t/ In C++, wchar_t is a distinct fundamental type (and thus it is not defined in <cwchar> nor any other header).
|
||||
type
|
||||
wchar_t* {.importc, header:"<cwchar>".} = object
|
||||
elif defined(cpp):
|
||||
type
|
||||
wchar_t* {.importc.} = object
|
||||
|
||||
template enumOp*(op, typ, typout) =
|
||||
proc op*(x: typ, y: int): typout {.borrow.}
|
||||
proc op*(x: int, y: typ): typout {.borrow.}
|
||||
|
|
@ -75,4 +79,4 @@ template defineEnum*(typ) =
|
|||
proc `/`*(x: typ, y: int): typ = `/`(x, y.typ)
|
||||
proc `/`*(x: int, y: typ): typ = `/`(x.typ, y)
|
||||
|
||||
proc `$` *(x: typ): string {.borrow.}
|
||||
proc `$` *(x: typ): string {.borrow.}
|
||||
|
|
|
|||
42
tests/getheader.nims
Normal file
42
tests/getheader.nims
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import strutils
|
||||
|
||||
proc testCall(cmd, output: string, exitCode: int, delete = true) =
|
||||
if delete:
|
||||
rmDir("build/liblzma")
|
||||
echo cmd
|
||||
var
|
||||
ccmd =
|
||||
when defined(windows):
|
||||
"cmd /c " & cmd
|
||||
else:
|
||||
cmd
|
||||
(outp, exitC) = gorgeEx(ccmd)
|
||||
echo outp
|
||||
doAssert exitC == exitCode, $exitC
|
||||
doAssert outp.contains(output), outp
|
||||
|
||||
var
|
||||
cmd = "nim c -f"
|
||||
rcmd = " -r lzma.nim"
|
||||
exp = "liblzma version = "
|
||||
|
||||
when defined(linux):
|
||||
testCall(cmd & rcmd, "No build files found", 1)
|
||||
|
||||
# stdlib
|
||||
testCall(cmd & " -d:lzmaStd" & rcmd, exp, 0)
|
||||
testCall(cmd & " -d:lzmaStd -d:lzmaStatic" & rcmd, exp, 0)
|
||||
|
||||
# git
|
||||
testCall(cmd & " -d:lzmaGit" & rcmd, exp, 0)
|
||||
testCall(cmd & " -d:lzmaGit -d:lzmaStatic" & rcmd, exp, 0, delete = false)
|
||||
|
||||
# git tag
|
||||
testCall(cmd & " -d:lzmaGit -d:lzmaVersion=v5.2.0" & rcmd, exp & "5.2.0", 0)
|
||||
testCall(cmd & " -d:lzmaGit -d:lzmaStatic -d:lzmaVersion=v5.2.0" & rcmd, exp & "5.2.0", 0, delete = false)
|
||||
testCall("cd build/liblzma && git branch", "v5.2.0", 0, delete = false)
|
||||
|
||||
# dl
|
||||
testCall(cmd & " -d:lzmaDL" & rcmd, "Need version", 1)
|
||||
testCall(cmd & " -d:lzmaDL -d:lzmaVersion=v5.2.4" & rcmd, exp & "5.2.4", 0)
|
||||
testCall(cmd & " -d:lzmaDL -d:lzmaStatic -d:lzmaVersion=v5.2.4" & rcmd, exp & "5.2.4", 0, delete = false)
|
||||
41
tests/lzma.nim
Normal file
41
tests/lzma.nim
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import os, strutils
|
||||
|
||||
import nimterop/[build, cimport]
|
||||
|
||||
const
|
||||
baseDir = currentSourcePath.parentDir()/"build/liblzma"
|
||||
|
||||
static:
|
||||
cDebug()
|
||||
|
||||
getHeader(
|
||||
"lzma.h",
|
||||
giturl = "https://github.com/xz-mirror/xz",
|
||||
dlurl = "https://github.com/xz-mirror/xz/archive/$1.zip",
|
||||
outdir = baseDir,
|
||||
conFlags = "--disable-xz --disable-xzdec --disable-lzmadec --disable-lzmainfo"
|
||||
)
|
||||
|
||||
cPlugin:
|
||||
import strutils
|
||||
|
||||
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
||||
sym.name = sym.name.strip(chars = {'_'})
|
||||
|
||||
cOverride:
|
||||
type
|
||||
lzma_internal = object
|
||||
lzma_index = object
|
||||
lzma_index_hash = object
|
||||
|
||||
lzma_options_lzma = object
|
||||
lzma_stream_flags = object
|
||||
lzma_block = object
|
||||
lzma_index_iter = object
|
||||
|
||||
when not defined(lzmaStatic):
|
||||
cImport(lzmaPath, recurse = true, dynlib = "lzmaLPath")
|
||||
else:
|
||||
cImport(lzmaPath, recurse = true)
|
||||
|
||||
echo "liblzma version = " & $lzma_version_string()
|
||||
Loading…
Add table
Add a link
Reference in a new issue