/ Check-in [5e892d60]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Makefile changes to support building winsqlite3.dll using STDCALL rather than CDECL.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5e892d60935e5c82234d1bfaef4c5026061acceb
User & Date: mistachkin 2016-09-22 18:46:38
Context
2016-09-22
18:53
Remove the internal sqlite3CodeOnce() interface, replacing it with a direct call to sqlite3VdbeAddOp0(v,OP_Once). Slightly smaller and faster. check-in: c3774c6a user: drh tags: trunk
18:46
Makefile changes to support building winsqlite3.dll using STDCALL rather than CDECL. check-in: 5e892d60 user: mistachkin tags: trunk
2016-09-21
23:58
Fix speedtest1.c so that it works with SQLITE_OMIT_DEPRECATED. Add the --lean and --cachesize options to speed-check.sh. check-in: 7785b3a2 user: drh tags: trunk
2016-09-08
23:16
Remove an extra space before function names in the amalgamation. Closed-Leaf check-in: 20f3c743 user: mistachkin tags: callbackConv
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.msc.

    26     26   
    27     27   # Set this non-0 to enable full runtime error checks (-RTC1, etc).  This
    28     28   # has no effect if (any) optimizations are enabled.
    29     29   #
    30     30   !IFNDEF USE_RUNTIME_CHECKS
    31     31   USE_RUNTIME_CHECKS = 0
    32     32   !ENDIF
           33  +
           34  +# Set this non-0 to create a SQLite amalgamation file that excludes the
           35  +# various built-in extensions.
           36  +#
           37  +!IFNDEF MINIMAL_AMALGAMATION
           38  +MINIMAL_AMALGAMATION = 0
           39  +!ENDIF
    33     40   
    34     41   # Set this non-0 to use "stdcall" calling convention for the core library
    35     42   # and shell executable.
    36     43   #
    37     44   !IFNDEF USE_STDCALL
    38     45   USE_STDCALL = 0
    39     46   !ENDIF
................................................................................
   266    273   !IF $(FOR_WIN10)!=0
   267    274   SQLITE3EXEPDB =
   268    275   !ELSE
   269    276   SQLITE3EXEPDB = /pdb:sqlite3sh.pdb
   270    277   !ENDIF
   271    278   !ENDIF
   272    279   
          280  +# <<mark>>
          281  +# These are the names of the customized Tcl header files used by various parts
          282  +# of this makefile when the stdcall calling convention is in use.  It is not
          283  +# used for any other purpose.
          284  +#
          285  +!IFNDEF SQLITETCLH
          286  +SQLITETCLH = sqlite_tcl.h
          287  +!ENDIF
          288  +
          289  +!IFNDEF SQLITETCLDECLSH
          290  +SQLITETCLDECLSH = sqlite_tclDecls.h
          291  +!ENDIF
          292  +
          293  +# These are the additional targets that the targets that integrate with the
          294  +# Tcl library should depend on when compiling, etc.
          295  +#
          296  +!IFNDEF SQLITE_TCL_DEP
          297  +!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
          298  +SQLITE_TCL_DEP = $(SQLITETCLDECLSH) $(SQLITETCLH)
          299  +!ELSE
          300  +SQLITE_TCL_DEP =
          301  +!ENDIF
          302  +!ENDIF
          303  +# <</mark>>
          304  +
   273    305   # These are the "standard" SQLite compilation options used when compiling for
   274    306   # the Windows platform.
   275    307   #
   276    308   !IFNDEF OPT_FEATURE_FLAGS
          309  +!IF $(MINIMAL_AMALGAMATION)==0
   277    310   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1
   278    311   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
          312  +!ENDIF
   279    313   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
   280    314   !ENDIF
   281    315   
   282    316   # Should the session extension be enabled?  If so, add compilation options
   283    317   # to enable it.
   284    318   #
   285    319   !IF $(SESSION)!=0
................................................................................
   467    501   # also be noted here that building any target with these "stdcall" options
   468    502   # will most likely fail if the Tcl library is also required.  This is due
   469    503   # to how the Tcl library functions are declared and exported (i.e. without
   470    504   # an explicit calling convention, which results in "cdecl").
   471    505   #
   472    506   !IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
   473    507   !IF "$(PLATFORM)"=="x86"
   474         -CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
   475         -SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
          508  +CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
          509  +SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
          510  +# <<mark>>
          511  +TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl
          512  +# <</mark>>
   476    513   !ELSE
   477    514   !IFNDEF PLATFORM
   478         -CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
   479         -SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
          515  +CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
          516  +SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
          517  +# <<mark>>
          518  +TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl
          519  +# <</mark>>
   480    520   !ELSE
   481    521   CORE_CCONV_OPTS =
   482    522   SHELL_CCONV_OPTS =
          523  +# <<mark>>
          524  +TEST_CCONV_OPTS =
          525  +# <</mark>>
   483    526   !ENDIF
   484    527   !ENDIF
   485    528   !ELSE
   486    529   CORE_CCONV_OPTS =
   487    530   SHELL_CCONV_OPTS =
          531  +# <<mark>>
          532  +TEST_CCONV_OPTS =
          533  +# <</mark>>
   488    534   !ENDIF
   489    535   
   490    536   # These are additional compiler options used for the core library.
   491    537   #
   492    538   !IFNDEF CORE_COMPILE_OPTS
   493    539   !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
   494    540   CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) -DSQLITE_API=__declspec(dllexport)
