Skip to content

Commit

Permalink
Allow to build without Tcl callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
chpock committed Oct 12, 2024
1 parent 99620e3 commit e7bea19
Show file tree
Hide file tree
Showing 21 changed files with 337 additions and 93 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
- compiler: gcc
configure: "--disable-c-crypto"
description: "no crypto"
- compiler: gcc
configure: "--disable-tcl-callbacks"
description: "no tcl-callbacks"
name: build (${{ matrix.compiler }}, ${{ matrix.description }})
steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Add a fileset feature to VFS
* Allow to link with zlib directly (without Tcl layer)
* Allow to link with mbedtls and use its crypto functions
* Allow to build without Tcl callbacks

2024-10-10 Konstantin Kushnir <[email protected]>
* Add a fileset feature to fsindex
Expand Down
4 changes: 0 additions & 4 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

* Add documentation as HTML to github pages

* Add ability to disable custom compression to reduce size footprint when it is not needed

* Add ability to disable async compression to reduce size footprint when it is not needed

* Update bzip2 and use it as a submodule. Perhaps this will get rid of its compile-time warnings.

* Add ability/subcommand to copy files from/to cookfs more efficiently than using 'file copy'.
Expand Down
71 changes: 60 additions & 11 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ GREP
COOKFS_PKGCONFIG_USECPKGCONFIG
COOKFS_PKGCONFIG_FEATURE_CRYPTO
COOKFS_PKGCONFIG_USECCRYPTO
COOKFS_PKGCONFIG_USECALLBACKS
COOKFS_PKGCONFIG_USETCLCMDS
COOKFS_PKGCONFIG_USECWRITER
COOKFS_PKGCONFIG_USECVFS
Expand Down Expand Up @@ -798,7 +799,6 @@ enable_bz2
enable_lzma
enable_zstd
enable_brotli
enable_tcl_fallback
enable_c_pages
enable_c_fsindex
enable_c_readerchannel
Expand All @@ -808,6 +808,7 @@ enable_c_vfs
enable_c_writer
enable_c_crypto
enable_tcl_commands
enable_tcl_callbacks
with_zlib
with_mbedtls
'
Expand Down Expand Up @@ -1454,7 +1455,6 @@ Optional Features:
--disable-lzma Use lzma compression. Defaults to true
--enable-zstd Use zstd compression. Defaults to false
--enable-brotli Use brotli compression. Defaults to false
--enable-tcl-fallback Install Tcl scripts if load fails. Defaults to false
--disable-c-pages Use pages handling written in C. Defaults to true
--disable-c-fsindex Use index handling written in C. Defaults to true
--disable-c-readerchannel Use reader handler written in C. Defaults to true
Expand All @@ -1464,6 +1464,7 @@ Optional Features:
--disable-c-writer Use writer handler written in C. Defaults to true
--disable-c-crypto Use crypto functions written in C. Defaults to true
--disable-tcl-commands Enable Tcl commands for objects. Defaults to true
--disable-tcl-callbacks Enable Tcl callbacks for compression. Defaults to true
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
Expand Down Expand Up @@ -8796,14 +8797,6 @@ else $as_nop
USEBROTLI=no
fi

# Check whether --enable-tcl-fallback was given.
if test ${enable_tcl_fallback+y}
then :
enableval=$enable_tcl_fallback; USEFALLBACK=${enableval}
else $as_nop
USEFALLBACK=no
fi

# Check whether --enable-c-pages was given.
if test ${enable_c_pages+y}
then :
Expand Down Expand Up @@ -8876,6 +8869,14 @@ else $as_nop
USETCLCMDS=yes
fi

# Check whether --enable-tcl-callbacks was given.
if test ${enable_tcl_callbacks+y}
then :
enableval=$enable_tcl_callbacks; USECALLBACKS=${enableval}
else $as_nop
USECALLBACKS=yes
fi



# Check whether --with-zlib was given.
Expand Down Expand Up @@ -8941,7 +8942,7 @@ if test ${USECPAGES} = yes; then
COOKFS_PKGCONFIG_USECPAGES=1
COOKFS_PKGCONFIG_FEATURE_ASIDE=1

