pekingduck / emacs-sqlite3-api

SQLite3 API for GNU Emacs 25+
GNU General Public License v3.0
62 stars 5 forks source link

Add a wrapper library so that this package can be distributed on Melpa #2

Closed tarsius closed 4 years ago

tarsius commented 4 years ago

I saw that the Makefile contains support for building a package.el-compatible package named sqlite3-api but think this should be available from Melpa so that third-party packages can actually start depending on this.

Melpa gets a packages metadata from the elisp library that matches the name of the package. This repository contained no such library. Because the name of the dynamic module is sqlite3-api.so, we cannot use sqlite3-api.el. Modules and libraries live in the same "namespace", which makes it possible to require both, so they cannot have conflicting names.

I went with sqlite3.el, which means that the package ends up being named sqlite3, which I personally think is a better name than sqlite3-api anyway. But if you don't want that, then you would have to rename sqlite3.el to sqlite3-api.el and sqlite3-api.c to something like e.g. sqlite3-api-module.c.

If you merge this, then I can take care of adding the module to Melpa (though you might have to take care of the review feedback). For now I have used this recipe for local testing:

(sqlite3
 ;; :fetcher github
 ;; :repo "pekingduck/emacs-sqlite3-api"
 ;; :repo "tarsiiformes/emacs-sqlite3-api"
 :fetcher git :url "/home/jonas/.emacs.d/lib/sqlite3"
 :branch "melpa-alt"
 :files (:defaults
     "Makefile"
     "consts.c"
     "emacs-module.h"
     "sqlite3-api.c"))

The wrapper library takes care of building the module if necessary (unlike your old attempt in the dummy-el branch).


Please note that this is currently used the melpa-alt, which does not branch of the latest master but from the commit before 781f915cd4ebbb5941b290aed7109c767e93f5d2. That commit breaks building for me, resulting in these errors:

$ make clean all
rm -rf *.so *.o *.tar sqlite3-api-0.13
gcc -g3 -Wall -std=c99 -I. -fPIC -c sqlite3-api.c
In file included from sqlite3-api.c:1096:
consts.c: In function ‘emacs_module_init’:
consts.c:127:77: error: ‘SQLITE_OPEN_FILEPROTECTION_COMPLETE’ undeclared (first use in this function); did you mean ‘SQLITE_OPEN_DELETEONCLOSE’?
 defconst(env, "sqlite-open-fileprotection-complete", env->make_integer(env, SQLITE_OPEN_FILEPROTECTION_COMPLETE));
                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                             SQLITE_OPEN_DELETEONCLOSE
consts.c:127:77: note: each undeclared identifier is reported only once for each function it appears in
consts.c:128:87: error: ‘SQLITE_OPEN_FILEPROTECTION_COMPLETEUNLESSOPEN’ undeclared (first use in this function)
 defconst(env, "sqlite-open-fileprotection-completeunlessopen", env->make_integer(env, SQLITE_OPEN_FILEPROTECTION_COMPLETEUNLESSOPEN));
                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
consts.c:129:105: error: ‘SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION’ undeclared (first use in this function)
 defconst(env, "sqlite-open-fileprotection-completeuntilfirstuserauthentication", env->make_integer(env, SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION));
                                                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
consts.c:130:73: error: ‘SQLITE_OPEN_FILEPROTECTION_NONE’ undeclared (first use in this function); did you mean ‘SQLITE_OPEN_DELETEONCLOSE’?
 defconst(env, "sqlite-open-fileprotection-none", env->make_integer(env, SQLITE_OPEN_FILEPROTECTION_NONE));
                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                         SQLITE_OPEN_DELETEONCLOSE
consts.c:131:73: error: ‘SQLITE_OPEN_FILEPROTECTION_MASK’ undeclared (first use in this function); did you mean ‘SQLITE_OPEN_DELETEONCLOSE’?
 defconst(env, "sqlite-open-fileprotection-mask", env->make_integer(env, SQLITE_OPEN_FILEPROTECTION_MASK));
                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                         SQLITE_OPEN_DELETEONCLOSE
consts.c:240:73: error: ‘SQLITE_DBCONFIG_WRITABLE_SCHEMA’ undeclared (first use in this function); did you mean ‘SQLITE_DBCONFIG_ENABLE_FKEY’?
 defconst(env, "sqlite-dbconfig-writable-schema", env->make_integer(env, SQLITE_DBCONFIG_WRITABLE_SCHEMA));
                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                         SQLITE_DBCONFIG_ENABLE_FKEY
make: *** [Makefile:55: sqlite3-api.o] Error 1
pekingduck commented 4 years ago

Thanks for the PR! Regarding the errors, I'll modify the way the SQLITE_* constants are generated. Seems like those in the error messages are only present in the newer sqlite3 but aren't needed by the Emacs module.

tarsius commented 4 years ago

You are welcome and thanks!

tarsius commented 4 years ago

With your latest commits and sqlite 3.27.2, which is the version on debian stable, I still get:

consts.c:247:73: error: ‘SQLITE_DBCONFIG_WRITABLE_SCHEMA’ undeclared (first use in this function); did you mean ‘SQLITE_DBCONFIG_ENABLE_FKEY’?
pekingduck commented 4 years ago

Ok fixed. Any SQLITE_* codes not in your local installation should not cause compilation error now.

tarsius commented 4 years ago

Thanks! I can confirm that it works now.