Add the byte code compiler

This commit is contained in:
Sameer Rahmani 2020-04-14 22:37:00 +01:00
parent a1c4b2a106
commit 8757abe917
6 changed files with 186 additions and 7 deletions

View File

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `System` implementation (`core/fg42/system.el`)
- New `extensions` implementation (`core/fg42/extensions.el`)
- New approach to launching fg42
- New `compiler` target to Makefile
### Changed
- Changed the main package path to `/core`
- Changed the extensions path to `/extensions`

144
CONTRIBUTE Normal file
View File

@ -0,0 +1,144 @@
# Contribution Guidelines
*FG42* is a free software and a community of Emacs developers who like to share
their ideas and tools. We encourage you to join us. The community is what matters
to us. Here is a brief overview of contribution guidelines, which we ask all
contributors to follow.
## Asking for help
If you want to ask an usage question, first make sure to read the `README.md` file
and the documents of *FG42*. If you still need help feel free to join us via
[out gitter channel](https://gitter.im/FG42/FG42).
## Reporting issues
Issues have to be reported on our [issues tracker](https://gitlab.com/FG42/FG42/issues). Please:
- Check that the issue has not already been reported.
- This can be achieved by searching keywords on the [issues tracker](https://gitlab.com/FG42/FG42/issues).
- Try to use a clear title, and describe your problem with complete sentences.
- Include your emacs version and `~/.fg42.el` file as well.
- If possible, try to include details on how to reproduce it, like a step by
step guide.
## Contributing code
Code contributions are welcome. Please read the following sections carefully. In
any case, feel free to join us on [out gitter channel](https://gitter.im/FG42/FG42) to ask questions about
contributing!
### General contribution
#### License
The license is *GPLv2* for all parts specific to *FG42*, this includes:
- The initialization and core files
- All the built-in extensions.
For files not belonging to FG42 like local packages and libraries, refer
to the header file. Those files should not have an empty header, we may not
accept code without a proper header file.
#### Conventions
We follow these simple rules:
* Make elisp linter happy
* follow functional patterns and avoid huge functions
* seperate each expression by two new lines
* put (comment ...) to demonstrate the usage of the function
* write good docstrings
* choose meaningful names
* follow the indentation guides made in FG42
* prefix the functions with a prefix to differentiate them from other functions ( we need to discuss this)
* use <prefix>--<fn-name> for private/internal function names
* use / to categorize functions into namespaces ( air quote)
#### Pull-Request
Submit your contribution against the `master` branch. The `stable` branch
is going to be our last stable version only.
Please make one PR per feature. Keep your PRs as small as possible so we can review them
easily.
Write commit messages according to adapted [this article](https://chris.beams.io/posts/git-commit/):
- Include the extension or library name in the title inside square brackets
- Use present tense and write in the imperative: “Fix bug”, not “fixed bug” or
“fixes bug”.
- Start with a capitalized, short (72 characters or less) summary, followed by a
blank line.
- If necessary, add one or more paragraphs with details, wrapped at 72
characters.
- Separate paragraphs by blank lines.
This is a model commit message:
```
[FPKG] Capitalized, short (72 chars or less) summary
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body. The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.
Write your commit message in the imperative: "Fix bug" and not "Fixed bug"
or "Fixes bug." This convention matches up with commit messages generated
by commands like git merge and git revert.
Further paragraphs come after blank lines.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, followed by a
single space, with blank lines in between, but conventions vary here
- Use a hanging indent
```
[[https://github.com/magit/magit/][Git Commit]] and [[https://github.com/magit/magit/][Magit]] provide Emacs mode
for Git commit messages, which helps you to comply to these guidelines.
### Contributing an extension
Technical aspects TBD
Each file should be GPL compliant and contain the following header:
```lisp
;;; FILENAME --- SHORT DESCRIPTION
;;
;; Copyright (c) 2010-2020 Sameer Rahmani & Contributors
;;
;; Author: YOUR FULL NAME <YOUR EMAIL>
;; URL: https://gitlab.com/FG42/FG42
;; Version: VERSION
;;
;; 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:
;; THE COMMENTARY ON THE MOST IMPORTANT ASPECT OF THE EXTENSION
;;
;;; Code:
```
You should replace `FILENAME` by the name of the file (e.g. `packages.el`).
Don't forget to replace `YOUR FULL NAME` and `YOUR EMAIL` also.
#### Contribute to an existing extension
If you are contributing to an already existing extension, you should not modify any
header file.
* Credits
This `CONTRIBUTING` file is partially based on the [Rails Contribution
guidelines](https://github.com/rails/rails/blob/master/CONTRIBUTING.md)
and [Flycheck Contribution guidelines](https://github.com/flycheck/flycheck/blob/master/CONTRIBUTING.md)
and [Spacemacs Contribution guidelines](https://raw.githubusercontent.com/syl20bnr/spacemacs/master/CONTRIBUTING.org).

View File

@ -51,3 +51,7 @@ install:
install-fonts:
@mkdir -p ~/.fonts/
@cp -rv ./share/fonts/vazir/* ~/.fonts/
.PHONY: compile
compile:
@$(PWD)/fg42-new --script scripts/compiler.el

View File

@ -27,7 +27,7 @@
(require 'fg42/extensions/core)
(defun fg42-extensions/load-index (system ext-name ext-path)
(defun fg42-extensions/load-index (_system ext-name ext-path)
"Load the extension EXT-NAME which is in EXT-PATH using SYSTEM.
It will load the main file of the extension and return the `fg42-extension'
instance of the extension and nil otherwise."

View File

@ -1,6 +1,6 @@
;;; system --- System library of FG42 -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2020 Sameer Rahmani <lxsameer@gnu.org>
;; Copyright (c) 2010-2020 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://gitlab.com/FG42/FG42
@ -25,13 +25,13 @@
;;
;;; Code:
(require 'fg42/utils)
(require 'fg42/system/core)
(require 'fg42/system/utils)
;;;###autoload
(defun fg42-system/start ()
"Start the system from `fg42-get-current-system'."
(require 'fg42/utils))
(require 'fg42/system/core)
(require 'fg42/system/utils)
(debug-message "Starting the default system.")
(let ((sys (fg42-system/get-active-system)))
(funcall (fg42-system-start sys) sys)))

30
scripts/compiler.el Normal file
View File

@ -0,0 +1,30 @@
;;; 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