From f9554ee3dfb3d943baa665eab0b9a829b8f5a3c3 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Fri, 26 Apr 2019 23:08:55 +0200 Subject: [PATCH] Hook up SQLite in build system, scaffold SQLite repository. --- configure | 52 ++++++++++++++++++- .../sqlite/KeyValueRepositorySqlite.cxx | 43 +++++++++++++++ .../sqlite/KeyValueRepositorySqlite.hxx | 36 +++++++++++++ src/common/repository/sqlite/module.mk | 10 ++++ src/emucore/OSystem.cxx | 14 +++-- 5 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 src/common/repository/sqlite/KeyValueRepositorySqlite.cxx create mode 100644 src/common/repository/sqlite/KeyValueRepositorySqlite.hxx create mode 100644 src/common/repository/sqlite/module.mk diff --git a/configure b/configure index be222696a..eb2f0a09c 100755 --- a/configure +++ b/configure @@ -21,6 +21,7 @@ _build_joystick=yes _build_cheats=yes _build_png=yes _build_zip=yes +_build_sqlite=no _build_static=no _build_profile=no _build_debug=no @@ -201,6 +202,8 @@ Optional Features: --disable-png --enable-zip enable/disable ZIP file support [enabled] --disable-zip + --enable-sqlite enable SQLite for storing settings and preferences [disabled] + --disable-sqlite --enable-windowed enable/disable windowed rendering modes [enabled] --disable-windowed --enable-shared build shared binary [enabled] @@ -215,6 +218,7 @@ Optional Libraries: --with-sdl-prefix=DIR Prefix where the sdl2-config script is installed (optional) --with-libpng-prefix=DIR Prefix where libpng is installed (optional) --with-zlib-prefix=DIR Prefix where zlib is installed (optional) + --with-sqlite-prefix=DIR PREFIX where sqlite is installed (optional) Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a @@ -243,13 +247,15 @@ for ac_option in $@; do --disable-png) _build_png=no ;; --enable-zip) _build_zip=yes ;; --disable-zip) _build_zip=no ;; + --enable-sqlite) _build_sqlite=yes ;; + --disable-sqlite) _build_sqlite=no ;; --enable-windowed) _build_windowed=yes ;; --disable-windowed) _build_windowed=no ;; --enable-shared) _build_static=no ;; --enable-static) _build_static=yes ;; --disable-static) _build_static=no ;; --enable-profile) _build_profile=yes ;; - --disable-profile) _build_profile=no ;; + # --disable-profile) _build_profile=no ;; --enable-debug) _build_debug=yes ;; --disable-debug) _build_debug=false ;; --with-sdl-prefix=*) @@ -265,6 +271,11 @@ for ac_option in $@; do _prefix=`echo $ac_option | cut -d '=' -f 2` ZLIB_CFLAGS="-I$_prefix/include" ZLIB_LIBS="-L$_prefix/lib" + ;; + --with-sqlite-prefix=*) + _prefix=`echo $ac_option | cut -d '=' -f 2` + SQLITE_CFLAGS="-I$_prefix/include" + SQLITE_LIBS="-L$_prefix/lib" ;; --host=*) _host=`echo $ac_option | cut -d '=' -f 2` @@ -640,6 +651,30 @@ else _build_png=no fi +# +# Check for SQLite +# +echocheck "SQLite" +if test "$_build_sqlite" = yes ; then + _sqlite=no + cat > $TMPC << EOF +#include +#include +int main(void) { printf("%s\n", SQLITE_VERSION); } +EOF + cc_check $LDFLAGS $CXXFLAGS $SQLITE_CFLAGS $SQLITE_LIBS -lsqlite3 && _sqlite=yes + + if test "$_sqlite" = yes ; then + echo "$_sqlite" + else + echo "disabled" + _build_sqlite=no + fi +else + echo "disabled" + _build_sqlite=no +fi + # # figure out installation directories # @@ -699,6 +734,14 @@ else echo fi +if test "$_build_sqlite" = yes ; then + echo_n " SQLite enabled" + echo +else + echo_n " SQLite disabled" + echo +fi + if test "$_build_windowed" = "yes" ; then echo_n " Windowed rendering modes enabled" echo @@ -752,6 +795,7 @@ YACC="$SRC/yacc" CHEAT="$SRC/cheat" LIBPNG="$SRC/libpng" ZLIB="$SRC/zlib" +SQLITE="$SRC/common/repository/sqlite" INCLUDES="-I$CORE -I$COMMON -I$TV -I$GUI -I$TIA -I$TIA_FRAME_MANAGER" @@ -828,6 +872,12 @@ if test "$_build_png" = yes ; then fi fi +if test "$_build_sqlite" = yes; then + DEFINES="$DEFINES -DSQLITE_SUPPORT" + MODULES="$MODULES $SQLITE" + INCLUDES="$INCLUDES -I$SQLITE" +fi + if test "$_build_zip" = yes ; then DEFINES="$DEFINES -DZIP_SUPPORT" if test "$_zlib" = yes ; then diff --git a/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx b/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx new file mode 100644 index 000000000..7601f4010 --- /dev/null +++ b/src/common/repository/sqlite/KeyValueRepositorySqlite.cxx @@ -0,0 +1,43 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#include + +#include "KeyValueRepositorySqlite.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +KeyValueRepositorySqlite::KeyValueRepositorySqlite( + const string& databaseDirectory, + const string& databaseName +) +{} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +KeyValueRepositorySqlite::~KeyValueRepositorySqlite() +{} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +std::map KeyValueRepositorySqlite::load() +{ + std::map values; + + return values; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void KeyValueRepositorySqlite::save(const std::map& values) +{} diff --git a/src/common/repository/sqlite/KeyValueRepositorySqlite.hxx b/src/common/repository/sqlite/KeyValueRepositorySqlite.hxx new file mode 100644 index 000000000..d5767ff86 --- /dev/null +++ b/src/common/repository/sqlite/KeyValueRepositorySqlite.hxx @@ -0,0 +1,36 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#ifndef KEY_VALUE_REPOSITORY_SQLITE_HXX +#define KEY_VALUE_REPOSITORY_SQLITE_HXX + +#include "repository/KeyValueRepository.hxx" + +class KeyValueRepositorySqlite : public KeyValueRepository +{ + public: + + KeyValueRepositorySqlite(const string& databaseDirectory, const string& databaseName); + + ~KeyValueRepositorySqlite(); + + virtual std::map load(); + + virtual void save(const std::map& values); +}; + +#endif // KEY_VALUE_REPOSITORY_SQLITE_HXX diff --git a/src/common/repository/sqlite/module.mk b/src/common/repository/sqlite/module.mk new file mode 100644 index 000000000..d23fcb37c --- /dev/null +++ b/src/common/repository/sqlite/module.mk @@ -0,0 +1,10 @@ +MODULE := src/common/repository/sqlite + +MODULE_OBJS := \ + src/common/repository/sqlite/KeyValueRepositorySqlite.o + +MODULE_DIRS += \ + src/common/repository/sqlite + +# Include common rules +include $(srcdir)/common.rules diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 7adb60466..a8201ffbb 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -30,6 +30,10 @@ #include "CheatManager.hxx" #endif +#ifdef SQLITE_SUPPORT + #include "KeyValueRepositorySqlite.hxx" +#endif + #include "FSNode.hxx" #include "MD5.hxx" #include "Cart.hxx" @@ -746,10 +750,14 @@ void OSystem::mainLoop() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - shared_ptr OSystem::createSettingsRepository() { - if (myConfigFile.empty()) - return make_shared(); + #ifdef SQLITE_SUPPORT + return make_shared(myBaseDir, "settings"); + #else + if (myConfigFile.empty()) + return make_shared(); - return make_shared(myConfigFile); + return make_shared(myConfigFile); + #endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -