[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pq c6286f3dc9 4/4: Merge pull request #23 from tgbugs/m
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pq c6286f3dc9 4/4: Merge pull request #23 from tgbugs/master |
Date: |
Sun, 19 Jun 2022 20:58:00 -0400 (EDT) |
branch: externals/pq
commit c6286f3dc979cc6b151f91ca49d86ab1be547052
Merge: cb47fcf769 630c0382f1
Author: Mario Rodas <marsam@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Merge pull request #23 from tgbugs/master
pq-compile, and license header fixes
---
.gitignore | 3 +++
Makefile | 2 +-
pg_type.h | 2 ++
pq-compile.el | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++
pq-core.c | 3 ++-
test.el => pq-test.el | 21 +++++++++++++++++++
pq.el | 24 ++++++++++++++++++---
7 files changed, 108 insertions(+), 5 deletions(-)
diff --git a/.gitignore b/.gitignore
index 9f8c20a9e2..2c16467025 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,7 @@
*.so
#*#
+*.elc
+/pq-autoloads.el
+/pq-pkg.el
diff --git a/Makefile b/Makefile
index 9712526fe1..c4b37f0344 100644
--- a/Makefile
+++ b/Makefile
@@ -29,4 +29,4 @@ clean:
$(RM) $(TARGET)
check: $(TARGET)
- $(EMACS) --batch -Q -l ert -l test.el -f ert-run-tests-batch-and-exit
+ $(EMACS) --batch -Q -l ert -l pq-test.el -f ert-run-tests-batch-and-exit
diff --git a/pg_type.h b/pg_type.h
index 79daedaf17..7e5c268f3d 100644
--- a/pg_type.h
+++ b/pg_type.h
@@ -3,6 +3,8 @@
* pg_type.h
* Hard-wired knowledge about some standard type OIDs.
*
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
* XXX keep this in sync with src/include/catalog/pg_type.h
*
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
diff --git a/pq-compile.el b/pq-compile.el
new file mode 100644
index 0000000000..5899ce7620
--- /dev/null
+++ b/pq-compile.el
@@ -0,0 +1,58 @@
+;;; pq-compile.el --- Compile the `pq-core` module -*- lexical-binding: t;
-*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(defvar pq--compile-directory
+ (file-name-directory
+ (or
+ (if (fboundp 'macroexp-file-name) (macroexp-file-name)) ;Emacs≥28
+ load-file-name
+ buffer-file-name
+ (locate-library "pq"))))
+
+(defun pq--compile-module ()
+ "Compile the `pq-core' module."
+ (with-temp-buffer
+ (setq default-directory pq--compile-directory)
+ (let* ((exitcode (call-process "make" nil t)))
+ (if (zerop exitcode)
+ (message "Compilation of `pq-core' succeeded")
+ (let ((out (buffer-string)))
+ (with-current-buffer (get-buffer-create "*pq-compile*")
+ (setq default-directory pq--compile-directory)
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (insert out))
+ (compilation-mode)
+ (pop-to-buffer (current-buffer))
+ (error "Compilation of `pq-core' failed")))))))
+
+(defun pq--compile-maybe ()
+ ;; FIXME: Should we first try it silently (i.e. without prompting the user)?
+ (if (not (y-or-n-p "PQ needs to compile the `pq-core' module. Do it now?"))
+ (message "Continuing without `pq-core'; some operations may fail")
+ (pq--compile-module)
+ (require 'pq-core)))
+
+
+(provide 'pq-compile)
+;;; pq-compile.el ends here
diff --git a/pq-core.c b/pq-core.c
index e665331370..4c451b101e 100644
--- a/pq-core.c
+++ b/pq-core.c
@@ -1,5 +1,6 @@
/* libpq bindings for Emacs Lisp as a dynamic module
- Copyright (C) 2020-2022 Free Software Foundation, Inc.
+
+Copyright (C) 2020-2022 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/test.el b/pq-test.el
similarity index 84%
rename from test.el
rename to pq-test.el
index 4988725e24..677ebac54f 100644
--- a/test.el
+++ b/pq-test.el
@@ -1,3 +1,22 @@
+;;; pq-test.el --- test libpq bindings -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2020-2022 Free Software Foundation, Inc.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
(add-to-list 'load-path
(file-name-directory (or #$ (expand-file-name
(buffer-file-name)))))
@@ -124,3 +143,5 @@
(should-error (pq:query conn "select pg_terminate_backend($1)" mypid))
(should-error (pq:notifies conn))
))
+
+;;; pq-test.el ends here
diff --git a/pq.el b/pq.el
index b7a943355b..69ef12c5a2 100644
--- a/pq.el
+++ b/pq.el
@@ -1,8 +1,8 @@
-;;; pq.el --- libpq binding
+;;; pq.el --- libpq binding -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2022 Free Software Foundation, Inc.
-;; Author: Tom Gillespie
+;; Author: Tom Gillespie <tgbugs@gmail.com>
;; URL: https://github.com/anse1/emacs-libpq
;; Version: 0.01
;; Package-Requires: ((emacs "25"))
@@ -26,7 +26,25 @@
;;; Code:
-(if t (require 'pq-core))
+(require 'pq-core nil t) ; Don't signal an error if the module is absent.
+
+;; Try and compile the `pq-core' module when we compile the PQ package.
+(eval-when-compile
+ (unless (or (featurep 'pq-core)
+ ;; Try and avoid running this code when we're just
+ ;; loading the uncompiled `pq.el'.
+ (and (fboundp 'macroexp-compiling-p) ;Emacs≥28
+ (not (macroexp-compiling-p))))
+ (require 'pq-compile)
+ (declare-function pq--compile-module "pq-compile" ())
+ (ignore-errors (pq--compile-module))))
+
+;; Try and compile the `pq-core' module when the PQ package is loaded.
+(unless (featurep 'pq-core)
+ (require 'pq-compile)
+ (declare-function pq--compile-maybe "pq-compile" ())
+ (pq--compile-maybe))
+
(provide 'pq)