Fixed the broken debug-mode of the build

This commit is contained in:
Sameer Rahmani 2022-07-04 16:41:47 +01:00
parent 93bbfda8d3
commit 5780b87886
4 changed files with 66 additions and 50 deletions

View File

@ -54,7 +54,7 @@ serve: build
npx http-server ./build/site-build/ npx http-server ./build/site-build/
.PHONY: deploy-docs .PHONY: deploy-docs
deploy-docs: docs deploy-docs: clean docs
rsync -vlcr --delete-after ./build/site-build/* core.lxsameer.com:/home/www/public/fg42/ rsync -vlcr --delete-after ./build/site-build/* core.lxsameer.com:/home/www/public/fg42/
.PHONY: dummy-x .PHONY: dummy-x

View File

@ -29,12 +29,12 @@
(setq debug-on-error t) (setq debug-on-error t)
(setenv "FG42_HOME" (concat (getenv "HOME") "/.fg42/")) (defconst fg42/CORE_DIR (concat (getenv "HOME") "/.fg42/core"))
(defconst fg42/CORE_DIR (concat (getenv "FG42_HOME") "core"))
(setq user-emacs-directory (concat (getenv "FG42_HOME") "emacs.d"))
(add-to-list 'load-path fg42/CORE_DIR) (add-to-list 'load-path fg42/CORE_DIR)
(setenv "FG42_HOME" (concat (getenv "HOME") "/.fg42/"))
(setq user-emacs-directory (concat (getenv "FG42_HOME") "emacs.d"))
(require 'fg42/build/core) (require 'fg42/build/core)
(require 'fg42/build/utils) (require 'fg42/build/utils)
@ -68,33 +68,9 @@ PARAMS:
docs-actions '(fg42/build-prepare-docs)) docs-actions '(fg42/build-prepare-docs))
(defun main () (command-> command args
"The entry point to the build script." ((string= command "docs")
(message (fg42/version)) (do-command
(message "\nFG42 Build tool v%s\n\n" (fg42/version))
;; UTF-8 as default encoding
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(let* ((fg42-home (car command-line-args-left))
(build-dir (from-root "/build"))
(parsed-args (read-args (cdr command-line-args-left)))
(eval-string (plist-get (car parsed-args) :e))
(command (caadr parsed-args))
(args (cdadr parsed-args)))
;; Evaluate the expression provided by :e
(when eval-string
(eval (car (read-from-string eval-string))))
(setq debug-mode (plist-get (car parsed-args) :d))
(cond
((string= command "docs")
(do-command
(require 'fpkg) (require 'fpkg)
(fpkg/use dash) (fpkg/use dash)
(fpkg/use mustache) (fpkg/use mustache)
@ -105,23 +81,23 @@ PARAMS:
(require 'fg42/build/docs) (require 'fg42/build/docs)
(fg42/build-docs build-dir))) (fg42/build-docs build-dir)))
((string= command "compile")
(do-command
(native-compile-async fg42/CORE_DIR 'recursively)
(native-compile-async "~/.fg42.v3.el")
(print "Compiling FG42 files ...")
(while (or comp-files-queue
(> (comp-async-runnings) 0))
(print ".")
(sleep-for 1))
(message "Done")))
;; TODO: create a new command to update the license headers for ;; TODO: create a new command to update the license headers for
;; the copyright years. Hint: just run: ;; the copyright years. Hint: just run:
;; sed 's/2010-2021/2010-2022/' -i ` grep '2010-2021' . -R --color --exclude-dir=emacs.d/|cut -d':' -f1` ;; sed 's/2010-2021/2010-2022/' -i ` grep '2010-2021' . -R --color --exclude-dir=emacs.d/|cut -d':' -f1`
(t (print-help command)))))
((string= commad "compile")
(do-command
(native-compile-async fg42/CORE_DIR 'recursively)
(native-compile-async "~/.fg42.v3.el")
(print "Compiling FG42 files ...")
(while (or comp-files-queue
(> (comp-async-runnings) 0))
(print ".")
(sleep-for 1))
(message "Done"))))
(provide 'build) (provide 'build)
;;; build.el ends here ;;; build.el ends here

View File

@ -59,7 +59,8 @@ project root.")
(defvar fg42/build-docs-actions nil (defvar fg42/build-docs-actions nil
"Set of actions to run before building the "Set of actions to run before building the
main docs.") main docs.")
(defvar fg42/build-output-dir "/build"
"The path to the build directory.")
(defmacro defproject (prject-name &rest details) (defmacro defproject (prject-name &rest details)
"Create a project with the given DETAILS. "Create a project with the given DETAILS.
@ -79,6 +80,37 @@ The build system will consum these details for various purposes."
nil)))) nil))))
(defmacro command-> (command-var args-var &rest body)
(declare (indent defun))
`(defun main ()
"The entry point to the build script."
(message (fg42/version))
(message "\nFG42 Build tool v%s\n\n" (fg42/version))
;; UTF-8 as default encoding
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(let* ((fg42-home (car command-line-args-left))
(build-dir (from-root ,fg42/build-output-dir))
(parsed-args (read-args (cdr command-line-args-left)))
(eval-string (plist-get (car parsed-args) :e))
(,command-var (caadr parsed-args))
(,args-var (cdadr parsed-args)))
;; Evaluate the expression provided by :e
(when eval-string
(eval (car (read-from-string eval-string))))
(setq fg42/build-debug-mode (plist-get (car parsed-args) :d))
(cond
,@body
(t (print-help ,command-var))))))
(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 fg42/build-project-root path)) (concat fg42/build-project-root path))

View File

@ -153,7 +153,15 @@ Not pages."
(let ((posts (get-all-sorted-posts))) (let ((posts (get-all-sorted-posts)))
(mapconcat (mapconcat
(lambda (post) (lambda (post)
(format " - [[%s/essays/%s][%s]]" base-url (nth 2 post) (nth 1 post))) (format " - [[%s%s/%s?%s][%s]]"
base-url
fg42/build-docs-pages-dir
;; Path
(nth 2 post)
;; Hash
(car post)
;; Title
(nth 1 post)))
posts posts
"\n"))) "\n")))
@ -337,7 +345,7 @@ Not pages."
(setq org-latex-listings t) (setq org-latex-listings t)
(setq org-publish-project-alist (setq org-publish-project-alist
`(("fg42.org" `(("website"
:base-directory ,stage1-dir :base-directory ,stage1-dir
:root-directory ,stage1-dir :root-directory ,stage1-dir
:recursive t :recursive t
@ -377,7 +385,7 @@ Not pages."
:publishing-directory ,final-dir :publishing-directory ,final-dir
:recursive t :recursive t
:publishing-function org-publish-attachment) :publishing-function org-publish-attachment)
("build" :components ("fg42.org" "statics")))) ("build" :components ("website" "statics"))))
(org-publish-project "build" t nil) (org-publish-project "build" t nil)
(message "Build complete.") (message "Build complete.")