vars="pgindex.c pageObj.c pages.c pagesCompr.c pagesAsync.c pagesComprZlib.c pagesComprCustom.c pagesCmd.c"
vars="pgindex.c pageObj.c pages.c pagesCompr.c pagesComprZlib.c pagesCmd.c"
for i in $vars; do
case $i in
\$*)
Expand Down Expand Up @@ -10119,6 +10120,52 @@ else
COOKFS_PKGCONFIG_USETCLCMDS=1
fi

if test ${USECALLBACKS} = yes; then
printf "%s\n" "#define COOKFS_USECALLBACKS 1" >>confdefs.h

COOKFS_PKGCONFIG_USECALLBACKS=1
if test ${USECPAGES} = yes; then

vars="pagesAsync.c pagesComprCustom.c"
for i in $vars; do
case $i in
\$*)
# allow $-var names
PKG_SOURCES="$PKG_SOURCES $i"
PKG_OBJECTS="$PKG_OBJECTS $i"
;;
*)
# check for existence - allows for generic/win/unix VPATH
# To add more dirs here (like 'src'), you have to update VPATH
# in Makefile.in as well
if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
-a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
-a ! -f "${srcdir}/macosx/$i" \
; then
as_fn_error $? "could not find source file '$i'" "$LINENO" 5
fi
PKG_SOURCES="$PKG_SOURCES $i"
# this assumes it is in a VPATH dir
i=`basename $i`
# handle user calling this before or after TEA_SETUP_COMPILER
if test x"${OBJEXT}" != x ; then
j="`echo $i | sed -e 's/\.[^.]*$//'`.${OBJEXT}"
else
j="`echo $i | sed -e 's/\.[^.]*$//'`.\${OBJEXT}"
fi
PKG_OBJECTS="$PKG_OBJECTS $j"
;;
esac
done



fi
else
COOKFS_PKGCONFIG_USECALLBACKS=0
fi





Expand Down Expand Up @@ -10165,6 +10212,8 @@ if test ${USECPKGCONFIG} = yes; then

printf "%s\n" "#define COOKFS_PKGCONFIG_USETCLCMDS $COOKFS_PKGCONFIG_USETCLCMDS" >>confdefs.h

printf "%s\n" "#define COOKFS_PKGCONFIG_USECALLBACKS $COOKFS_PKGCONFIG_USECALLBACKS" >>confdefs.h

printf "%s\n" "#define COOKFS_PKGCONFIG_USECCRYPTO $COOKFS_PKGCONFIG_USECCRYPTO" >>confdefs.h

printf "%s\n" "#define COOKFS_PKGCONFIG_FEATURE_CRYPTO $COOKFS_PKGCONFIG_FEATURE_CRYPTO" >>confdefs.h
Expand Down
44 changes: 28 additions & 16 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,21 @@ if test "${SHARED_BUILD}" = "1"; then
AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs])
fi

