IMPORTANT NOTICE: Devheroes public code hosting will shut down at 1st of March 2023. Due to some difficulties, we have to shut down the instance. Since codeberg.org is pretty mature and welcoming, We highly recommend you to move your code there. Please be advised that on 1st of March, your data will be removed. Thanks for your time with us, and may the source be with you.

Browse Source

Add defproject to the build system to start creating a generic build system

ep8
Sameer Rahmani 7 months ago
parent
commit
95f7fea814
  1. 7
      build.el
  2. 36
      core/fg42/build/core.el
  3. 14
      core/fg42/build/docs.el
  4. 4
      core/fg42/build/utils.el

7
build.el

@ -55,6 +55,11 @@ PARAMS: @@ -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)
"Print out a usage instructions and print out the invalid msg for COMMAND."
(when command
@ -81,8 +86,6 @@ PARAMS: @@ -81,8 +86,6 @@ PARAMS:
(set-terminal-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))
(build-dir (from-root "/build"))
(parsed-args (read-args (cdr command-line-args-left)))

36
core/fg42/build/core.el

@ -29,20 +29,48 @@ @@ -29,20 +29,48 @@
(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.")
(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)
"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 ()
"Return non-nil if debug mode is turned off"
(not debug-mode))
(not fg42/build-debug-mode))
(defun read-args (args)

14
core/fg42/build/docs.el

@ -32,12 +32,8 @@ @@ -32,12 +32,8 @@
(require 'fg42/build/utils)
(require 'fg42/build/ox-template)
(defconst cube-template (from-root "/docs/site/templates/cube.org"))
(defconst cubes-index-template (from-root "/docs/site/templates/cubes.org"))
(defconst author-name "Sameer Rahmani")
(defconst author-email "lxsameer@gnu.org")
(defvar cube-template (from-root "/docs/site/templates/cube.org"))
(defvar cubes-index-template (from-root "/docs/site/templates/cubes.org"))
(defun fg42/build-docs-for-cube (build-dir cube)
@ -280,6 +276,8 @@ Not pages." @@ -280,6 +276,8 @@ Not pages."
(stage1-dir (expand-file-name "site" 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
(fg42/build-prepare-docs build-dir base-url)
@ -294,8 +292,8 @@ Not pages." @@ -294,8 +292,8 @@ Not pages."
;;; Discover all the org files
(setq org-agenda-files (all-org-files))
(setf user-full-name author-name)
(setf user-mail-address author-email)
(setf user-full-name fg42/build-author-name)
(setf user-mail-address fg42/build-author-email)
;; Disable default header links (top, next)
(setf org-html-home/up-format "")

4
core/fg42/build/utils.el

@ -75,13 +75,13 @@ @@ -75,13 +75,13 @@
(defun fg42/git-branch ()
(cd project-root)
(cd fg42/build-project-root)
(shell-command-to-string "git branch --show-current"))
(defun fg42/version ()
"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))))

Loading…
Cancel
Save