do not edit — generated by btf.
git.druid.rocksindexdruid520radiumradium-sc.el

radium-sc.el


;;; radium-sc.el, sc (druid520/sc.git) + dtc (druid520/dtc.git) -*- lexical-binding: t; -*-
;;
;; item 5. sc is a suckless ./configure generator: a hand-written
;; sc.conf (bin=/libs=/oss=/hard_cflags=/... plus any custom target
;; functions) becomes mk.conf + config.h + makefile + mk/*.sh (b/c/dm/
;; dh/d/dc, the exact same convention every real sc-based project this
;; whole config already knows how to build shares - checked directly:
;; that's genuinely why radium-build-markers already lists "mk.conf"/
;; "mk", not a coincidence worth re-discovering here). dtc ("devel
;; toolchain") scaffolds/grows an sc(+btf)-based project: new, doctor
;; (checks sc/btf2html/btf2man/mk/cc/perl/pkg-config are all on
;; $PATH), addbin, newdoc, port (an mp package definition from an
;; existing sc project's own sc.conf).
;;
;; a freshly-scaffolded, not-yet-configured sc project only has
;; sc.conf on disk yet (mk.conf/mk/ don't exist until sc itself runs)
;; - "sc.conf" joins radium-build-markers so C-x p f/project-switch-
;; project/radium-build-root all agree on that project root too, the
;; same real gap item 20's own commit already found and fixed for
;; cfg.rp/bare-mk.
 
(require 'radium-build)
(require 'radium-project)
 
;; both lists, explicitly, rather than leaning on radium-project.el's
;; own (setq project-vc-extra-root-markers radium-build-markers)
;; picking this up automatically - checked directly, not assumed:
;; add-to-list does NOT mutate a list in place in a way a second
;; variable already pointing at the old value would ever see (a
;; plain (setq copy old-list) genuinely stays the old, shorter list
;; after an unrelated (add-to-list 'old-list "x" t) - confirmed with
;; a real, isolated two-variable test), so which of this file and
;; radium-project.el happens to load first would otherwise silently
;; decide whether project.el's own C-x p commands ever learn about
;; sc.conf at all.
(add-to-list 'radium-build-markers "sc.conf" t)
(add-to-list 'project-vc-extra-root-markers "sc.conf" t)
 
(defun radium-sc-configure ()
  "C-c b s: run `sc' (sc.sh) at this project's own root, in a real
compile buffer - it prints one line per cflag/lib/header/ldflag/func
check as it goes, real scrolling status output, same reason a plain
build already goes through compile."
  (interactive)
  (let ((default-directory (radium-build-root)))
    (compile "sc")))
 
(defun radium-dtc--run (args)
  "run `dtc ARGS...' at this project's root in a real compile buffer -
the shared shape every non-interactive dtc subcommand below uses."
  (let ((default-directory (radium-build-root)))
    (compile (concat "dtc " args))))
 
(defun radium-dtc-new (dir)
  "M-x radium-dtc-new: scaffold a brand-new sc(+btf) project at DIR.
dtc new's own remaining prompts (binary name(s), supported oses, a
docs/ folder or not) are genuinely interactive (a plain `read -r' in
dtc.sh itself), so this hands off to a real terminal (ansi-term, same
shape radium-build-run-term already uses) rather than a compile
buffer, which can't answer them."
  (interactive (list (read-directory-name "scaffold new project at: ")))
  (require 'term)
  (when-let ((old (get-buffer "*radium-dtc-new*")))
    (when-let ((proc (get-buffer-process old)))
      (set-process-query-on-exit-flag proc nil))
    (kill-buffer old))
  (let ((buf (ansi-term "/bin/sh" "radium-dtc-new")))
    (with-current-buffer buf
      (term-send-raw-string (format "dtc new %s\n" (shell-quote-argument dir))))))
 
(defun radium-dtc-doctor ()
  "M-x radium-dtc-doctor: check sc/btf2html/btf2man/mk/cc/perl/
pkg-config are all really on $PATH."
  (interactive)
  (radium-dtc--run "doctor"))
 
(defun radium-dtc-addbin (name kind)
  "M-x radium-dtc-addbin: add NAME (KIND: c/s/S/pl/sh/bin) to this
project's own sc.conf bin=, with a real starter source file."
  (interactive (list (read-string "binary name: ")
                      (completing-read "kind: " '("c" "s" "S" "pl" "sh" "bin") nil t nil nil "c")))
  (radium-dtc--run (format "addbin %s %s" (shell-quote-argument name) (shell-quote-argument kind))))
 
(defun radium-dtc-newdoc (name)
  "M-x radium-dtc-newdoc: add NAME.btft to this project's own docs/."
  (interactive (list (read-string "doc page name: ")))
  (radium-dtc--run (format "newdoc %s" (shell-quote-argument name))))
 
(defun radium-dtc-port (catname)
  "M-x radium-dtc-port: scaffold an mp package definition
(category/name, default port/<this project's first bin= entry>) from
this project's own sc.conf."
  (interactive (list (read-string "category/name (empty for the default): ")))
  (radium-dtc--run (if (string-empty-p catname) "port" (format "port %s" (shell-quote-argument catname)))))
 
(global-set-key (kbd "C-c b s") #'radium-sc-configure)
 
(provide 'radium-sc)
powered by btf.