................................................................................
   633    679   !ENDIF
   634    680   
   635    681   # The mksqlite3c.tcl script accepts some options on the command
   636    682   # line.  When compiling with debugging enabled, some of these
   637    683   # options are necessary in order to allow debugging symbols to
   638    684   # work correctly with Visual Studio when using the amalgamation.
   639    685   #
          686  +!IFNDEF MKSQLITE3C_TOOL
          687  +!IF $(MINIMAL_AMALGAMATION)!=0
          688  +MKSQLITE3C_TOOL = $(TOP)\tool\mksqlite3c-noext.tcl
          689  +!ELSE
          690  +MKSQLITE3C_TOOL = $(TOP)\tool\mksqlite3c.tcl
          691  +!ENDIF
          692  +!ENDIF
          693  +
   640    694   !IFNDEF MKSQLITE3C_ARGS
   641    695   !IF $(DEBUG)>1
   642    696   MKSQLITE3C_ARGS = --linemacros
   643    697   !ELSE
   644    698   MKSQLITE3C_ARGS =
          699  +!ENDIF
          700  +!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
          701  +MKSQLITE3C_ARGS = $(MKSQLITE3C_ARGS) --useapicall
          702  +!ENDIF
          703  +!ENDIF
          704  +
          705  +# The mksqlite3h.tcl script accepts some options on the command line.
          706  +# When compiling with stdcall support, some of these options are
          707  +# necessary.
          708  +#
          709  +!IFNDEF MKSQLITE3H_ARGS
          710  +!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
          711  +MKSQLITE3H_ARGS = --useapicall
          712  +!ELSE
          713  +MKSQLITE3H_ARGS =
   645    714   !ENDIF
   646    715   !ENDIF
   647    716   # <</mark>>
   648    717   
   649    718   # Define -DNDEBUG to compile without debugging (i.e., for production usage)
   650    719   # Omitting the define will cause extra debugging code to be inserted and
   651    720   # includes extra comments when "EXPLAIN stmt" is used.
................................................................................
  1241   1310   # Generated header files
  1242   1311   #
  1243   1312   SRC11 = \
  1244   1313     keywordhash.h \
  1245   1314     opcodes.h \
  1246   1315     parse.h \
  1247   1316     $(SQLITE3H)
         1317  +
         1318  +# Generated Tcl header files
         1319  +#
         1320  +!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
         1321  +SRC12 = \
         1322  +  $(SQLITETCLH) \
         1323  +  $(SQLITETCLDECLSH)
         1324  +!ELSE
         1325  +SRC12 =
         1326  +!ENDIF
  1248   1327   
  1249   1328   # All source code files.
  1250   1329   #
  1251   1330   SRC = $(SRC00) $(SRC01) $(SRC02) $(SRC03) $(SRC04) $(SRC05) $(SRC06) $(SRC07) $(SRC08) $(SRC09) $(SRC10) $(SRC11)
  1252   1331   
  1253   1332   # Source code to the test files.
  1254   1333   #
................................................................................
  1349   1428      $(TOP)\src\os_setup.h \
  1350   1429      $(TOP)\src\os_win.h \
  1351   1430      $(TOP)\src\pager.h \
  1352   1431      $(TOP)\src\pcache.h \
  1353   1432      parse.h \
  1354   1433      $(TOP)\src\pragma.h \
  1355   1434      $(SQLITE3H) \
  1356         -   $(TOP)\src\sqlite3ext.h \
         1435  +   sqlite3ext.h \
  1357   1436      $(TOP)\src\sqliteInt.h \
  1358   1437      $(TOP)\src\sqliteLimit.h \
  1359   1438      $(TOP)\src\vdbe.h \
  1360   1439      $(TOP)\src\vdbeInt.h \
  1361   1440      $(TOP)\src\vxworks.h \
  1362   1441      $(TOP)\src\whereInt.h
  1363   1442   
................................................................................
  1507   1586   
  1508   1587   # This target creates a directory named "tsrc" and fills it with
  1509   1588   # copies of all of the C source code and header files needed to
  1510   1589   # build on the target system.  Some of the C source code and header
  1511   1590   # files are automatically generated.  This target takes care of
  1512   1591   # all that automatic generation.
  1513   1592   #
  1514         -.target_source:	$(SRC) $(TOP)\tool\vdbe-compress.tcl fts5.c
         1593  +.target_source:	$(SRC) $(TOP)\tool\vdbe-compress.tcl fts5.c $(SQLITE_TCL_DEP)
  1515   1594   	-rmdir /Q/S tsrc 2>NUL
  1516   1595   	-mkdir tsrc
  1517   1596   	for %i in ($(SRC00)) do copy /Y %i tsrc
  1518   1597   	for %i in ($(SRC01)) do copy /Y %i tsrc
  1519   1598   	for %i in ($(SRC02)) do copy /Y %i tsrc
  1520   1599   	for %i in ($(SRC03)) do copy /Y %i tsrc
  1521   1600   	for %i in ($(SRC04)) do copy /Y %i tsrc
