From 75178601e6b14e1a53a7386e672ca0648578c73c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renaud=20Casenave-P=C3=A9r=C3=A9?= Date: Tue, 26 Aug 2025 22:55:32 +0200 Subject: [PATCH] Make a boilerplate sextant package Start a slynk server or run tests --- lisp/local-projects/sextant/sextant.asd | 9 +++ lisp/local-projects/sextant/sextant.lisp | 25 +++++++ load-sextant.lisp | 3 + minimal.pro | 7 ++ sextant-tests.lisp | 4 ++ sextant.pro | 88 ++---------------------- src/sextant.cc | 44 ++++++++++++ 7 files changed, 99 insertions(+), 81 deletions(-) create mode 100644 lisp/local-projects/sextant/sextant.asd create mode 100644 lisp/local-projects/sextant/sextant.lisp create mode 100644 load-sextant.lisp create mode 100644 minimal.pro create mode 100644 sextant-tests.lisp create mode 100644 src/sextant.cc diff --git a/lisp/local-projects/sextant/sextant.asd b/lisp/local-projects/sextant/sextant.asd new file mode 100644 index 0000000..b098053 --- /dev/null +++ b/lisp/local-projects/sextant/sextant.asd @@ -0,0 +1,9 @@ +(defsystem sextant + :serial t + :defsystem-depends-on (:asdf-package-system) + :class :package-inferred-system + :around-compile (lambda (thunk) + (proclaim '(optimize (debug 3) (safety 3) (speed 0))) + (funcall thunk)) + :depends-on #.(append (uiop:read-file-form (merge-pathnames #p"../../../dependencies.sexp" (or *load-pathname* *compile-file-pathname*)))) + :components ((:file "sextant"))) diff --git a/lisp/local-projects/sextant/sextant.lisp b/lisp/local-projects/sextant/sextant.lisp new file mode 100644 index 0000000..21cb17b --- /dev/null +++ b/lisp/local-projects/sextant/sextant.lisp @@ -0,0 +1,25 @@ +(uiop:define-package :sextant + (:use :cl) + (:export #:start-slynk + #:stop-slynk + #:slynkp)) +(in-package :sextant) + +(defun sym (symbol package) + (intern (symbol-name symbol) package)) + +(let (slynkp) + (defun start-slynk () + (unless (find-package :slynk) + (require :ecl-quicklisp) + (funcall (sym 'quickload :ql) :slynk)) + (funcall (sym 'create-server :slynk) + :interface "0.0.0.0" :port 4005 :dont-close t :style :spawn) + (setf slynkp t)) + + (defun stop-slynk () + (when (find-package :slynk) + (funcall (sym 'stop-server :slynk) 4005) + (setf slynkp nil))) + + (defun slynkp () slynkp)) diff --git a/load-sextant.lisp b/load-sextant.lisp new file mode 100644 index 0000000..d21e712 --- /dev/null +++ b/load-sextant.lisp @@ -0,0 +1,3 @@ +(load "lisp/bundle.lisp") + +(asdf:load-system "sextant") diff --git a/minimal.pro b/minimal.pro new file mode 100644 index 0000000..5fce6c0 --- /dev/null +++ b/minimal.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs +SUBDIRS = parser \ + sextant + +parser.file = ts-parser.pro +sextant.file = sextant.pro +sextant.depends = parser diff --git a/sextant-tests.lisp b/sextant-tests.lisp new file mode 100644 index 0000000..0b5e223 --- /dev/null +++ b/sextant-tests.lisp @@ -0,0 +1,4 @@ +(require 'ecl-quicklisp) +(ql:quickload :fiveam) + +(use-package :fiveam) diff --git a/sextant.pro b/sextant.pro index b4d6f85..d220ec4 100644 --- a/sextant.pro +++ b/sextant.pro @@ -1,84 +1,10 @@ -# NOTICE: -# -# Application name defined in TARGET has a corresponding QML filename. -# If name defined in TARGET is changed, the following needs to be done -# to match new name: -# - corresponding QML filename must be changed -# - desktop icon filename must be changed -# - desktop filename must be changed -# - icon definition filename in desktop file must be changed -# - translation filenames have to be changed - +TEMPLATE = app CONFIG += debug - -LISP_FILES = make.lisp \ - lisp/system-index.txt \ - lisp/local-projects/sextant/options/config.lisp \ - lisp/local-projects/sextant/options/options.lisp \ - lisp/local-projects/sextant/options/all.lisp \ - lisp/local-projects/sextant/org/nodes.lisp \ - lisp/local-projects/sextant/org/cursor.lisp \ - lisp/local-projects/sextant/org/parser.lisp \ - lisp/local-projects/sextant/org/printer.lisp \ - lisp/local-projects/sextant/org/all.lisp \ - lisp/local-projects/sextant/models/actions.lisp \ - lisp/local-projects/sextant/models/commands.lisp \ - lisp/local-projects/sextant/models/cursor.lisp \ - lisp/local-projects/sextant/models/files-model.lisp \ - lisp/local-projects/sextant/models/org-model.lisp \ - lisp/local-projects/sextant/models/utils.lisp \ - lisp/local-projects/sextant/models/all.lisp \ - lisp/local-projects/sextant/sextant.lisp \ - lisp/local-projects/sextant/dependencies.sexp \ - lisp/local-projects/sextant/sextant.asd - -lisp.output = libsextant.a -lisp.commands = $$PWD/sextant-bootstrap -platform minimal -make -lisp.input = LISP_FILES -lisp.CONFIG = combine target_predeps - -QMAKE_EXTRA_COMPILERS += lisp - -# The name of your application -TARGET = harbour-sextant - +TARGET = sextant +DESTDIR = $$PWD +OBJECTS_DIR = $$PWD/tmp/sextant +LIBS += -lecl -lsextant-parser -L. QMAKE_CXXFLAGS += -std=c++2a -Wno-parentheses -Wno-unused-local-typedefs -Wno-array-bounds -Wno-maybe-uninitialized -Wno-restrict -CONFIG += sailfishapp -LIBS += -L. -lsextant-parser -lsextant -lecl -leql5 -QT += widgets qml multimedia network quick sql +QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'" -SOURCES += src/harbour-sextant.cc - -DISTFILES += qml/harbour-sextant.qml \ - qml/cover/CoverPage.qml \ - qml/components/ListTextField.qml \ - qml/components/ActionComboBox.qml \ - qml/components/OrgDelegate.qml \ - qml/components/OrgLine.qml \ - qml/components/OrgText.qml \ - qml/components/OrgEdit.qml \ - qml/components/OverwriteDialog.qml \ - qml/pages/FirstPage.qml \ - qml/pages/SecondPage.qml \ - qml/pages/Files.qml \ - qml/pages/Org.qml \ - qml/pages/Settings.qml \ - qml/pages/SelectFileDialog.qml \ - rpm/harbour-sextant.changes.in \ - rpm/harbour-sextant.changes.run.in \ - rpm/harbour-sextant.spec \ -# rpm/harbour-sextant.yaml \ -# translations/*.ts \ - harbour-sextant.desktop - -SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172 - -# to disable building translations every time, comment out the -# following CONFIG line -# CONFIG += sailfishapp_i18n - -# German translation is enabled as an example. If you aren't -# planning to localize your app, remember to comment out the -# following TRANSLATIONS line. And also do not forget to -# modify the localized app name in the the .desktop file. -# TRANSLATIONS += translations/harbour-sextant-de.ts +SOURCES += src/sextant.cc diff --git a/src/sextant.cc b/src/sextant.cc new file mode 100644 index 0000000..403e374 --- /dev/null +++ b/src/sextant.cc @@ -0,0 +1,44 @@ +#include "ts-parser/ts-parser.hh" + +#include +#include + +bool contains(int argc, char** argv, const char* target) +{ + for (int i = 0; i < argc; ++i) + { + if (std::strcmp(argv[i], target) == 0) + return true; + } + + return false; +} + +int main(int argc, char **argv) +{ + cl_boot(argc, argv); + sextant::parser::init_parser_lib(); + si_select_package(ecl_make_constant_base_string("COMMON-LISP-USER", 16)); + + std::string code("(progn (load \"load-sextant.lisp\")"); + + if (contains(argc, argv, "run-tests")) + code += "(load \"sextant-tests.lisp\")"; + else + { + code += "(funcall (intern (symbol-name 'start-slynk) :sextant))"; + code += "(si:top-level)"; + } + + code += ")"; + + CL_CATCH_ALL_BEGIN(ecl_process_env()) + { + si_safe_eval(2, ecl_read_from_cstring(code.c_str()), ECL_NIL); + } + CL_CATCH_ALL_END; + + sextant::parser::shutdown_parser_lib(); + + return 0; + }