From: Eshel Yaron Date: Fri, 23 Sep 2022 15:44:10 +0000 (+0300) Subject: BUILD: replaced Makefile with CMakeLists.txt X-Git-Tag: v0.3.2~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=521a4bfde514f8cdb13df3c1cf9c7779b335933a;p=dict.git BUILD: replaced Makefile with CMakeLists.txt --- diff --git a/.build.yml b/.build.yml deleted file mode 100644 index 255b3c0..0000000 --- a/.build.yml +++ /dev/null @@ -1,52 +0,0 @@ -image: debian/stable -packages: - - build-essential - - cmake - - ninja-build - - pkg-config - - ncurses-dev - - libreadline-dev - - libedit-dev - - libgoogle-perftools-dev - - libgmp-dev - - libssl-dev - - unixodbc-dev - - zlib1g-dev - - libarchive-dev - - libossp-uuid-dev - - libxext-dev - - libice-dev - - libjpeg-dev - - libxinerama-dev - - libxft-dev - - libxpm-dev - - libxt-dev - - libdb-dev - - libpcre2-dev - - libyaml-dev - - zip - - git - - emacs -secrets: - - 750079bb-9735-473b-bebf-db897c9f0c6b - - 72d5c3dc-f83f-4cc2-96e3-b2b08f6ee8a0 -sources: - - git@git.sr.ht:~eshel/sweep -tasks: - - getswipl: | - git clone --recursive https://github.com/SWI-Prolog/swipl-devel.git - cd swipl-devel - mkdir build - cd build - export LANG="en_US.UTF-8" - sudo localectl set-locale LANG=en_US.UTF-8 - localectl set-locale LANG=en_US.UTF-8 - cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DSWIPL_INSTALL_IN_LIB=ON -DSWIPL_PACKAGES_ODBC=OFF -DSWIPL_PACKAGES_JAVA=OFF -DSWIPL_PACKAGES_X=OFF -DINSTALL_DOCUMENTATION=OFF -G Ninja .. - ninja - sudo ninja install - - build: | - cd sweep - export LD_LIBRARY_PATH=/usr/local/lib - make - make sweep.info - LD_PRELOAD=/usr/local/lib/libswipl.so make check diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2f2f561 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.5) +project(swipl-sweep) + +include("../cmake/PrologPackage.cmake") + +find_program(EMACS Emacs) + +find_path( + EMACS_INCLUDE_DIR + NAMES "emacs-module.h" + PATHS /Applications/Emacs.app/Contents/Resources/include +) + +if(EMACS_INCLUDE_DIR) + +swipl_plugin( + sweep-module + C_SOURCES sweep.c + C_INCLUDE_DIR ${EMACS_INCLUDE_DIR} + PL_LIBS sweep.pl) + +endif(EMACS_INCLUDE_DIR) diff --git a/Makefile b/Makefile deleted file mode 100644 index ca0f96d..0000000 --- a/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -BASENAME = sweep - -UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Linux) - SOEXT = so -endif -ifeq ($(UNAME_S),Darwin) - SOEXT = dylib -endif - -SWIPL ?= swipl -SWIPLBASE = $(shell $(SWIPL) --dump-runtime-variables | grep PLBASE | cut -f 2 -d = | cut -f 1 -d ';') -SWIPLLIBDIR = $(shell $(SWIPL) --dump-runtime-variables | grep PLLIBDIR | cut -f 2 -d = | cut -f 1 -d ';') - -EMACS ?= emacs - -TARGET = $(BASENAME)-module.$(SOEXT) -OBJECT = $(BASENAME).o -SOURCE = $(BASENAME).c - -LDFLAGS += -shared -LDFLAGS += -L$(SWIPLLIBDIR) -LDFLAGS += -lswipl - -CFLAGS += -fPIC -CFLAGS += -Wall -CFLAGS += -Wextra -CFLAGS += -O2 -CFLAGS += -I$(SWIPLBASE)/include - -.PHONY: clean all check info - -all: $(TARGET) - -$(OBJECT): $(SOURCE) - $(CC) $(CFLAGS) -o $@ -c $(SOURCE) - -$(TARGET): $(OBJECT) - $(CC) -o $@ $(OBJECT) $(LDFLAGS) - -clean: - rm -f $(TARGET) $(OBJECT) $(BASENAME).info $(BASENAME).texi $(BASENAME).html - -info: $(BASENAME).info -$(BASENAME).info:: README.org - $(EMACS) -Q --batch --eval "(require 'ox-texinfo)" \ - --eval "(with-current-buffer (find-file \"README.org\") (org-export-to-file (quote texinfo) \"$@\" nil nil nil nil nil (quote org-texinfo-compile)))" - -check: $(TARGET) - $(EMACS) --batch --eval '(add-to-list (quote load-path) (expand-file-name "."))' \ - -l ert -l sweep -l sweep-tests.el -f ert-run-tests-batch-and-exit diff --git a/sweep.el b/sweep.el index a9c9c31..9291e97 100644 --- a/sweep.el +++ b/sweep.el @@ -121,9 +121,9 @@ inserted to the input history in `sweep-top-level-mode' buffers." :type 'boolean :group 'sweep) -(defcustom sweep-init-args (list (expand-file-name - "sweep.pl" - (file-name-directory load-file-name))) +(defcustom sweep-init-args (list "-q" + "--no-signals" + "-g [library(sweep)]") "List of strings used as initialization arguments for Prolog." :package-version '((sweep "0.1.0")) :type '(list string) @@ -156,12 +156,16 @@ inserted to the input history in `sweep-top-level-mode' buffers." (declare-function sweep-cleanup "sweep-module") (defun sweep--ensure-module () - (unless (require 'sweep-module nil t) - (if (y-or-n-p "Sweep needs `sweep-module' to work. Compile it now? ") - (progn - (sweep--compile-module) - (require 'sweep-module)) - (error "Sweep will not work until `sweep-module' is compiled!")))) + (let ((swipl-lib-dir (car + (split-string-and-unquote + (shell-command-to-string + (concat + (or sweep-swipl-path (executable-find "swipl")) + " --dump-runtime-variables |" + " grep PLLIBDIR |" + " cut -f 2 -d = |" + " cut -f 1 -d ';'")))))) + (load (expand-file-name "sweep-module" swipl-lib-dir)))) (defface sweep-debug-prefix-face @@ -301,7 +305,7 @@ FLAG and VALUE are specified as strings and read as Prolog terms." (defun sweep-init () (apply #'sweep-initialize (cons (or sweep-swipl-path (executable-find "swipl")) - (cons "-q" (cons "--no-signals" sweep-init-args)))) + sweep-init-args)) (sweep-setup-message-hook) (sweep-start-prolog-server))