mkctimec.tcl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. #!/usr/bin/tclsh
  2. #
  3. # To build the
  4. #
  5. # const char **azCompileOpt[]
  6. #
  7. # definition used in src/ctime.c, run this script from
  8. # the checkout root. It generates src/ctime.c .
  9. #
  10. # Results are normally written into src/ctime.c. But if an argument is
  11. # provided, results are written there instead. Examples:
  12. #
  13. # tclsh tool/mkctimec.tcl ;# <-- results to src/ctime.c
  14. #
  15. # tclsh tool/mkctimec.tcl /dev/tty ;# <-- results to the terminal
  16. #
  17. set ::headWarning {/* DO NOT EDIT!
  18. ** This file is automatically generated by the script in the canonical
  19. ** SQLite source tree at tool/mkctimec.tcl.
  20. **
  21. ** To modify this header, edit any of the various lists in that script
  22. ** which specify categories of generated conditionals in this file.
  23. */}
  24. # Make { and } easier to put into literals (even on EBCDIC machines.)
  25. regexp {(\{)(\})} "{}" ma ::lb ::rb
  26. set ::headCode "
  27. /*
  28. ** 2010 February 23
  29. **
  30. ** The author disclaims copyright to this source code. In place of
  31. ** a legal notice, here is a blessing:
  32. **
  33. ** May you do good and not evil.
  34. ** May you find forgiveness for yourself and forgive others.
  35. ** May you share freely, never taking more than you give.
  36. **
  37. *************************************************************************
  38. **
  39. ** This file implements routines used to report what compile-time options
  40. ** SQLite was built with.
  41. */
  42. #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */
  43. /*
  44. ** Include the configuration header output by 'configure' if we're using the
  45. ** autoconf-based build
  46. */
  47. #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
  48. #include \"sqlite_cfg.h\"
  49. #define SQLITECONFIG_H 1
  50. #endif
  51. /* These macros are provided to \"stringify\" the value of the define
  52. ** for those options in which the value is meaningful. */
  53. #define CTIMEOPT_VAL_(opt) #opt
  54. #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
  55. /* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
  56. ** option requires a separate macro because legal values contain a single
  57. ** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE=\"100,100\") */
  58. #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 \",\" #opt2
  59. #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
  60. #include \"sqliteInt.h\"
  61. /*
  62. ** An array of names of all compile-time options. This array should
  63. ** be sorted A-Z.
  64. **
  65. ** This array looks large, but in a typical installation actually uses
  66. ** only a handful of compile-time options, so most times this array is usually
  67. ** rather short and uses little memory space.
  68. */
  69. static const char * const sqlite3azCompileOpt\[\] = $::lb
  70. "
  71. set ::tailCode "
  72. $::rb ;
  73. const char **sqlite3CompileOptions(int *pnOpt){
  74. *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt\[0\]);
  75. return (const char**)sqlite3azCompileOpt;
  76. }
  77. #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
  78. "
  79. # All Boolean compile time options which default to something
  80. # other than 0 or empty. The default is paired with the PP
  81. # symbol so that a differing define can be detected.
  82. #
  83. set boolean_defnnz_options {
  84. {SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1}
  85. {SQLITE_POWERSAFE_OVERWRITE 1}
  86. {SQLITE_DEFAULT_MEMSTATUS 1}
  87. {SQLITE_OMIT_TRACE 1}
  88. {SQLITE_ALLOW_COVERING_INDEX_SCAN 1}
  89. }
  90. # All Boolean compile time options which default to 0 or empty.
  91. #
  92. set boolean_defnil_options {
  93. SQLITE_32BIT_ROWID
  94. SQLITE_4_BYTE_ALIGNED_MALLOC
  95. SQLITE_ALLOW_ROWID_IN_VIEW
  96. SQLITE_ALLOW_URI_AUTHORITY
  97. SQLITE_BUG_COMPATIBLE_20160819
  98. SQLITE_CASE_SENSITIVE_LIKE
  99. SQLITE_CHECK_PAGES
  100. SQLITE_COVERAGE_TEST
  101. SQLITE_DEBUG
  102. SQLITE_DEFAULT_AUTOMATIC_INDEX
  103. SQLITE_DEFAULT_AUTOVACUUM
  104. SQLITE_DEFAULT_CKPTFULLFSYNC
  105. SQLITE_DEFAULT_FOREIGN_KEYS
  106. SQLITE_DEFAULT_LOCKING_MODE
  107. SQLITE_DEFAULT_RECURSIVE_TRIGGERS
  108. SQLITE_DEFAULT_SYNCHRONOUS
  109. SQLITE_DEFAULT_WAL_SYNCHRONOUS
  110. SQLITE_DIRECT_OVERFLOW_READ
  111. SQLITE_DISABLE_DIRSYNC
  112. SQLITE_DISABLE_FTS3_UNICODE
  113. SQLITE_DISABLE_FTS4_DEFERRED
  114. SQLITE_DISABLE_INTRINSIC
  115. SQLITE_DISABLE_LFS
  116. SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
  117. SQLITE_DISABLE_SKIPAHEAD_DISTINCT
  118. SQLITE_ENABLE_8_3_NAMES
  119. SQLITE_ENABLE_API_ARMOR
  120. SQLITE_ENABLE_ATOMIC_WRITE
  121. SQLITE_ENABLE_BATCH_ATOMIC_WRITE
  122. SQLITE_ENABLE_BYTECODE_VTAB
  123. SQLITE_ENABLE_COLUMN_METADATA
  124. SQLITE_ENABLE_COLUMN_USED_MASK
  125. SQLITE_ENABLE_COSTMULT
  126. SQLITE_ENABLE_CURSOR_HINTS
  127. SQLITE_ENABLE_DBPAGE_VTAB
  128. SQLITE_ENABLE_DBSTAT_VTAB
  129. SQLITE_ENABLE_EXPENSIVE_ASSERT
  130. SQLITE_ENABLE_EXPLAIN_COMMENTS
  131. SQLITE_ENABLE_FTS3
  132. SQLITE_ENABLE_FTS3_PARENTHESIS
  133. SQLITE_ENABLE_FTS3_TOKENIZER
  134. SQLITE_ENABLE_FTS4
  135. SQLITE_ENABLE_FTS5
  136. SQLITE_ENABLE_GEOPOLY
  137. SQLITE_ENABLE_HIDDEN_COLUMNS
  138. SQLITE_ENABLE_ICU
  139. SQLITE_ENABLE_IOTRACE
  140. SQLITE_ENABLE_LOAD_EXTENSION
  141. SQLITE_ENABLE_LOCKING_STYLE
  142. SQLITE_ENABLE_MATH_FUNCTIONS
  143. SQLITE_ENABLE_MEMORY_MANAGEMENT
  144. SQLITE_ENABLE_MEMSYS3
  145. SQLITE_ENABLE_MEMSYS5
  146. SQLITE_ENABLE_MULTIPLEX
  147. SQLITE_ENABLE_NORMALIZE
  148. SQLITE_ENABLE_NULL_TRIM
  149. SQLITE_ENABLE_ORDERED_SET_AGGREGATES
  150. SQLITE_ENABLE_OFFSET_SQL_FUNC
  151. SQLITE_ENABLE_OVERSIZE_CELL_CHECK
  152. SQLITE_ENABLE_PREUPDATE_HOOK
  153. SQLITE_ENABLE_QPSG
  154. SQLITE_ENABLE_RBU
  155. SQLITE_ENABLE_RTREE
  156. SQLITE_ENABLE_SESSION
  157. SQLITE_ENABLE_SNAPSHOT
  158. SQLITE_ENABLE_SORTER_REFERENCES
  159. SQLITE_ENABLE_SQLLOG
  160. SQLITE_ENABLE_STAT4
  161. SQLITE_ENABLE_STMT_SCANSTATUS
  162. SQLITE_ENABLE_STMTVTAB
  163. SQLITE_ENABLE_TREETRACE
  164. SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
  165. SQLITE_ENABLE_UNLOCK_NOTIFY
  166. SQLITE_ENABLE_UPDATE_DELETE_LIMIT
  167. SQLITE_ENABLE_URI_00_ERROR
  168. SQLITE_ENABLE_VFSTRACE
  169. SQLITE_ENABLE_WHERETRACE
  170. SQLITE_ENABLE_ZIPVFS
  171. SQLITE_EXPLAIN_ESTIMATED_ROWS
  172. SQLITE_EXTRA_IFNULLROW
  173. SQLITE_FTS5_ENABLE_TEST_MI
  174. SQLITE_FTS5_NO_WITHOUT_ROWID
  175. SQLITE_IGNORE_AFP_LOCK_ERRORS
  176. SQLITE_IGNORE_FLOCK_LOCK_ERRORS
  177. SQLITE_INLINE_MEMCPY
  178. SQLITE_INT64_TYPE
  179. SQLITE_LEGACY_JSON_VALID
  180. SQLITE_LIKE_DOESNT_MATCH_BLOBS
  181. SQLITE_LOCK_TRACE
  182. SQLITE_LOG_CACHE_SPILL
  183. SQLITE_MEMDEBUG
  184. SQLITE_MIXED_ENDIAN_64BIT_FLOAT
  185. SQLITE_MMAP_READWRITE
  186. SQLITE_MUTEX_NOOP
  187. SQLITE_MUTEX_OMIT
  188. SQLITE_MUTEX_PTHREADS
  189. SQLITE_MUTEX_W32
  190. SQLITE_NEED_ERR_NAME
  191. SQLITE_NO_SYNC
  192. SQLITE_OMIT_ALTERTABLE
  193. SQLITE_OMIT_ANALYZE
  194. SQLITE_OMIT_ATTACH
  195. SQLITE_OMIT_AUTHORIZATION
  196. SQLITE_OMIT_AUTOINCREMENT
  197. SQLITE_OMIT_AUTOINIT
  198. SQLITE_OMIT_AUTOMATIC_INDEX
  199. SQLITE_OMIT_AUTORESET
  200. SQLITE_OMIT_AUTOVACUUM
  201. SQLITE_OMIT_BETWEEN_OPTIMIZATION
  202. SQLITE_OMIT_BLOB_LITERAL
  203. SQLITE_OMIT_CAST
  204. SQLITE_OMIT_CHECK
  205. SQLITE_OMIT_COMPLETE
  206. SQLITE_OMIT_COMPOUND_SELECT
  207. SQLITE_OMIT_CONFLICT_CLAUSE
  208. SQLITE_OMIT_CTE
  209. SQLITE_OMIT_DECLTYPE
  210. SQLITE_OMIT_DEPRECATED
  211. SQLITE_OMIT_DESERIALIZE
  212. SQLITE_OMIT_DISKIO
  213. SQLITE_OMIT_EXPLAIN
  214. SQLITE_OMIT_FLAG_PRAGMAS
  215. SQLITE_OMIT_FLOATING_POINT
  216. SQLITE_OMIT_FOREIGN_KEY
  217. SQLITE_OMIT_GET_TABLE
  218. SQLITE_OMIT_HEX_INTEGER
  219. SQLITE_OMIT_INCRBLOB
  220. SQLITE_OMIT_INTEGRITY_CHECK
  221. SQLITE_OMIT_INTROSPECTION_PRAGMAS
  222. SQLITE_OMIT_JSON
  223. SQLITE_OMIT_LIKE_OPTIMIZATION
  224. SQLITE_OMIT_LOAD_EXTENSION
  225. SQLITE_OMIT_LOCALTIME
  226. SQLITE_OMIT_LOOKASIDE
  227. SQLITE_OMIT_MEMORYDB
  228. SQLITE_OMIT_OR_OPTIMIZATION
  229. SQLITE_OMIT_PAGER_PRAGMAS
  230. SQLITE_OMIT_PARSER_TRACE
  231. SQLITE_OMIT_POPEN
  232. SQLITE_OMIT_PRAGMA
  233. SQLITE_OMIT_PROGRESS_CALLBACK
  234. SQLITE_OMIT_QUICKBALANCE
  235. SQLITE_OMIT_REINDEX
  236. SQLITE_OMIT_SCHEMA_PRAGMAS
  237. SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
  238. SQLITE_OMIT_SEH
  239. SQLITE_OMIT_SHARED_CACHE
  240. SQLITE_OMIT_SHUTDOWN_DIRECTORIES
  241. SQLITE_OMIT_SUBQUERY
  242. SQLITE_OMIT_TCL_VARIABLE
  243. SQLITE_OMIT_TEMPDB
  244. SQLITE_OMIT_TEST_CONTROL
  245. SQLITE_OMIT_TRIGGER
  246. SQLITE_OMIT_TRUNCATE_OPTIMIZATION
  247. SQLITE_OMIT_UTF16
  248. SQLITE_OMIT_VACUUM
  249. SQLITE_OMIT_VIEW
  250. SQLITE_OMIT_VIRTUALTABLE
  251. SQLITE_OMIT_WAL
  252. SQLITE_OMIT_WSD
  253. SQLITE_OMIT_XFER_OPT
  254. SQLITE_PERFORMANCE_TRACE
  255. SQLITE_PREFER_PROXY_LOCKING
  256. SQLITE_PROXY_DEBUG
  257. SQLITE_REVERSE_UNORDERED_SELECTS
  258. SQLITE_RTREE_INT_ONLY
  259. SQLITE_SECURE_DELETE
  260. SQLITE_SMALL_STACK
  261. SQLITE_SOUNDEX
  262. SQLITE_SUBSTR_COMPATIBILITY
  263. SQLITE_TCL
  264. SQLITE_TEST
  265. SQLITE_UNLINK_AFTER_CLOSE
  266. SQLITE_UNTESTABLE
  267. SQLITE_USE_ALLOCA
  268. SQLITE_USE_FCNTL_TRACE
  269. SQLITE_USE_URI
  270. SQLITE_VDBE_COVERAGE
  271. SQLITE_WIN32_MALLOC
  272. SQLITE_ZERO_MALLOC
  273. }
  274. # All compile time options for which the assigned value is other than boolean
  275. # and is a comma-separated scalar pair.
  276. #
  277. set value2_options {
  278. SQLITE_DEFAULT_LOOKASIDE
  279. }
  280. # All compile time options for which the assigned value is other than boolean
  281. # and is a single scalar.
  282. #
  283. set value_options {
  284. SQLITE_ATOMIC_INTRINSICS
  285. SQLITE_BITMASK_TYPE
  286. SQLITE_DEFAULT_CACHE_SIZE
  287. SQLITE_DEFAULT_FILE_FORMAT
  288. SQLITE_DEFAULT_FILE_PERMISSIONS
  289. SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
  290. SQLITE_DEFAULT_LOCKING_MODE
  291. SQLITE_DEFAULT_MMAP_SIZE
  292. SQLITE_DEFAULT_PAGE_SIZE
  293. SQLITE_DEFAULT_PCACHE_INITSZ
  294. SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
  295. SQLITE_DEFAULT_ROWEST
  296. SQLITE_DEFAULT_SECTOR_SIZE
  297. SQLITE_DEFAULT_SYNCHRONOUS
  298. SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
  299. SQLITE_DEFAULT_WAL_SYNCHRONOUS
  300. SQLITE_DEFAULT_WORKER_THREADS
  301. SQLITE_DQS
  302. SQLITE_ENABLE_8_3_NAMES
  303. SQLITE_ENABLE_CEROD
  304. SQLITE_ENABLE_LOCKING_STYLE
  305. SQLITE_EXTRA_AUTOEXT
  306. SQLITE_EXTRA_INIT
  307. SQLITE_EXTRA_SHUTDOWN
  308. SQLITE_FTS3_MAX_EXPR_DEPTH
  309. SQLITE_INTEGRITY_CHECK_ERROR_MAX
  310. SQLITE_MALLOC_SOFT_LIMIT
  311. SQLITE_MAX_ATTACHED
  312. SQLITE_MAX_COLUMN
  313. SQLITE_MAX_COMPOUND_SELECT
  314. SQLITE_MAX_DEFAULT_PAGE_SIZE
  315. SQLITE_MAX_EXPR_DEPTH
  316. SQLITE_MAX_FUNCTION_ARG
  317. SQLITE_MAX_LENGTH
  318. SQLITE_MAX_LIKE_PATTERN_LENGTH
  319. SQLITE_MAX_MEMORY
  320. SQLITE_MAX_MMAP_SIZE
  321. SQLITE_MAX_MMAP_SIZE_
  322. SQLITE_MAX_PAGE_COUNT
  323. SQLITE_MAX_PAGE_SIZE
  324. SQLITE_MAX_SCHEMA_RETRY
  325. SQLITE_MAX_SQL_LENGTH
  326. SQLITE_MAX_TRIGGER_DEPTH
  327. SQLITE_MAX_VARIABLE_NUMBER
  328. SQLITE_MAX_VDBE_OP
  329. SQLITE_MAX_WORKER_THREADS
  330. SQLITE_SORTER_PMASZ
  331. SQLITE_STAT4_SAMPLES
  332. SQLITE_STMTJRNL_SPILL
  333. SQLITE_TEMP_STORE
  334. }
  335. # Options that require custom code.
  336. #
  337. set options(COMPILER) {
  338. #if defined(__clang__) && defined(__clang_major__)
  339. "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
  340. CTIMEOPT_VAL(__clang_minor__) "."
  341. CTIMEOPT_VAL(__clang_patchlevel__),
  342. #elif defined(_MSC_VER)
  343. "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
  344. #elif defined(__GNUC__) && defined(__VERSION__)
  345. "COMPILER=gcc-" __VERSION__,
  346. #endif
  347. }
  348. set options(HAVE_ISNAN) {
  349. #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
  350. "HAVE_ISNAN",
  351. #endif
  352. }
  353. set options(OMIT_DATETIME_FUNCS) {
  354. #if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT)
  355. "OMIT_DATETIME_FUNCS",
  356. #endif
  357. }
  358. set options(SYSTEM_MALLOC) "\
  359. #if (!defined(SQLITE_WIN32_MALLOC) \\
  360. && !defined(SQLITE_ZERO_MALLOC) \\
  361. && !defined(SQLITE_MEMDEBUG) \\
  362. ) || defined(SQLITE_SYSTEM_MALLOC)
  363. \"SYSTEM_MALLOC\",
  364. #endif
  365. "
  366. set options(THREADSAFE) {
  367. #if defined(SQLITE_THREADSAFE)
  368. "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
  369. #elif defined(THREADSAFE)
  370. "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
  371. #else
  372. "THREADSAFE=1",
  373. #endif
  374. }
  375. proc trim_name {in} {
  376. set ret $in
  377. if {[string range $in 0 6]=="SQLITE_"} {
  378. set ret [string range $in 7 end]
  379. }
  380. return $ret
  381. }
  382. foreach name_defval $boolean_defnnz_options {
  383. set b [lindex $name_defval 0]
  384. set defval [lindex $name_defval 1]
  385. set name [trim_name $b]
  386. set options($name) [subst {
  387. #ifdef $b
  388. # if $b != $defval
  389. "$name=" CTIMEOPT_VAL($b),
  390. # endif
  391. #endif
  392. }]
  393. }
  394. foreach b $boolean_defnil_options {
  395. set name [trim_name $b]
  396. set options($name) [subst {
  397. #ifdef $b
  398. "$name",
  399. #endif
  400. }]
  401. }
  402. foreach v $value_options {
  403. set name [trim_name $v]
  404. set options($name) [subst {
  405. #ifdef $v
  406. "$name=" CTIMEOPT_VAL($v),
  407. #endif
  408. }]
  409. }
  410. foreach v $value2_options {
  411. set name [trim_name $v]
  412. set options($name) [subst {
  413. #ifdef $v
  414. "$name=" CTIMEOPT_VAL2($v),
  415. #endif
  416. }]
  417. }
  418. if {$argc>0} {
  419. set destfile [lindex $argv 0]
  420. } else {
  421. set destfile "[file dir [file dir [file normal $argv0]]]/src/ctime.c"
  422. puts "Overwriting $destfile..."
  423. }
  424. if {[catch {set cfd [open $destfile w]}]!=0} {
  425. puts stderr "File '$destfile' unwritable."
  426. exit 1;
  427. }
  428. fconfigure $cfd -translation binary
  429. puts $cfd $::headWarning;
  430. puts $cfd $::headCode;
  431. foreach o [lsort [array names options]] {
  432. puts $cfd [string trim $options($o)]
  433. }
  434. puts -nonewline $cfd $::tailCode;
  435. close $cfd