[FBT]: Add support for setting FG42 home and version number

Signed-off-by: Sameer Rahmani <lxsameer@gnu.org>
This commit is contained in:
Sameer Rahmani 2020-04-15 17:15:23 +01:00
parent 38809cdd19
commit c6f84490a6
4 changed files with 41 additions and 36 deletions

View File

@ -10,6 +10,20 @@ stages:
script: script:
- cd ~/.fg42/ && fg42 -nw --script build.el - cd ~/.fg42/ && fg42 -nw --script build.el
.build-v3:
image: debian:stable-slim
stage: build
before_script:
- apt update && apt install -y make wget git emacs sudo
- git clone -b fpkg-v2 https://gitlab.com/FG42/FG42 ~/.fg42/ && ~/.fg42/fbt build
build-branches-v3:
extends: .build-v3
only:
- branches
except:
- tags
build-branches: build-branches:
extends: .build extends: .build
only: only:

31
fbt
View File

@ -1,4 +1,4 @@
:;exec emacs --no-site-file --no-site-lisp -batch -l "$0" -f main "$@" :;exec emacs --no-site-file --no-site-lisp -batch -l "$0" -f main "$(cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" "$@"
;;; FGBuildTool --- The build tool for FG42 ;;; FGBuildTool --- The build tool for FG42
;; ;;
;; Copyright (c) 2010-2020 Sameer Rahmani <lxsameer@gnu.org> ;; Copyright (c) 2010-2020 Sameer Rahmani <lxsameer@gnu.org>
@ -23,6 +23,8 @@
;; ;;
;;; Commentary: ;;; Commentary:
;;; Code: ;;; Code:
(defvar FG42_VERSION "3.0.0-snapshot"
"The version number of the current build of FG42.")
(defun compile (dir) (defun compile (dir)
"Compile all the elisp files in the given DIR regardless of timestamp. "Compile all the elisp files in the given DIR regardless of timestamp.
@ -38,14 +40,33 @@ The DIR should be relative to FG42_HOME."
(compile "core")) (compile "core"))
(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 "Usage:\n")
(message "compile [DIR] - Compiles the given DIR to bytecodes (default: \"core\")")
(message "build - Builds FG42 by compiling the code and installing dependencies."))
(defun main () (defun main ()
"Execute a subcommand by looking into input arguments of the script." "Execute a subcommand by looking into input arguments of the script."
(print (version)) (message (version))
(let ((command (car command-line-args-left)) (message "\nFG42 Built tool v%s\n\n" FG42_VERSION)
(args (cdr command-line-args-left)))
(let ((fg42-home (car command-line-args-left))
(command (cadr command-line-args-left))
(args (cddr command-line-args-left)))
;; FG42 Needs this env var to know where had it been installed
(setenv "FG42_HOME" fg42-home)
(setenv "FG42_VERSION" FG42_VERSION)
(cond (cond
((string= command "compile") (funcall #'compile (or (car args) "core"))) ((string= command "compile") (funcall #'compile (or (car args) "core")))
((string= command "build") (funcall #'build args))))) ((string= command "build") (funcall #'build args))
(t (print-help command)))))
;; Local Variables: ;; Local Variables:
;; mode: emacs-lisp ;; mode: emacs-lisp

View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
export FG42_HOME="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" export FG42_HOME="$(cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
FG42_WM=false emacs --name FG42 \ FG42_WM=false emacs --name FG42 \
--no-site-file --no-site-lisp --no-splash --title FG42 \ --no-site-file --no-site-lisp --no-splash --title FG42 \

View File

@ -1,30 +0,0 @@
;;; FG42ByteCompiler --- The byte compiler for FG42 libraries and extensions
;;
;; Copyright (c) 2010-2020 Sameer Rahmani <lxsameer@gnu.org>
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://gitlab.com/FG42/FG42
;; Version: 3.0.0
;;
;; 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
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;
;;
;;; Commentary:
;;; Code:
(add-to-list 'load-path (concat (getenv "FG42_HOME") "/core"))
(message "Compiling FG42 core...")
(byte-recompile-directory (concat (getenv "FG42_HOME") "/core") 0 t)
;;; compiler.el ends here