From c6f84490a6c92a0c4f2deb3c4965044d74021ce0 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Wed, 15 Apr 2020 17:15:23 +0100 Subject: [PATCH] [FBT]: Add support for setting FG42 home and version number Signed-off-by: Sameer Rahmani --- .gitlab-ci.yml | 14 ++++++++++++++ fbt | 31 ++++++++++++++++++++++++++----- fg42-new | 2 +- scripts/compiler.el | 30 ------------------------------ 4 files changed, 41 insertions(+), 36 deletions(-) delete mode 100644 scripts/compiler.el diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e32ab6..445b456 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,20 @@ stages: script: - 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: extends: .build only: diff --git a/fbt b/fbt index c11bb53..8a1ee6a 100755 --- a/fbt +++ b/fbt @@ -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 ;; ;; Copyright (c) 2010-2020 Sameer Rahmani @@ -23,6 +23,8 @@ ;; ;;; Commentary: ;;; Code: +(defvar FG42_VERSION "3.0.0-snapshot" + "The version number of the current build of FG42.") (defun compile (dir) "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")) +(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 () "Execute a subcommand by looking into input arguments of the script." - (print (version)) - (let ((command (car command-line-args-left)) - (args (cdr command-line-args-left))) + (message (version)) + (message "\nFG42 Built tool v%s\n\n" FG42_VERSION) + + (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 ((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: ;; mode: emacs-lisp diff --git a/fg42-new b/fg42-new index 291f236..eb9e125 100755 --- a/fg42-new +++ b/fg42-new @@ -1,6 +1,6 @@ #! /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 \ --no-site-file --no-site-lisp --no-splash --title FG42 \ diff --git a/scripts/compiler.el b/scripts/compiler.el deleted file mode 100644 index 2ef295c..0000000 --- a/scripts/compiler.el +++ /dev/null @@ -1,30 +0,0 @@ -;;; FG42ByteCompiler --- The byte compiler for FG42 libraries and extensions -;; -;; Copyright (c) 2010-2020 Sameer Rahmani -;; -;; Author: Sameer Rahmani -;; 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 . -;; -;; -;;; 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