AC_ARG_ENABLE(internal-debug, [ --enable-internal-debug Enable internal debugging mechanism. Defaults to false],INTERNALDEBUG=${enableval}, INTERNALDEBUG=no)
AC_ARG_ENABLE(bz2, [ --enable-bz2 Use bz2 compression. Defaults to false], USEBZ2=${enableval}, USEBZ2=no)
AC_ARG_ENABLE(lzma, [ --disable-lzma Use lzma compression. Defaults to true], USELZMA=${enableval}, USELZMA=yes)
AC_ARG_ENABLE(zstd, [ --enable-zstd Use zstd compression. Defaults to false], USEZSTD=${enableval}, USEZSTD=no)
AC_ARG_ENABLE(brotli, [ --enable-brotli Use brotli compression. Defaults to false], USEBROTLI=${enableval}, USEBROTLI=no)
AC_ARG_ENABLE(tcl-fallback, [ --enable-tcl-fallback Install Tcl scripts if load fails. Defaults to false], USEFALLBACK=${enableval}, USEFALLBACK=no)
AC_ARG_ENABLE(c-pages, [ --disable-c-pages Use pages handling written in C. Defaults to true], USECPAGES=${enableval}, USECPAGES=yes)
AC_ARG_ENABLE(c-fsindex, [ --disable-c-fsindex Use index handling written in C. Defaults to true], USECFSINDEX=${enableval}, USECFSINDEX=yes)
AC_ARG_ENABLE(c-readerchannel, [ --disable-c-readerchannel Use reader handler written in C. Defaults to true], USECREADERCHAN=${enableval}, USECREADERCHAN=yes)
AC_ARG_ENABLE(c-writerchannel, [ --disable-c-writerchannel Use writer handler written in C. Defaults to true], USECWRITERCHAN=${enableval}, USECWRITERCHAN=yes)
AC_ARG_ENABLE(c-pkgconfig, [ --disable-c-pkgconfig Use pkgconfig written in C. Defaults to true], USECPKGCONFIG=${enableval}, USECPKGCONFIG=yes)
AC_ARG_ENABLE(c-vfs, [ --disable-c-vfs Use VFS support written in C. Defaults to true], USECVFS=${enableval}, USECVFS=yes)
AC_ARG_ENABLE(c-writer, [ --disable-c-writer Use writer handler written in C. Defaults to true], USECWRITER=${enableval}, USECWRITER=yes)
AC_ARG_ENABLE(c-crypto, [ --disable-c-crypto Use crypto functions written in C. Defaults to true], USECCRYPTO=${enableval}, USECCRYPTO=yes)
AC_ARG_ENABLE(tcl-commands, [ --disable-tcl-commands Enable Tcl commands for objects. Defaults to true], USETCLCMDS=${enableval}, USETCLCMDS=yes)
AC_ARG_ENABLE(internal-debug, [ --enable-internal-debug Enable internal debugging mechanism. Defaults to false], INTERNALDEBUG=${enableval}, INTERNALDEBUG=no)
AC_ARG_ENABLE(bz2, [ --enable-bz2 Use bz2 compression. Defaults to false], USEBZ2=${enableval}, USEBZ2=no)
AC_ARG_ENABLE(lzma, [ --disable-lzma Use lzma compression. Defaults to true], USELZMA=${enableval}, USELZMA=yes)
AC_ARG_ENABLE(zstd, [ --enable-zstd Use zstd compression. Defaults to false], USEZSTD=${enableval}, USEZSTD=no)
AC_ARG_ENABLE(brotli, [ --enable-brotli Use brotli compression. Defaults to false], USEBROTLI=${enableval}, USEBROTLI=no)
AC_ARG_ENABLE(c-pages, [ --disable-c-pages Use pages handling written in C. Defaults to true], USECPAGES=${enableval}, USECPAGES=yes)
AC_ARG_ENABLE(c-fsindex, [ --disable-c-fsindex Use index handling written in C. Defaults to true], USECFSINDEX=${enableval}, USECFSINDEX=yes)
AC_ARG_ENABLE(c-readerchannel, [ --disable-c-readerchannel Use reader handler written in C. Defaults to true], USECREADERCHAN=${enableval}, USECREADERCHAN=yes)
AC_ARG_ENABLE(c-writerchannel, [ --disable-c-writerchannel Use writer handler written in C. Defaults to true], USECWRITERCHAN=${enableval}, USECWRITERCHAN=yes)
AC_ARG_ENABLE(c-pkgconfig, [ --disable-c-pkgconfig Use pkgconfig written in C. Defaults to true], USECPKGCONFIG=${enableval}, USECPKGCONFIG=yes)
AC_ARG_ENABLE(c-vfs, [ --disable-c-vfs Use VFS support written in C. Defaults to true], USECVFS=${enableval}, USECVFS=yes)
AC_ARG_ENABLE(c-writer, [ --disable-c-writer Use writer handler written in C. Defaults to true], USECWRITER=${enableval}, USECWRITER=yes)
AC_ARG_ENABLE(c-crypto, [ --disable-c-crypto Use crypto functions written in C. Defaults to true], USECCRYPTO=${enableval}, USECCRYPTO=yes)
AC_ARG_ENABLE(tcl-commands, [ --disable-tcl-commands Enable Tcl commands for objects. Defaults to true], USETCLCMDS=${enableval}, USETCLCMDS=yes)
AC_ARG_ENABLE(tcl-callbacks, [ --disable-tcl-callbacks Enable Tcl callbacks for compression. Defaults to true], USECALLBACKS=${enableval}, USECALLBACKS=yes)

