From 910c19c51071be7661ed82d47311cda462a21a92 Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Mon, 30 Aug 2021 19:04:48 +0200 Subject: [PATCH] Parametrize with elisp the output files of the project --- .gitignore | 1 + Makefile | 16 +++++++++------- README.org | 18 +++++++++++++++--- config.el | 17 +++++++++++++++++ etc/config/gcc.mk | 2 ++ etc/emacs.mk | 5 +++++ shell.nix | 10 +++++++++- 7 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 .gitignore create mode 100644 config.el create mode 100644 etc/emacs.mk diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a47e57a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.emacs diff --git a/Makefile b/Makefile index ee3c801..b9cdb91 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,17 @@ ATRIP_ROOT := $(PWD) CONFIG ?= gcc -include etc/config/$(CONFIG).mk +SOURCES_FILE := Sources.mk + +include $(SOURCES_FILE) +include ./etc/emacs.mk +include ./etc/config/$(CONFIG).mk include ./bench/config.mk -EMACS = emacs -q --batch -define tangle -$(EMACS) $(1) --eval "(require 'org)" --eval '(org-babel-tangle)' -endef - MAIN = README.org -SOURCES = $(shell grep -oe ':tangle \+[^ ]\+' $(MAIN) | awk '{print $$2}' | sort -u) + +$(SOURCES_FILE): $(MAIN) + echo -n "SOURCES = " > $@ + $(EMACS) --eval '(atrip-print-sources)' >> $@ $(SOURCES): $(MAIN) $(call tangle,$<) diff --git a/README.org b/README.org index 64d2e24..9144b63 100644 --- a/README.org +++ b/README.org @@ -9,8 +9,20 @@ The algorithm uses two main data types, the =Slice= and the ** The slice -#+begin_src c++ :tangle include/Slice.hpp +#+begin_src c++ :tangle (atrip-slice-h) #pragma once +#include +#include +#include +#include + +#include + +namespace atrip { + +using ABCTuple = std::array; +using PartialTuple = std::array; + struct Slice { using F = double; @@ -26,7 +38,7 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds -#+begin_src c++ :tangle include/Slice.hpp +#+begin_src c++ :tangle (atrip-slice-h) // ASSOCIATED TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% struct Location { size_t rank; size_t source; }; @@ -455,7 +467,7 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds {} - }; + }; // struct Slice std::ostream& operator<<(std::ostream& out, Slice::Location const& v) { diff --git a/config.el b/config.el new file mode 100644 index 0000000..868bfea --- /dev/null +++ b/config.el @@ -0,0 +1,17 @@ +(require 'subr-x) + +(defun f-join (&rest args) + (string-join args "/")) + +(defvar atrip-sources nil) +(defun atrip-print-sources () + (princ (string-join atrip-sources " "))) + +(defmacro atrip-def (name body) `(progn (defun ,name () ,body) + (push (,name) atrip-sources))) + +;; atrip variables for the org-mode file +(atrip-def atrip-include-f "include/atrip") +(atrip-def atrip-slice-h (f-join (atrip-include-f) "Slice.hpp")) +(atrip-def atrip-utils-h (f-join (atrip-include-f) "Utils.hpp")) +(atrip-def atrip-main-h "include/atrip.hpp") diff --git a/etc/config/gcc.mk b/etc/config/gcc.mk index 0a9aad5..4086fe4 100644 --- a/etc/config/gcc.mk +++ b/etc/config/gcc.mk @@ -2,5 +2,7 @@ include etc/ctf.mk CXX = mpic++ +CXXFLAGS += -I$(ATRIP_ROOT)/include + CXXFLAGS += -I$(CTF_INCLUDE_PATH) LDFLAGS += -L$(CTF_BUILD_PATH) -lctf diff --git a/etc/emacs.mk b/etc/emacs.mk new file mode 100644 index 0000000..d617eae --- /dev/null +++ b/etc/emacs.mk @@ -0,0 +1,5 @@ +EMACS = emacs -q --batch --load config.el +define tangle +$(EMACS) $(1) --eval "(require 'org)" --eval '(org-babel-tangle)' +endef + diff --git a/shell.nix b/shell.nix index 81cf26e..915c87f 100644 --- a/shell.nix +++ b/shell.nix @@ -3,7 +3,15 @@ pkgs.mkShell rec { buildInputs = with pkgs; [ - emacs gcc blas + + coreutils + git + + gcc + blas + openmpi + + emacs ]; }