2021-07-27 16:37:18 +01:00
|
|
|
:;exec `echo $EMACS` --no-site-file --no-site-lisp --batch -L ./ -l "$0" -f main "$(cd "$(dirname "$0")/." >/dev/null 2>&1 ; pwd -P)" "$@"
|
2021-07-27 12:32:24 +01:00
|
|
|
;;; Buid --- The builder for FG42 -*- lexical-binding: t; -*-
|
2020-03-16 21:34:29 +00:00
|
|
|
;;
|
2021-07-27 12:32:24 +01:00
|
|
|
;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors
|
2020-03-16 21:34:29 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
2021-07-27 12:32:24 +01:00
|
|
|
;; URL: https://gitlab.com/FG42/FG42
|
|
|
|
;; Version: 3.0.0
|
2020-03-16 21:34:29 +00:00
|
|
|
;;
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2021-07-27 12:32:24 +01:00
|
|
|
;; along with thnis program. If not, see <http://www.gnu.org/licenses/>.
|
2020-03-16 21:34:29 +00:00
|
|
|
;;
|
|
|
|
;;; Commentary:
|
2021-07-27 12:32:24 +01:00
|
|
|
;; Cubes are the building blocks of any `FG42' editor. Each `cube' is a
|
|
|
|
;; unit which defines different abilities in a deterministic and idempotent
|
|
|
|
;; way. Cubes are composable and a composition of cubes creates an editor.
|
|
|
|
;;
|
2020-03-16 21:34:29 +00:00
|
|
|
;;; Code:
|
2021-07-27 12:32:24 +01:00
|
|
|
|
2020-05-17 18:12:28 +01:00
|
|
|
(setq debug-on-error t)
|
2021-07-27 12:32:24 +01:00
|
|
|
|
2021-07-27 16:37:18 +01:00
|
|
|
(defconst fg42/CORE_DIR (concat (getenv "HOME") "/.fg42/core"))
|
|
|
|
|
2021-07-27 12:32:24 +01:00
|
|
|
(setq user-emacs-directory (concat (getenv "HOME") "/.fg42/emacs.d"))
|
2021-07-27 16:37:18 +01:00
|
|
|
(add-to-list 'load-path fg42/CORE_DIR)
|
2021-07-27 12:32:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
(require 'fg42/build/core)
|
|
|
|
|
|
|
|
(defvar FG42-VERSION "3.0.0-snapshot"
|
|
|
|
"The version number of the current build of FG42.")
|
|
|
|
|
|
|
|
(defconst build/usage "
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
build.el [PARAMS] COMMAND [...]
|
|
|
|
|
|
|
|
COMMANDS:
|
|
|
|
clean [DIRS] - Clean up the given list of directories (default: \"code\" \"fbt\").
|
|
|
|
docs - Build the documents and convert them to HTML
|
|
|
|
|
|
|
|
PARAMS:
|
|
|
|
:d - Turns on the debug mode.
|
|
|
|
:e expr - Run the given `expr' before any operation.
|
|
|
|
")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun print-help (command)
|
|
|
|
"Print out a usage instructions and print out the invalid msg for COMMAND."
|
|
|
|
(when command
|
|
|
|
(warn "I don't know about '%s' command.\n" command))
|
|
|
|
(message build/usage))
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro do-command (&rest body)
|
|
|
|
"Run the BODY after loading FG42."
|
|
|
|
`(progn
|
|
|
|
(require 'fg42)
|
|
|
|
(fg42/before-initialize)
|
|
|
|
,@body))
|
|
|
|
|
|
|
|
|
|
|
|
(defun main ()
|
|
|
|
"The entry point to the build script."
|
|
|
|
(message (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)
|
|
|
|
|
|
|
|
(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)))
|
|
|
|
(eval-string (car parsed-args))
|
|
|
|
(command (caadr parsed-args))
|
|
|
|
(args (cdadr parsed-args)))
|
|
|
|
|
|
|
|
;; Evaluate the expression provided by :e
|
|
|
|
(when eval-string
|
|
|
|
(eval (car (read-from-string eval-string))))
|
|
|
|
|
|
|
|
(cond
|
|
|
|
((string= command "docs")
|
|
|
|
(do-command
|
2021-10-12 00:35:05 +01:00
|
|
|
(require 'fpkg)
|
|
|
|
(fpkg/use dash)
|
|
|
|
|
2021-07-27 12:32:24 +01:00
|
|
|
(require 'fg42/build/docs)
|
|
|
|
(fg42/build-docs build-dir)))
|
2021-07-27 16:37:18 +01:00
|
|
|
|
|
|
|
((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")))
|
|
|
|
|
2021-07-27 12:32:24 +01:00
|
|
|
(t (print-help command)))))
|
2020-03-16 21:34:29 +00:00
|
|
|
|
|
|
|
(provide 'build)
|
|
|
|
;;; build.el ends here
|