AC_ARG_WITH([zlib], [AS_HELP_STRING([--with-zlib=PATH], [prefix where zlib is installed (optional)])], WITH_ZLIB="${withval}", WITH_ZLIB="no")
AC_ARG_WITH([mbedtls], [AS_HELP_STRING([--with-mbedtls=PATH], [prefix where mbedtls is installed (optional)])], WITH_MBEDTLS="${withval}", WITH_MBEDTLS="no")
Expand All @@ -148,7 +148,7 @@ if test ${USECPAGES} = yes; then
AC_DEFINE(COOKFS_USECPAGES)
COOKFS_PKGCONFIG_USECPAGES=1
COOKFS_PKGCONFIG_FEATURE_ASIDE=1
TEA_ADD_SOURCES([pgindex.c pageObj.c pages.c pagesCompr.c pagesAsync.c pagesComprZlib.c pagesComprCustom.c pagesCmd.c])
TEA_ADD_SOURCES([pgindex.c pageObj.c pages.c pagesCompr.c pagesComprZlib.c pagesCmd.c])

# enable bz2 files only if pages are handled using C
if test ${USEBZ2} = yes; then
Expand Down Expand Up @@ -448,6 +448,16 @@ else
COOKFS_PKGCONFIG_USETCLCMDS=1
fi

if test ${USECALLBACKS} = yes; then
AC_DEFINE(COOKFS_USECALLBACKS)
COOKFS_PKGCONFIG_USECALLBACKS=1
if test ${USECPAGES} = yes; then
TEA_ADD_SOURCES([pagesAsync.c pagesComprCustom.c])
fi
else
COOKFS_PKGCONFIG_USECALLBACKS=0
fi

AC_SUBST(COOKFS_PKGCONFIG_FEATURE_ASIDE)
AC_SUBST(COOKFS_PKGCONFIG_USECPAGES)
AC_SUBST(COOKFS_PKGCONFIG_USECREADERCHAN)
Expand All @@ -461,6 +471,7 @@ AC_SUBST(COOKFS_PKGCONFIG_FEATURE_METADATA)
AC_SUBST(COOKFS_PKGCONFIG_USECVFS)
AC_SUBST(COOKFS_PKGCONFIG_USECWRITER)
AC_SUBST(COOKFS_PKGCONFIG_USETCLCMDS)
AC_SUBST(COOKFS_PKGCONFIG_USECALLBACKS)
AC_SUBST(COOKFS_PKGCONFIG_USECCRYPTO)
AC_SUBST(COOKFS_PKGCONFIG_FEATURE_CRYPTO)

Expand All @@ -480,6 +491,7 @@ if test ${USECPKGCONFIG} = yes; then
AC_DEFINE_UNQUOTED(COOKFS_PKGCONFIG_USECVFS, $COOKFS_PKGCONFIG_USECVFS)
AC_DEFINE_UNQUOTED(COOKFS_PKGCONFIG_USECWRITER, $COOKFS_PKGCONFIG_USECWRITER)
AC_DEFINE_UNQUOTED(COOKFS_PKGCONFIG_USETCLCMDS, $COOKFS_PKGCONFIG_USETCLCMDS)
AC_DEFINE_UNQUOTED(COOKFS_PKGCONFIG_USECALLBACKS, $COOKFS_PKGCONFIG_USECALLBACKS)
AC_DEFINE_UNQUOTED(COOKFS_PKGCONFIG_USECCRYPTO, $COOKFS_PKGCONFIG_USECCRYPTO)
AC_DEFINE_UNQUOTED(COOKFS_PKGCONFIG_FEATURE_CRYPTO, $COOKFS_PKGCONFIG_FEATURE_CRYPTO)

Expand Down
1 change: 1 addition & 0 deletions generic/cookfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ static Tcl_Config const cookfs_pkgconfig[] = {
{"feature-brotli", STRINGIFY(COOKFS_PKGCONFIG_USEBROTLI)},
{"feature-metadata", STRINGIFY(COOKFS_PKGCONFIG_FEATURE_METADATA)},
{"tcl-commands", STRINGIFY(COOKFS_PKGCONFIG_USETCLCMDS)},
{"tcl-callbacks", STRINGIFY(COOKFS_PKGCONFIG_USECALLBACKS)},
{"platform", COOKFS_PLATFORM},
{NULL, NULL}
};
Expand Down
Loading

0 comments on commit e7bea19

Please sign in to comment.