Add defproject to the build system to start creating a generic build system
This commit is contained in:
parent
6ef2cd853a
commit
95f7fea814
7
build.el
7
build.el
|
@ -55,6 +55,11 @@ PARAMS:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(defproject FG42
|
||||||
|
project-root (nth 2 command-line-args-left)
|
||||||
|
fg42/build-docs-actions '(fg42/build-prepare-docs))
|
||||||
|
|
||||||
|
|
||||||
(defun print-help (command)
|
(defun print-help (command)
|
||||||
"Print out a usage instructions and print out the invalid msg for COMMAND."
|
"Print out a usage instructions and print out the invalid msg for COMMAND."
|
||||||
(when command
|
(when command
|
||||||
|
@ -81,8 +86,6 @@ PARAMS:
|
||||||
(set-terminal-coding-system 'utf-8)
|
(set-terminal-coding-system 'utf-8)
|
||||||
(set-keyboard-coding-system 'utf-8)
|
(set-keyboard-coding-system 'utf-8)
|
||||||
|
|
||||||
(setq project-root (car command-line-args-left))
|
|
||||||
|
|
||||||
(let* ((fg42-home (car command-line-args-left))
|
(let* ((fg42-home (car command-line-args-left))
|
||||||
(build-dir (from-root "/build"))
|
(build-dir (from-root "/build"))
|
||||||
(parsed-args (read-args (cdr command-line-args-left)))
|
(parsed-args (read-args (cdr command-line-args-left)))
|
||||||
|
|
|
@ -29,20 +29,48 @@
|
||||||
(require 'seq)
|
(require 'seq)
|
||||||
|
|
||||||
|
|
||||||
(defvar project-root nil
|
(defvar fg42/build-project-name "FG42"
|
||||||
|
"The name to be uesd with in the output as as the project name")
|
||||||
|
|
||||||
|
(defvar fg42/build-project-root nil
|
||||||
"Root directory of the website source code.")
|
"Root directory of the website source code.")
|
||||||
|
|
||||||
(defvar debug-mode nil)
|
(defvar fg42/build-debug-mode nil)
|
||||||
|
|
||||||
|
(defvar fg42/build-author-name "Sameer Rahmani")
|
||||||
|
(defvar fg42/build-author-email "lxsameer@gnu.org")
|
||||||
|
|
||||||
|
(defvar fg42/build-docs-actions nil
|
||||||
|
"Set of actions to run before building the
|
||||||
|
main docs.")
|
||||||
|
|
||||||
|
|
||||||
|
(defmacro defproject (prject-name &rest details)
|
||||||
|
"Create a project with the given DETAILS.
|
||||||
|
|
||||||
|
The build system will consum these details for various purposes."
|
||||||
|
(declare (indent defun))
|
||||||
|
(cons 'progn
|
||||||
|
(cons `(setq fg42/bulid-project-name
|
||||||
|
,(symbol-name prject-name))
|
||||||
|
(seq-reduce
|
||||||
|
(lambda (forms pair)
|
||||||
|
(let* ((varname (intern (format "fg42/build-%s" (car pair))))
|
||||||
|
(val (cadr pair))
|
||||||
|
(form `(setq ,varname ,val)))
|
||||||
|
(cons form forms)))
|
||||||
|
(seq-partition details 2)
|
||||||
|
nil))))
|
||||||
|
|
||||||
|
|
||||||
(defun from-root (path)
|
(defun from-root (path)
|
||||||
"Return the full path of the given PATH in the project root."
|
"Return the full path of the given PATH in the project root."
|
||||||
(concat project-root path))
|
(concat fg42/build-project-root path))
|
||||||
|
|
||||||
|
|
||||||
(defun prod-p ()
|
(defun prod-p ()
|
||||||
"Return non-nil if debug mode is turned off"
|
"Return non-nil if debug mode is turned off"
|
||||||
(not debug-mode))
|
(not fg42/build-debug-mode))
|
||||||
|
|
||||||
|
|
||||||
(defun read-args (args)
|
(defun read-args (args)
|
||||||
|
|
|
@ -32,12 +32,8 @@
|
||||||
(require 'fg42/build/utils)
|
(require 'fg42/build/utils)
|
||||||
(require 'fg42/build/ox-template)
|
(require 'fg42/build/ox-template)
|
||||||
|
|
||||||
|
(defvar cube-template (from-root "/docs/site/templates/cube.org"))
|
||||||
(defconst cube-template (from-root "/docs/site/templates/cube.org"))
|
(defvar cubes-index-template (from-root "/docs/site/templates/cubes.org"))
|
||||||
(defconst cubes-index-template (from-root "/docs/site/templates/cubes.org"))
|
|
||||||
|
|
||||||
(defconst author-name "Sameer Rahmani")
|
|
||||||
(defconst author-email "lxsameer@gnu.org")
|
|
||||||
|
|
||||||
|
|
||||||
(defun fg42/build-docs-for-cube (build-dir cube)
|
(defun fg42/build-docs-for-cube (build-dir cube)
|
||||||
|
@ -280,6 +276,8 @@ Not pages."
|
||||||
(stage1-dir (expand-file-name "site" build-dir))
|
(stage1-dir (expand-file-name "site" build-dir))
|
||||||
(final-dir (expand-file-name "site-build" build-dir)))
|
(final-dir (expand-file-name "site-build" build-dir)))
|
||||||
|
|
||||||
|
(mapc (lambda (f) (apply f build-dir base-url)) fg42/build-docs-actions)
|
||||||
|
|
||||||
;; Create org files for the cubes
|
;; Create org files for the cubes
|
||||||
(fg42/build-prepare-docs build-dir base-url)
|
(fg42/build-prepare-docs build-dir base-url)
|
||||||
|
|
||||||
|
@ -294,8 +292,8 @@ Not pages."
|
||||||
;;; Discover all the org files
|
;;; Discover all the org files
|
||||||
(setq org-agenda-files (all-org-files))
|
(setq org-agenda-files (all-org-files))
|
||||||
|
|
||||||
(setf user-full-name author-name)
|
(setf user-full-name fg42/build-author-name)
|
||||||
(setf user-mail-address author-email)
|
(setf user-mail-address fg42/build-author-email)
|
||||||
|
|
||||||
;; Disable default header links (top, next)
|
;; Disable default header links (top, next)
|
||||||
(setf org-html-home/up-format "")
|
(setf org-html-home/up-format "")
|
||||||
|
|
|
@ -75,13 +75,13 @@
|
||||||
|
|
||||||
|
|
||||||
(defun fg42/git-branch ()
|
(defun fg42/git-branch ()
|
||||||
(cd project-root)
|
(cd fg42/build-project-root)
|
||||||
(shell-command-to-string "git branch --show-current"))
|
(shell-command-to-string "git branch --show-current"))
|
||||||
|
|
||||||
|
|
||||||
(defun fg42/version ()
|
(defun fg42/version ()
|
||||||
"Returns the current version of FG42."
|
"Returns the current version of FG42."
|
||||||
(cd project-root)
|
(cd fg42/build-project-root)
|
||||||
(shell-command-to-string (format "git describe %s" (fg42/git-branch))))
|
(shell-command-to-string (format "git describe %s" (fg42/git-branch))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue