@@ -5,7 +5,7 @@ from std/strutils import parseInt, strip, multiReplace
5
5
import std/ macros
6
6
7
7
const weirdTarget = defined(js) or defined(nimscript)
8
-
8
+ const pylibDebug = defined(pylibDebugPyConfig)
9
9
const cacheDir = currentSourcePath()/../ " .cfgcache"
10
10
when not weirdTarget:
11
11
static :
@@ -24,13 +24,19 @@ template decl_ac_implAux(handle; subcmd; variable; defval; doWithExecRes; code):
24
24
when fileExists fp: handle variable, fp.slurp
25
25
else :
26
26
const
27
- res = gorgeEx( nimExeQuotedPath & ' ' & subcmd & " --hints:off --eval:" & quoteShell(astToStr code) )
27
+ scode = astToStr code
28
+ res = gorgeEx( nimExeQuotedPath & ' ' & subcmd & " --hints:" & (when pylibDebug: " on" else : " off" )& " --eval: " & quoteShell(scode) )
28
29
resCodeS = doWithExecRes res
30
+ when pylibDebug:
31
+ static :echo scode
29
32
fp.writeFile resCodeS
30
33
handle variable, resCodeS
31
34
32
35
template decl_ac_implAux(handle; subcmd; variable; defval; code): untyped =
33
- template handle_exec_res(res): string {.genSym, used.} = $ res.exitCode
36
+ template handle_exec_res(res): string {.genSym, used.} =
37
+ when pylibDebug:
38
+ echo res.output
39
+ $ res.exitCode
34
40
decl_ac_implAux(handle, subcmd, variable, defval, handle_exec_res, code)
35
41
36
42
@@ -64,7 +70,7 @@ proc from_c_int_expr(cacheName, cexpr: string; defval: NimNode): NimNode =
64
70
let pureVarId = newLit cacheName
65
71
result = quote do :
66
72
from_c_int(`cexpr`, `defval`):
67
- {.emit: [" /*VARSECTION*/\n #define " , `pureVarId`, " " , `cexpr`, ' \n ' ].}
73
+ {.emit: [" /*VARSECTION*/\n #define " , `pureVarId`, " " , `cexpr`, " \n " ].}
68
74
69
75
macro from_c_int_underlined* (variable: static [string ]; defval: int ): int =
70
76
let pureVar = variable.strip(chars = {'_' })
@@ -167,18 +173,20 @@ template c_defined*(variable; c_macro: string; headers: openArray = []) =
167
173
template AC_CHECK_FUNC* (res, function) =
168
174
# # export const HAVE_`function`
169
175
AC_LINK_IFELSE res, false :
176
+ const fname{.inject.} = astToStr(function)
170
177
{.emit: [
171
178
" /*INCLUDESECTION*/\n " ,
172
- " #undef " & astToStr(function) & '\n ' ,
179
+ " #include <limits.h>\n " ,
180
+ " #undef " , fname, " \n " ,
173
181
""" /* The GNU C library defines this for functions which it implements
174
182
to always fail with ENOSYS. Some functions are actually named
175
183
something starting with __ and the normal name is an alias. */
176
- #if defined __stub_`function` || defined __stub___`function`
184
+ #if defined __stub_ """ , fname, " || defined __stub___" , fname, " \n " , """
177
185
choke me
178
186
#endif
179
187
"""
180
188
].} # """ <- for code lint
181
- proc function(): cchar {.importc, header: " <limits.h> " .}
189
+ proc function(): cchar {.importc, cdecl .}
182
190
discard function()
183
191
184
192
template AC_CHECK_FUNC* (function) =
0 commit comments