................................................................................
  1522   1601   	for %i in ($(SRC05)) do copy /Y %i tsrc
  1523   1602   	for %i in ($(SRC06)) do copy /Y %i tsrc
  1524   1603   	for %i in ($(SRC07)) do copy /Y %i tsrc
  1525   1604   	for %i in ($(SRC08)) do copy /Y %i tsrc
  1526   1605   	for %i in ($(SRC09)) do copy /Y %i tsrc
  1527   1606   	for %i in ($(SRC10)) do copy /Y %i tsrc
  1528   1607   	for %i in ($(SRC11)) do copy /Y %i tsrc
         1608  +	for %i in ($(SRC12)) do copy /Y %i tsrc
  1529   1609   	copy /Y fts5.c tsrc
  1530   1610   	copy /Y fts5.h tsrc
  1531   1611   	del /Q tsrc\sqlite.h.in tsrc\parse.y 2>NUL
  1532   1612   	$(TCLSH_CMD) $(TOP)\tool\vdbe-compress.tcl $(OPTS) < tsrc\vdbe.c > vdbe.new
  1533   1613   	move vdbe.new tsrc\vdbe.c
  1534   1614   	echo > .target_source
  1535   1615   
  1536         -sqlite3.c:	.target_source sqlite3ext.h $(TOP)\tool\mksqlite3c.tcl
  1537         -	$(TCLSH_CMD) $(TOP)\tool\mksqlite3c.tcl $(MKSQLITE3C_ARGS)
         1616  +sqlite3.c:	.target_source sqlite3ext.h $(MKSQLITE3C_TOOL)
         1617  +	$(TCLSH_CMD) $(MKSQLITE3C_TOOL) $(MKSQLITE3C_ARGS)
  1538   1618   	copy tsrc\shell.c .
  1539   1619   	copy $(TOP)\ext\session\sqlite3session.h .
  1540   1620   
  1541   1621   sqlite3-all.c:	sqlite3.c $(TOP)\tool\split-sqlite3c.tcl
  1542   1622   	$(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl
  1543   1623   # <</mark>>
  1544   1624   
................................................................................
  1803   1883   
  1804   1884   wherecode.lo:	$(TOP)\src\wherecode.c $(HDR)
  1805   1885   	$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\wherecode.c
  1806   1886   
  1807   1887   whereexpr.lo:	$(TOP)\src\whereexpr.c $(HDR)
  1808   1888   	$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\whereexpr.c
  1809   1889   
  1810         -tclsqlite.lo:	$(TOP)\src\tclsqlite.c $(HDR)
         1890  +tclsqlite.lo:	$(TOP)\src\tclsqlite.c $(HDR) $(SQLITE_TCL_DEP)
  1811   1891   	$(LTCOMPILE) $(NO_WARN) -DUSE_TCL_STUBS=1 -DBUILD_sqlite -I$(TCLINCDIR) -c $(TOP)\src\tclsqlite.c
  1812   1892   
  1813         -tclsqlite-shell.lo:	$(TOP)\src\tclsqlite.c $(HDR)
         1893  +tclsqlite-shell.lo:	$(TOP)\src\tclsqlite.c $(HDR) $(SQLITE_TCL_DEP)
  1814   1894   	$(LTCOMPILE) $(NO_WARN) -DTCLSH=1 -DBUILD_sqlite -I$(TCLINCDIR) -c $(TOP)\src\tclsqlite.c
  1815   1895   
  1816   1896   tclsqlite3.exe:	tclsqlite-shell.lo $(SQLITE3C) $(SQLITE3H) $(LIBRESOBJS)
  1817   1897   	$(LTLINK) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /OUT:$@ tclsqlite-shell.lo $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
  1818   1898   
  1819   1899   # Rules to build opcodes.c and opcodes.h
  1820   1900   #
................................................................................
  1832   1912   	del /Q parse.y parse.h parse.h.temp 2>NUL
  1833   1913   	copy $(TOP)\src\parse.y .
  1834   1914   	.\lemon.exe $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) $(OPTS) parse.y
  1835   1915   	move parse.h parse.h.temp
  1836   1916   	$(TCLSH_CMD) $(TOP)\tool\addopcodes.tcl parse.h.temp > parse.h
  1837   1917   
  1838   1918   $(SQLITE3H):	$(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION
  1839         -	$(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP:\=/) > $(SQLITE3H)
         1919  +	$(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP:\=/) > $(SQLITE3H) $(MKSQLITE3H_ARGS)
  1840   1920   
  1841   1921   sqlite3ext.h:	.target_source
  1842         -	copy tsrc\sqlite3ext.h .
         1922  +!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
         1923  +	type tsrc\sqlite3ext.h | $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*\)" "(SQLITE_CALLBACK *)" \
         1924  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*" "(SQLITE_APICALL *" > sqlite3ext.h
         1925  +	copy /Y sqlite3ext.h tsrc\sqlite3ext.h
         1926  +!ELSE
         1927  +	copy /Y tsrc\sqlite3ext.h sqlite3ext.h
         1928  +!ENDIF
  1843   1929   
  1844   1930   mkkeywordhash.exe:	$(TOP)\tool\mkkeywordhash.c
  1845   1931   	$(BCC) $(NO_WARN) -Fe$@ $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS) $(OPTS) \
  1846   1932   		$(TOP)\tool\mkkeywordhash.c /link $(LDFLAGS) $(NLTLINKOPTS) $(NLTLIBPATHS)
  1847   1933   
  1848   1934   keywordhash.h:	$(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe
  1849   1935   	.\mkkeywordhash.exe > keywordhash.h
................................................................................
  1968   2054   # hidden when the library is built via the amalgamation).
  1969   2055   #
  1970   2056   TESTFIXTURE_FLAGS = -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1
  1971   2057   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERVER=1 -DSQLITE_PRIVATE=""
  1972   2058   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_CORE $(NO_WARN)
  1973   2059   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
  1974   2060   TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_DEFAULT_PAGE_SIZE=1024
         2061  +TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) $(TEST_CCONV_OPTS)
  1975   2062   
  1976   2063   TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2)
  1977   2064   TESTFIXTURE_SRC1 = $(TESTEXT) $(SQLITE3C)
  1978   2065   !IF $(USE_AMALGAMATION)==0
  1979   2066   TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC0)
  1980   2067   !ELSE
  1981   2068   TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC1)
  1982   2069   !ENDIF
  1983   2070   
  1984         -testfixture.exe:	$(TESTFIXTURE_SRC) $(SQLITE3H) $(LIBRESOBJS) $(HDR)
         2071  +!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
         2072  +sqlite_tclDecls.h:
         2073  +	echo #ifndef SQLITE_TCLAPI > $(SQLITETCLDECLSH)
         2074  +	echo #  define SQLITE_TCLAPI >> $(SQLITETCLDECLSH)
         2075  +	echo #endif >> $(SQLITETCLDECLSH)
         2076  +	type "$(TCLINCDIR)\tclDecls.h" \
         2077  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN(?: CONST\d+?)?\s+?[^\(]*?\s+?)Tcl_" "\1 SQLITE_TCLAPI Tcl_" \
         2078  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "^(EXTERN\s+?(?:void|VOID)\s+?)TclFreeObj" "\1 SQLITE_TCLAPI TclFreeObj" \
         2079  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tcl_" "(SQLITE_TCLAPI *tcl_" \
         2080  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*tclFreeObj" "(SQLITE_TCLAPI *tclFreeObj" \
         2081  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "\(\*" "(SQLITE_TCLAPI *" >> $(SQLITETCLDECLSH)
         2082  +
         2083  +sqlite_tcl.h:
         2084  +	type "$(TCLINCDIR)\tcl.h" | $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact tclDecls.h sqlite_tclDecls.h \
         2085  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl regsub "typedef (.*?)\(Tcl_" "typedef \1 (SQLITE_TCLAPI Tcl_" \
         2086  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact "void (*freeProc)" "void (SQLITE_TCLAPI *freeProc)" \
         2087  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact "Tcl_HashEntry *(*findProc)" "Tcl_HashEntry *(SQLITE_TCLAPI *findProc)" \
         2088  +		| $(TCLSH_CMD) $(TOP)\tool\replace.tcl exact "Tcl_HashEntry *(*createProc)" "Tcl_HashEntry *(SQLITE_TCLAPI *createProc)" >> $(SQLITETCLH)
         2089  +!ENDIF
         2090  +
         2091  +testfixture.exe:	$(TESTFIXTURE_SRC) $(SQLITE3H) $(LIBRESOBJS) $(HDR) $(SQLITE_TCL_DEP)
  1985   2092   	$(LTLINK) -DSQLITE_NO_SYNC=1 $(TESTFIXTURE_FLAGS) \
  1986   2093   		-DBUILD_sqlite -I$(TCLINCDIR) \
  1987   2094   		$(TESTFIXTURE_SRC) \
  1988   2095   		/link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
  1989   2096   
  1990   2097   extensiontest:	testfixture.exe testloadext.dll
  1991   2098   	@set PATH=$(LIBTCLPATH);$(PATH)
................................................................................
  2026   2133   	@set PATH=$(LIBTCLPATH);$(PATH)
  2027   2134   	.\testfixture.exe $(TOP)\test\veryquick.test $(TESTOPTS)
  2028   2135   
  2029   2136   smoketest:	$(TESTPROGS)
  2030   2137   	@set PATH=$(LIBTCLPATH);$(PATH)
  2031   2138   	.\testfixture.exe $(TOP)\test\main.test $(TESTOPTS)
  2032   2139   
  2033         -sqlite3_analyzer.c:	$(SQLITE3C) $(SQLITE3H) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl
         2140  +sqlite3_analyzer.c:	$(SQLITE3C) $(SQLITE3H) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl $(SQLITE_TCL_DEP)
  2034   2141   	echo #define TCLSH 2 > $@
  2035   2142   	echo #define SQLITE_ENABLE_DBSTAT_VTAB 1 >> $@
  2036   2143   	copy $@ + $(SQLITE3C) + $(TOP)\src\tclsqlite.c $@
  2037   2144   	echo static const char *tclsh_main_loop(void){ >> $@
  2038   2145   	echo static const char *zMainloop = >> $@
  2039   2146   	$(TCLSH_CMD) $(TOP)\tool\tostr.tcl $(TOP)\tool\spaceanal.tcl >> $@
  2040   2147   	echo ; return zMainloop; } >> $@
................................................................................
  2106   2213   	del /Q lemon.* lempar.c parse.* 2>NUL
  2107   2214   	del /Q mkkeywordhash.* keywordhash.h 2>NUL
  2108   2215   	del /Q notasharedlib.* 2>NUL
  2109   2216   	-rmdir /Q/S .deps 2>NUL
  2110   2217   	-rmdir /Q/S .libs 2>NUL
  2111   2218   	-rmdir /Q/S tsrc 2>NUL
  2112   2219   	del /Q .target_source 2>NUL
  2113         -	del /Q tclsqlite3.exe 2>NUL
         2220  +	del /Q tclsqlite3.exe $(SQLITETCLH) $(SQLITETCLDECLSH) 2>NUL
  2114   2221   	del /Q testloadext.dll 2>NUL
  2115   2222   	del /Q testfixture.exe test.db 2>NUL
  2116   2223   	del /Q LogEst.exe fts3view.exe rollback-test.exe showdb.exe 2>NUL
  2117   2224   	del /Q changeset.exe 2>NUL
  2118   2225   	del /Q showjournal.exe showstat4.exe showwal.exe speedtest1.exe 2>NUL
  2119   2226   	del /Q mptester.exe wordcount.exe rbu.exe srcck1.exe 2>NUL
  2120   2227   	del /Q sqlite3.c sqlite3-*.c 2>NUL

Changes to autoconf/Makefile.msc.

    26     26   
    27     27   # Set this non-0 to enable full runtime error checks (-RTC1, etc).  This
    28     28   # has no effect if (any) optimizations are enabled.
    29     29   #
    30     30   !IFNDEF USE_RUNTIME_CHECKS
    31     31   USE_RUNTIME_CHECKS = 0
    32     32   !ENDIF
           33  +
           34  +# Set this non-0 to create a SQLite amalgamation file that excludes the
           35  +# various built-in extensions.
           36  +#
           37  +!IFNDEF MINIMAL_AMALGAMATION
           38  +MINIMAL_AMALGAMATION = 0
           39  +!ENDIF
    33     40   
    34     41   # Set this non-0 to use "stdcall" calling convention for the core library
    35     42   # and shell executable.
    36     43   #
    37     44   !IFNDEF USE_STDCALL
    38     45   USE_STDCALL = 0
    39     46   !ENDIF
................................................................................
   250    257   !IFNDEF SQLITE3EXEPDB
   251    258   !IF $(FOR_WIN10)!=0
   252    259   SQLITE3EXEPDB =
   253    260   !ELSE
   254    261   SQLITE3EXEPDB = /pdb:sqlite3sh.pdb
   255    262   !ENDIF
   256    263   !ENDIF
          264  +
   257    265   
   258    266   # These are the "standard" SQLite compilation options used when compiling for
   259    267   # the Windows platform.
   260    268   #
   261    269   !IFNDEF OPT_FEATURE_FLAGS
          270  +!IF $(MINIMAL_AMALGAMATION)==0
   262    271   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1
   263    272   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
          273  +!ENDIF
   264    274   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
   265    275   !ENDIF
   266    276   
   267    277   # Should the session extension be enabled?  If so, add compilation options
   268    278   # to enable it.
   269    279   #
   270    280   !IF $(SESSION)!=0
................................................................................
   452    462   # also be noted here that building any target with these "stdcall" options
   453    463   # will most likely fail if the Tcl library is also required.  This is due
   454    464   # to how the Tcl library functions are declared and exported (i.e. without
   455    465   # an explicit calling convention, which results in "cdecl").
   456    466   #
   457    467   !IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
   458    468   !IF "$(PLATFORM)"=="x86"
   459         -CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
   460         -SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
          469  +CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
          470  +SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
   461    471   !ELSE
   462    472   !IFNDEF PLATFORM
   463         -CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
   464         -SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_STDCALL=__stdcall
          473  +CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
          474  +SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
   465    475   !ELSE
   466    476   CORE_CCONV_OPTS =
   467    477   SHELL_CCONV_OPTS =
   468    478   !ENDIF
   469    479   !ENDIF
   470    480   !ELSE
   471    481   CORE_CCONV_OPTS =

Changes to tool/mksqlite3c-noext.tcl.

     1      1   #!/usr/bin/tclsh
     2      2   #
     3      3   # To build a single huge source file holding all of SQLite (or at
     4         -# least the core components - the test harness, shell, and TCL 
            4  +# least the core components - the test harness, shell, and TCL
     5      5   # interface are omitted.) first do
     6      6   #
     7      7   #      make target_source
     8      8   #
     9      9   # The make target above moves all of the source code files into
    10     10   # a subdirectory named "tsrc".  (This script expects to find the files
    11     11   # there and will not work if they are not found.)  There are a few
    12     12   # generated C code files that are also added to the tsrc directory.
    13     13   # For example, the "parse.c" and "parse.h" files to implement the
    14         -# the parser are derived from "parse.y" using lemon.  And the 
           14  +# the parser are derived from "parse.y" using lemon.  And the
    15     15   # "keywordhash.h" files is generated by a program named "mkkeywordhash".
    16     16   #
    17     17   # After the "tsrc" directory has been created and populated, run
    18     18   # this script:
    19     19   #
    20     20   #      tclsh mksqlite3c-noext.tcl
    21     21   #
................................................................................
    22     22   # The amalgamated SQLite code will be written into sqlite3.c
    23     23   #
    24     24   
    25     25   # Begin by reading the "sqlite3.h" header file.  Extract the version number
    26     26   # from in this file.  The version number is needed to generate the header
    27     27   # comment of the amalgamation.
    28     28   #
    29         -if {[lsearch $argv --nostatic]>=0} {
    30         -  set addstatic 0
    31         -} else {
    32         -  set addstatic 1
    33         -}
    34         -if {[lsearch $argv --linemacros]>=0} {
    35         -  set linemacros 1
    36         -} else {
    37         -  set linemacros 0
           29  +set addstatic 1
           30  +set linemacros 0
           31  +set useapicall 0
           32  +for {set i 0} {$i<[llength $argv]} {incr i} {
           33  +  set x [lindex $argv $i]
           34  +  if {[regexp {^-+nostatic$} $x]} {
           35  +    set addstatic 0
           36  +  } elseif {[regexp {^-+linemacros} $x]} {
           37  +    set linemacros 1
           38  +  } elseif {[regexp {^-+useapicall} $x]} {
           39  +    set useapicall 1
           40  +  } else {
           41  +    error "unknown command-line option: $x"
           42  +  }
    38     43   }
    39     44   set in [open tsrc/sqlite3.h]
    40     45   set cnt 0
    41     46   set VERSION ?????
    42     47   while {![eof $in]} {
    43     48     set line [gets $in]
    44     49     if {$line=="" && [eof $in]} break
................................................................................
    53     58   set out [open sqlite3.c w]
    54     59   # Force the output to use unix line endings, even on Windows.
    55     60   fconfigure $out -translation lf
    56     61   set today [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S UTC" -gmt 1]
    57     62   puts $out [subst \
    58     63   {/******************************************************************************
    59     64   ** This file is an amalgamation of many separate C source files from SQLite
    60         -** version $VERSION.  By combining all the individual C code files into this 
           65  +** version $VERSION.  By combining all the individual C code files into this
    61     66   ** single large file, the entire code can be compiled as a single translation
    62     67   ** unit.  This allows many compilers to do optimizations that would not be
    63     68   ** possible if the files were compiled separately.  Performance improvements
    64     69   ** of 5% or more are commonly seen when SQLite is compiled as a single
    65     70   ** translation unit.
    66     71   **
    67     72   ** This file is all you need to compile SQLite.  To use SQLite in other
    68     73   ** programs, you need this file and the "sqlite3.h" header file that defines
    69         -** the programming interface to the SQLite library.  (If you do not have 
           74  +** the programming interface to the SQLite library.  (If you do not have
    70     75   ** the "sqlite3.h" header file at hand, you will find a copy embedded within
    71     76   ** the text of this file.  Search for "Begin file sqlite3.h" to find the start
    72     77   ** of the embedded sqlite3.h header file.) Additional code files may be needed
    73     78   ** if you want a wrapper to interface SQLite with your choice of programming
    74     79   ** language. The code for the "sqlite3" command-line shell is also in a
    75     80   ** separate file. This file contains only code for the core SQLite library.
    76     81   */
................................................................................
    79     84   if {$addstatic} {
    80     85     puts $out \
    81     86   {#ifndef SQLITE_PRIVATE
    82     87   # define SQLITE_PRIVATE static
    83     88   #endif}
    84     89   }
    85     90   
    86         -# These are the header files used by SQLite.  The first time any of these 
           91  +# These are the header files used by SQLite.  The first time any of these
    87     92   # files are seen in a #include statement in the C code, include the complete
    88     93   # text of the file in-line.  The file only needs to be included once.
    89     94   #
    90     95   foreach hdr {
    91     96      btree.h
    92     97      btreeInt.h
    93     98      hash.h
................................................................................
   100    105      os_setup.h
   101    106      os_win.h
   102    107      os.h
   103    108      pager.h
   104    109      parse.h
   105    110      pcache.h
   106    111      pragma.h
   107         -   sqlite3ext.h
   108    112      sqlite3.h
          113  +   sqlite3ext.h
   109    114      sqliteicu.h
   110    115      sqliteInt.h
   111    116      sqliteLimit.h
   112    117      vdbe.h
   113    118      vdbeInt.h
   114    119      vxworks.h
   115    120      wal.h
................................................................................
   151    156   }
   152    157   
   153    158   # Read the source file named $filename and write it into the
   154    159   # sqlite3.c output file.  If any #include statements are seen,
   155    160   # process them appropriately.
   156    161   #
   157    162   proc copy_file {filename} {
   158         -  global seen_hdr available_hdr varonly_hdr cdecllist out addstatic linemacros
          163  +  global seen_hdr available_hdr varonly_hdr cdecllist out
          164  +  global addstatic linemacros useapicall
   159    165     set ln 0
   160    166     set tail [file tail $filename]
   161    167     section_comment "Begin file $tail"
   162    168     if {$linemacros} {puts $out "#line 1 \"$filename\""}
   163    169     set in [open $filename r]
   164    170     set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)}
   165    171     set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)}
................................................................................
   199    205           # begin/end markers with the harmless substring "**".
   200    206           puts $out "/* [string map [list /* ** */ **] $line] */"
   201    207         }
   202    208       } elseif {[regexp {^#ifdef __cplusplus} $line]} {
   203    209         puts $out "#if 0"
   204    210       } elseif {!$linemacros && [regexp {^#line} $line]} {
   205    211         # Skip #line directives.
   206         -    } elseif {$addstatic && ![regexp {^(static|typedef)} $line]} {
          212  +    } elseif {$addstatic
          213  +               && ![regexp {^(static|typedef|SQLITE_PRIVATE)} $line]} {
   207    214         # Skip adding the SQLITE_PRIVATE or SQLITE_API keyword before
   208    215         # functions if this header file does not need it.
   209    216         if {![info exists varonly_hdr($tail)]
   210    217          && [regexp $declpattern $line all rettype funcname rest]} {
   211    218           regsub {^SQLITE_API } $line {} line
   212    219           # Add the SQLITE_PRIVATE or SQLITE_API keyword before functions.
   213    220           # so that linkage can be modified at compile-time.
   214         -        if {[regexp {^sqlite3_} $funcname]} {
          221  +        if {[regexp {^sqlite3[a-z]*_} $funcname]} {
   215    222             set line SQLITE_API
   216    223             append line " " [string trim $rettype]
   217    224             if {[string index $rettype end] ne "*"} {
   218    225               append line " "
   219    226             }
   220         -          if {[lsearch -exact $cdecllist $funcname] >= 0} {
   221         -            append line SQLITE_CDECL
   222         -          } else {
   223         -            append line SQLITE_APICALL
          227  +          if {$useapicall} {
          228  +            if {[lsearch -exact $cdecllist $funcname] >= 0} {
          229  +              append line SQLITE_CDECL " "
          230  +            } else {
          231  +              append line SQLITE_APICALL " "
          232  +            }
   224    233             }
   225         -          append line " " $funcname $rest
          234  +          append line $funcname $rest
   226    235             puts $out $line
   227    236           } else {
   228    237             puts $out "SQLITE_PRIVATE $line"
   229    238           }
   230    239         } elseif {[regexp $varpattern $line all varname]} {
   231    240             # Add the SQLITE_PRIVATE before variable declarations or
   232    241             # definitions for internal use
................................................................................
   281    290      mem5.c
   282    291      mutex.c
   283    292      mutex_noop.c
   284    293      mutex_unix.c
   285    294      mutex_w32.c
   286    295      malloc.c
   287    296      printf.c
          297  +   treeview.c
   288    298      random.c
   289    299      threads.c
   290    300      utf.c
   291    301      util.c
   292    302      hash.c
   293    303      opcodes.c
   294    304   
................................................................................
   309    319      vdbemem.c
   310    320      vdbeaux.c
   311    321      vdbeapi.c
   312    322      vdbetrace.c
   313    323      vdbe.c
   314    324      vdbeblob.c
   315    325      vdbesort.c
   316         -   journal.c
   317    326      memjournal.c
   318    327   
   319    328      walker.c
   320    329      resolve.c
   321    330      expr.c
   322    331      alter.c
   323    332      analyze.c
................................................................................
   335    344      prepare.c
   336    345      select.c
   337    346      table.c
   338    347      trigger.c
   339    348      update.c
   340    349      vacuum.c
   341    350      vtab.c
          351  +   wherecode.c
          352  +   whereexpr.c
   342    353      where.c
   343    354   
   344    355      parse.c
   345    356   
   346    357      tokenize.c
   347    358      complete.c
   348    359   

Changes to tool/mksqlite3c.tcl.

     1      1   #!/usr/bin/tclsh
     2      2   #
     3      3   # To build a single huge source file holding all of SQLite (or at
     4         -# least the core components - the test harness, shell, and TCL 
            4  +# least the core components - the test harness, shell, and TCL
     5      5   # interface are omitted.) first do
     6      6   #
     7      7   #      make target_source
     8      8   #
     9      9   # The make target above moves all of the source code files into
    10     10   # a subdirectory named "tsrc".  (This script expects to find the files
    11     11   # there and will not work if they are not found.)  There are a few
    12     12   # generated C code files that are also added to the tsrc directory.
    13     13   # For example, the "parse.c" and "parse.h" files to implement the
    14         -# the parser are derived from "parse.y" using lemon.  And the 
           14  +# the parser are derived from "parse.y" using lemon.  And the
    15     15   # "keywordhash.h" files is generated by a program named "mkkeywordhash".
    16     16   #
    17     17   # After the "tsrc" directory has been created and populated, run
    18     18   # this script:
    19     19   #
    20     20   #      tclsh mksqlite3c.tcl --srcdir $SRC
    21     21   #
................................................................................
    24     24   
    25     25   # Begin by reading the "sqlite3.h" header file.  Extract the version number
    26     26   # from in this file.  The version number is needed to generate the header
    27     27   # comment of the amalgamation.
    28     28   #
    29     29   set addstatic 1
    30     30   set linemacros 0
           31  +set useapicall 0
    31     32   for {set i 0} {$i<[llength $argv]} {incr i} {
    32     33     set x [lindex $argv $i]
    33     34     if {[regexp {^-+nostatic$} $x]} {
    34     35       set addstatic 0
    35     36     } elseif {[regexp {^-+linemacros} $x]} {
    36     37       set linemacros 1
           38  +  } elseif {[regexp {^-+useapicall} $x]} {
           39  +    set useapicall 1
    37     40     } else {
    38     41       error "unknown command-line option: $x"
    39     42     }
    40     43   }
    41     44   set in [open tsrc/sqlite3.h]
    42     45   set cnt 0
    43     46   set VERSION ?????
................................................................................
    55     58   set out [open sqlite3.c w]
    56     59   # Force the output to use unix line endings, even on Windows.
    57     60   fconfigure $out -translation lf
    58     61   set today [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S UTC" -gmt 1]
    59     62   puts $out [subst \
    60     63   {/******************************************************************************
    61     64   ** This file is an amalgamation of many separate C source files from SQLite
    62         -** version $VERSION.  By combining all the individual C code files into this 
           65  +** version $VERSION.  By combining all the individual C code files into this
    63     66   ** single large file, the entire code can be compiled as a single translation
    64     67   ** unit.  This allows many compilers to do optimizations that would not be
    65     68   ** possible if the files were compiled separately.  Performance improvements
    66     69   ** of 5% or more are commonly seen when SQLite is compiled as a single
    67     70   ** translation unit.
    68     71   **
    69     72   ** This file is all you need to compile SQLite.  To use SQLite in other
    70     73   ** programs, you need this file and the "sqlite3.h" header file that defines
    71         -** the programming interface to the SQLite library.  (If you do not have 
           74  +** the programming interface to the SQLite library.  (If you do not have
    72     75   ** the "sqlite3.h" header file at hand, you will find a copy embedded within
    73     76   ** the text of this file.  Search for "Begin file sqlite3.h" to find the start
    74     77   ** of the embedded sqlite3.h header file.) Additional code files may be needed
    75     78   ** if you want a wrapper to interface SQLite with your choice of programming
    76     79   ** language. The code for the "sqlite3" command-line shell is also in a
    77     80   ** separate file. This file contains only code for the core SQLite library.
    78     81   */
................................................................................
    81     84   if {$addstatic} {
    82     85     puts $out \
    83     86   {#ifndef SQLITE_PRIVATE
    84     87   # define SQLITE_PRIVATE static
    85     88   #endif}
    86     89   }
    87     90   
    88         -# These are the header files used by SQLite.  The first time any of these 
           91  +# These are the header files used by SQLite.  The first time any of these
    89     92   # files are seen in a #include statement in the C code, include the complete
    90     93   # text of the file in-line.  The file only needs to be included once.
    91     94   #
    92     95   foreach hdr {
    93     96      btree.h
    94     97      btreeInt.h
    95     98      fts3.h
................................................................................
   108    111      os.h
   109    112      pager.h
   110    113      parse.h
   111    114      pcache.h
   112    115      pragma.h
   113    116      rtree.h
   114    117      sqlite3session.h
   115         -   sqlite3ext.h
   116    118      sqlite3.h
   117    119      sqlite3ext.h
   118    120      sqlite3rbu.h
   119    121      sqliteicu.h
   120    122      sqliteInt.h
   121    123      sqliteLimit.h
   122    124      vdbe.h
................................................................................
   162    164   }
   163    165   
   164    166   # Read the source file named $filename and write it into the
   165    167   # sqlite3.c output file.  If any #include statements are seen,
   166    168   # process them appropriately.
   167    169   #
   168    170   proc copy_file {filename} {
   169         -  global seen_hdr available_hdr varonly_hdr cdecllist out addstatic linemacros
          171  +  global seen_hdr available_hdr varonly_hdr cdecllist out
          172  +  global addstatic linemacros useapicall
   170    173     set ln 0
   171    174     set tail [file tail $filename]
   172    175     section_comment "Begin file $tail"
   173    176     if {$linemacros} {puts $out "#line 1 \"$filename\""}
   174    177     set in [open $filename r]
   175    178     set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+(sqlite3[_a-zA-Z0-9]+)(\[|;| =)}
   176    179     set declpattern {([a-zA-Z][a-zA-Z_0-9 ]+ \**)(sqlite3[_a-zA-Z0-9]+)(\(.*)}
................................................................................
   225    228           # so that linkage can be modified at compile-time.
   226    229           if {[regexp {^sqlite3[a-z]*_} $funcname]} {
   227    230             set line SQLITE_API
   228    231             append line " " [string trim $rettype]
   229    232             if {[string index $rettype end] ne "*"} {
   230    233               append line " "
   231    234             }
   232         -          if {[lsearch -exact $cdecllist $funcname] >= 0} {
   233         -            append line SQLITE_CDECL
   234         -          } else {
   235         -            append line SQLITE_STDCALL
          235  +          if {$useapicall} {
          236  +            if {[lsearch -exact $cdecllist $funcname] >= 0} {
          237  +              append line SQLITE_CDECL " "
          238  +            } else {
          239  +              append line SQLITE_APICALL " "
          240  +            }
   236    241             }
   237         -          append line " " $funcname $rest
          242  +          append line $funcname $rest
   238    243             puts $out $line
   239    244           } else {
   240    245             puts $out "SQLITE_PRIVATE $line"
   241    246           }
   242    247         } elseif {[regexp $varpattern $line all varname]} {
   243    248             # Add the SQLITE_PRIVATE before variable declarations or
   244    249             # definitions for internal use

Changes to tool/mksqlite3h.tcl.

     6      6   #   1) The src/sqlite.h.in source file.  This is the template for sqlite3.h.
     7      7   #   2) The VERSION file containing the current SQLite version number.
     8      8   #   3) The manifest file from the fossil SCM.  This gives use the date.
     9      9   #   4) The manifest.uuid file from the fossil SCM.  This gives the SHA1 hash.
    10     10   #
    11     11   # Run this script by specifying the root directory of the source tree
    12     12   # on the command-line.
    13         -# 
           13  +#
    14     14   # This script performs processing on src/sqlite.h.in. It:
    15     15   #
    16     16   #   1) Adds SQLITE_EXTERN in front of the declaration of global variables,
    17     17   #   2) Adds SQLITE_API in front of the declaration of API functions,
    18         -#   3) Replaces the string --VERS-- with the current library version, 
           18  +#   3) Replaces the string --VERS-- with the current library version,
    19     19   #      formatted as a string (e.g. "3.6.17"), and
    20     20   #   4) Replaces the string --VERSION-NUMBER-- with current library version,
    21     21   #      formatted as an integer (e.g. "3006017").
    22         -#   5) Replaces the string --SOURCE-ID-- with the date and time and sha1 
           22  +#   5) Replaces the string --SOURCE-ID-- with the date and time and sha1
    23     23   #      hash of the fossil-scm manifest for the source tree.
           24  +#   6) Adds the SQLITE_CALLBACK calling convention macro in front of all
           25  +#      callback declarations.
    24     26   #
    25     27   # This script outputs to stdout.
    26     28   #
    27     29   # Example usage:
    28     30   #
    29     31   #   tclsh mksqlite3h.tcl ../sqlite >sqlite3.h
    30     32   #
    31     33   
    32     34   
    33     35   # Get the source tree root directory from the command-line
    34     36   #
    35     37   set TOP [lindex $argv 0]
           38  +
           39  +# Enable use of SQLITE_APICALL macros at the right points?
           40  +#
           41  +set useapicall 0
           42  +
           43  +if {[lsearch -regexp [lrange $argv 1 end] {^-+useapicall}] != -1} {
           44  +  set useapicall 1
           45  +}
    36     46   
    37     47   # Get the SQLite version number (ex: 3.6.18) from the $TOP/VERSION file.
    38     48   #
    39     49   set in [open $TOP/VERSION]
    40     50   set zVersion [string trim [read $in]]
    41     51   close $in
    42     52   set nVersion [eval format "%d%03d%03d" [split $zVersion .]]
................................................................................
    92    102   #
    93    103   foreach file $filelist {
    94    104     set in [open $file]
    95    105     if {![regexp {sqlite\.h\.in} $file]} {
    96    106       puts "/******** Begin file [file tail $file] *********/"
    97    107     }
    98    108     while {![eof $in]} {
    99         -  
          109  +
   100    110       set line [gets $in]
   101    111   
   102    112       # File sqlite3rtree.h contains a line "#include <sqlite3.h>". Omit this
   103    113       # line when copying sqlite3rtree.h into sqlite3.h.
   104    114       #
   105    115       if {[string match {*#include*[<"]sqlite3.h[>"]*} $line]} continue
   106         -  
          116  +
   107    117       regsub -- --VERS--           $line $zVersion line
   108    118       regsub -- --VERSION-NUMBER-- $line $nVersion line
   109    119       regsub -- --SOURCE-ID--      $line "$zDate $zUuid" line
   110    120   
   111    121       if {[regexp $varpattern $line] && ![regexp {^ *typedef} $line]} {
   112    122         set line "SQLITE_API $line"
   113    123       } else {
   114    124         if {[regexp $declpattern $line all rettype funcname rest]} {
   115    125           set line SQLITE_API
   116    126           append line " " [string trim $rettype]
   117    127           if {[string index $rettype end] ne "*"} {
   118    128             append line " "
   119    129           }
   120         -        if {[lsearch -exact $cdecllist $funcname] >= 0} {
   121         -          append line SQLITE_CDECL
   122         -        } else {
   123         -          append line SQLITE_STDCALL
          130  +        if {$useapicall} {
          131  +          if {[lsearch -exact $cdecllist $funcname] >= 0} {
          132  +            append line SQLITE_CDECL " "
          133  +          } else {
          134  +            append line SQLITE_APICALL " "
          135  +          }
   124    136           }
   125         -        append line " " $funcname $rest
          137  +        append line $funcname $rest
   126    138         }
   127    139       }
          140  +    if {$useapicall} {
          141  +      set line [string map [list (*sqlite3_syscall_ptr) \
          142  +          "(SQLITE_SYSAPI *sqlite3_syscall_ptr)"] $line]
          143  +      regsub {\(\*} $line {(SQLITE_CALLBACK *} line
          144  +    }
   128    145       puts $line
   129    146     }
   130    147     close $in
   131    148     if {![regexp {sqlite\.h\.in} $file]} {
   132    149       puts "/******** End of [file tail $file] *********/"
   133    150     }
   134    151   }