-*- mode: org -*-
#+TITLE:       configuration git
#+DESCRIPTION: documents - structuring, various output representations & search
#+FILETAGS:    :spine:hub:
#+AUTHOR:      Ralph Amissah
#+EMAIL:       [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]]
#+COPYRIGHT:   Copyright (C) 2015 - 2022 Ralph Amissah
#+LANGUAGE:    en
#+STARTUP:     content hideblocks hidestars noindent entitiespretty
#+OPTIONS:     H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t
#+PROPERTY:    header-args  :exports code
#+PROPERTY:    header-args+ :noweb yes
#+PROPERTY:    header-args+ :eval no
#+PROPERTY:    header-args+ :results no
#+PROPERTY:    header-args+ :cache no
#+PROPERTY:    header-args+ :padline no
#+PROPERTY:    header-args+ :mkdirp yes

* sundry misc
** sh script to batch process _emacs org babel tangle_ :shell_script:tangle:
  [[https://orgmode.org/manual/Batch-execution.html]]
creates a shell batch script called "tangle", that will tangle (emacs org
babel tangle) org files in ./org/ to create .d source files in ./src/doc_reform/
(similar functionality is contained within the "makefile" created by this
"dr_build_scaffold.org" file make tangle)

#+HEADER: :tangle ../tangle
#+HEADER: :tangle-mode (identity #o755)
#+HEADER: :shebang "#!/bin/sh"
#+BEGIN_SRC sh
# -*- mode: shell-script -*-
# tangle files with org-mode
DIR=`pwd`
ORGFILES=""
EMACSLISP=/usr/share/emacs/site-lisp
ORG_VER_AVAILABLE=$(shell echo `ls -d ~/.emacs.d/elpa/org-???????? | cut -d '-' -f2`)
EMACSLISP_ORG=~/.emacs.d/elpa/org-$($(shell echo $(ORG_VER_AVAILABLE)))
ORG_CONTRIB_VER_AVAILABLE=$(shell echo `ls -d ~/.emacs.d/elpa/org-plus-???????? | cut -d '-' -f2`)
EMACSLISP_ORG_CONTRIB=~/.emacs.d/elpa/org-plus-contrib-$($(shell echo $(ORG_CONTRIB_VER_AVAILABLE)))
# wrap each argument in the code required to call tangle on it
for i in $@; do
  ORGFILES="$ORGFILES \"$i\""
done
emacs --batch -Q -q \
--eval "(progn
(add-to-list 'load-path (expand-file-name \"$EMACSLISP\"))
(add-to-list 'load-path (expand-file-name \"$EMACSLISP_ORG\" t))
(add-to-list 'load-path (expand-file-name \"$EMACSLISP_ORG_CONTRIB\" t))
(require 'org)(require 'ob)(require 'ob-tangle)
(mapc (lambda (file)
  (find-file (expand-file-name file \"$DIR\"))
  (setq-local org-src-preserve-indentation t)
  (org-babel-tangle)
  (kill-buffer)) '($ORGFILES)))" 2>&1 #|grep tangled
#+END_SRC

** build
*** dub

#+BEGIN_SRC sh
dub build -h
#+END_SRC

#+BEGIN_SRC sh
time dub --compiler=ldc2 -v --force
time (dub --compiler=ldc2 --config=spine-ldc --debug=steps)
time (dub --compiler=ldc2 --config=spine-ldc --debug=checkdoc --debug=summary --debug=dumpdoc)
time (dub --compiler=ldc2 --config=spine-ldc --debug=io)
time (dub --compiler=ldc2 --config=spine-ldc --debug=checkdoc --debug=summary --debug=dumpdoc --debug=io)
time (dub --compiler=ldc2 --config=spine-ldc-debug --debug=io)

time dub --compiler=dmd -v --force
time (dub --compiler=dmd --config=spine-dmd --debug=steps)
time (dub --compiler=dmd --config=spine-dmd-debug --debug=io)

time dub --compiler=gdc -v --force
time (dub --compiler=gdc --config=spine-gdc --debug=steps)
time (dub --compiler=gdc --config=spine-gdc-debug --debug=io)
#+END_SRC

*** make

#+BEGIN_SRC sh
time make dmd
time make gdc
time make ldc
time make gdc ldc
time make all
time make all_ver
time make dmd_ver ldc_ver gdc_ver

time make restart
time make restart ldc
time make tangle ldc

time make ldc_testrun_find_pod_epub
#+END_SRC

** git
*** project version

#+BEGIN_SRC sh
echo $(git describe --long --tags | sed 's/^[ a-z_-]\+\([0-9.]\+\)/\1/;s/\([^-]*-g\)/r\1/;s/-/./g')
#+END_SRC

*** what files changed

#+BEGIN_SRC sh
git whatchanged --since="1 day ago" --oneline --name-only --pretty=format: | sort -u
git log --since="1 day ago" --name-only --pretty=format: | sort -u
#+END_SRC

** test run
*** e.g.

#+BEGIN_SRC sh
time (./result/bin/spine --source --html -v --output-dir=tmp/program-output data/pod/sisu-manual/media/text/en/sisu_markup.sst )

time (./bin/spine-ldc --source --html -v --output-dir=tmp/program-output data/pod/sisu-manual/media/text/en/sisu_markup.sst )

time (./bin/spine-ldc --source --html -v --output-dir=tmp/program-output data/pod/sisu-manual )
time (./bin/spine-ldc --source --html -v --output-dir=tmp/program-output data/pod/the_wealth_of_networks.yochai_benkler )
time (./bin/spine-ldc --source --html -v --output-dir=tmp/program-output data/pod/live-manual )

time (~sdp2/bin/spine-ldc --pod --source --html --epub --sqlite-create --sqlite-update -v sisudoc/media/text/en/sisu_markup_stress_test.sst sisudoc/media/text/en/the_wealth_of_networks.yochai_benkler.sst )

can point to directory containing sisudoc.txt file (listing which files to process)

time (~sdp2/bin/spine-ldc --html -v sisudoc)
# will process source files listed in sisudoc.txt for appropriate files and dir structure

e.g. live-manual a multilingual document (with source file inserts .ssi)

time (~sdp2/bin/spine-ldc --html --lang=en,es -v sisudoc)

time ( find data/pod -name pod.manifest | sort | xargs ./bin/spine-ldc --source --html --epub -v --output-dir=tmp/program-output )

time ( find data/pod -maxdepth 2 -name pod.manifest | sort | xargs ./bin/spine-ldc --source --html --epub -v --output-dir=tmp/program-output )
time ( find data/sisudir/media/text -name *.ss[tm] | sort | xargs ./bin/spine-ldc --source --html --epub -v --output-dir=tmp/program-output )

find data/pod -maxdepth 2 -name pod.manifest | sort | xargs

find data/sisudir/media/text -name *.ss[tm] | sort | xargs
#+END_SRC

*** sort

#+BEGIN_SRC sh
~dr/bin/spine-ldc -v  --sqlite-db-create --sqlite-db-filename="spine.search.db" --cgi-sqlite-search-filename="spine-search" --output=/var/www/html \
  ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod/*

~dr/bin/spine-ldc -v  --sqlite-update --sqlite-db-filename="spine.search.db"   --output=/var/www/html \
  ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod/*

~dr/bin/spine-ldc -v --html --curate-link  --output=/var/www/html \
   ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod/*

~dr/bin/spine-ldc -q --show-config --html --output=/var/www/html ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod

~dr/bin/spine-ldc -q --show-config ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod

~dr/result/bin/spine --html --output=/var/www/html /grotto-ra/repo/git.repo/projects/project-spine/doc-reform-markup/markup_samples/markup/pod/*

~dr/result/bin/spine --very-verbose --sqlite-db-create --sqlite-db-filename="spine.search.db" --cgi-sqlite-search-filename="spine-search" --output=/var/www /grotto-ra/repo/git.repo/projects/project-spine/doc-reform-markup/markup_samples/markup/pod/*

~dr/result/bin/spine --very-verbose --sqlite-update --sqlite-db-filename="spine.search.db" --cgi-sqlite-search-filename="spine-search" --output=/var/www /grotto-ra/repo/git.repo/projects/project-spine/doc-reform-markup/markup_samples/markup/pod/*
#+END_SRC

- produces:
  - sqlite db @:           /var/www/html/sqlite/spine.search.db
  - search script in D @:  /var/www/html/cgi/src/spine_search.d
  - html output *          /var/www/html/en/html/[filename]

#+BEGIN_SRC sh
cd /var/www/html/cgi

cp arsd/cgi.d /var/www/html/cgi/.          *-[needs to be implemented as part of code]

dub --force --compiler=ldc2 && sudo cp -v cgi-bin/spine-search /usr/lib/cgi-bin/.
#+END_SRC

*** list markup files
find data/pod -name pod.manifest | sort
find data/sisudir/media/text -name *.ss[tm] | sort

time make ldc_testrun_paths_pod_pod
time make ldc_testrun_paths_pod_pod | ag "^\".+\"|NOT found"
time make ldc_testrun_find_pod_pod
time make ldc_testrun_find_dir_pod
time make ldc_testrun_filelist_dir_pod

** compilers

- [X] Set D_COMPILER (one of DMD LDC or GDC)
- [X] Set debug flags (using DMD standard flag -deb

[[https://wiki.dlang.org/Compilers][D Compilers wiki https://wiki.dlang.org/Compilers]]
[[https://dlang.org/download.html][D Compilers download https://dlang.org/download.html]]

** version info REVIEW :version:

- https://dlang.org/download.html

*** compilers (set latest versions) :compiler:version:
**** ldc VERSION :version:set:ldc:

- https://github.com/ldc-developers/ldc/releases

***** 1.24.0 HACK

- https://github.com/ldc-developers/ldc/releases/tag/v1.24.0
  - nix-prefetch-url https://github.com/ldc-developers/ldc/releases/download/v1.24.0/ldc-1.24.0-src.tar.gz

#+NAME: ldc_version_info
#+BEGIN_SRC nix
version = "1.24.0";
sha256  = "0g5svf55i0kq55q49awmwqj9qi1n907cyrn1vjdjgs8nx6nn35gx";
#+END_SRC

- ldc-1.24.0 overlay does not build with latest nixos version, nixos-20.09
  nixos at ldc-1.20.0

**** dmd :dmd:

- https://dlang.org/changelog/index.html
- https://dlang.org/changelog/pending.html
- https://downloads.dlang.org/releases/
- https://downloads.dlang.org/releases/2.x/