Juan Jose Garcia-Ripoll
ffeba88218
|
4 years ago | |
---|---|---|
.github/workflows | 4 years ago | |
scripts | 4 years ago | |
.gitattributes | 4 years ago | |
.gitignore | 4 years ago | |
LICENSE | 4 years ago | |
README.md | 4 years ago | |
emacs-build.cmd | 4 years ago | |
emacs-build.sh | 4 years ago |
README.md
emacs-build v0.2
Scripts to build a distribution of Emacs from sources, using MSYS2 and Mingw64(32)
Rationale
I wanted a script to build Emacs from sources, package it and install it on different computers, with the following conditions
- I should be able to build any branch or release from Emacs. This includes the last release branch (right now emacs-27), as well as the master branch for development. Always using pristine sources from Savannah.
- I want to build emacs with different options from the default, which is to use all features available. For instance, I do not care for SVG support.
- The script needs to track all packages that are required by the Emacs build even if I change the build options.
- The installation should take as little space as possible, removing useless directories or files that come from the dependencies. For instance, headers from libraries used by emacs, spurious documentation files, etc.
- The script should be able to build other components I regularly use, such as mu, mu4e or pdf-tools, in a way that is not affected by updates to the mingw or msys environments.
Usage
The script supports two way of being invoked:
- The
emacs-build.cmd
assumes nothing about your system, except for an existing installation of PowerShell. It will download and install a minimal MSYS/MINGW64 environment and build Emacs and all other requested components. This allows for a more deterministic build, without perturbing your computer. - The
emacs-build.sh
is meant to be ran from an existing MSYS/MINGW64 environment, which will be modified to allow building Emacs and all tools. Use this version at your own risk.
Steps
- Download or clone the script from GitHub
- Open a Windows terminal and move to the folder for this script
- Issue whatever commands you need, such as
.\emacs-build.cmd --clone --deps --build --pack-emacs
- Inspect the
zips
folder for the products of the script
General options
Usage:
.\emacs-build.cmd [--branch b]
[--clone] [--build] [--deps] [--pack-emacs] [--pack-all]
[--without-X] [--with-X]
[--pdf-tools] [--hunspell] [--mu] [--isync]
Actions:
--clean Remove all directories except sources and zip files
--clone Download Savannah's git repository for Emacs
--build Configure and build Emacs from sources
--deps Create a ZIP file with all the Mingw64/32 dependencies
--pack-emacs Package an Emacs previously built with the --build option
--pack-all Package an Emacs previously built, with all the Mingw64/32
dependencies, as well as all extensions (see Extensions below)
--version Output emacs-build version number
Multiple actions can be selected. The default is to run them all in a logical
order: clone, build, deps and pack-all.
Emacs options:
--branch b Select branch 'b' for the remaining operations
--slim Remove Cairo, SVG and TIFF support for a slimmer build
Remove also documentation files and other support files
from the dependencies file
--with-X Add requested feature in the dependencies and build
--without-X Remove requested feature in the dependencies and build
X is any of the known features for emacs in Windows/Mingw:
xpm jpeg tiff gif png rsvg cairo harfbuzz json lcms2 xml2 gnutls zlib
Extensions:
--pdf-tools Build and package PDF-TOOLS
--hunspell Include Eli Zaretskii's port of Hunspell
--mu Mail search system and supporting Emacs mu4e libraries
--isync Synchronize email from IMAP/POP to Maildir format (mbsync)
An example
Assume you invoke this script as follows
.\emacs-build.cmd --slim --clone --deps --build --pdf-tools --hunspell --mu --isync --pack-all
It will take care of the following tasks
- Download the latest release of MSYS
- Download a minimal set of MSYS and MINGW programs needed to build Emacs and the extensions
- Clone the latest emacs repository on the branch emacs-27
- Ensure that all required packages Mingw64 are installed, or install them.
- Configure and build Emacs using those packages
- Pack all the dependencies into a ZIP file.
- Download and build pdf-tools, hunspell, mu and isync (plus xapian and gmime3). In the process, ensure that the required packages are also installed.
- Create a ZIP file with Emacs, all the dependencies and all the extensions.
The script, just like its creator, is a bit opinionated. It performs takes some extra steps to reduce the size of the distribution
- It eliminates the manual pages and large documentation files for the libraries that are used by Emacs.
- It eliminates the library files (*.a).
- It strips the executable files and DLL's from debugging information.
Considerations
There are implicit dependencies in the various actions:
--clone
is required to get the sources--build
is assumed to be run before--pack-all
or--pack-emacs
Note that --clean
or --clean-all
do not remove the msys64
directory, because it is very time consuming to create and update it.
The tool produces zip files that are stored in ./zips
and can be uncompressed wherever you want:
emacs-xx-xxxx-deps.zips
is the file with optional libraries (png, jpeg, etc) used by Emacs.emacs-xx-xxxx-nodeps.zip
is a bare Emacs installation. It runs even if the 'deps' file is not usedemacs-xx-xxxx-full.zip
is a complete Emacs installation, with the optional libraries and all extensions (pdf-tools, mu, etc) you mentioned in the command line.pdf-tools-xxxx.zip
and others are the Zip files for the extensions. They can be unpacked inside an Emacs installation, but may assume that 'deps' have also been unpacked.
Regarding the extensions to Emacs and third-party utilities:
- They can be built separately from Emacs.
- If
c:\emacs
is where you unpacked the full installation, some extensions will reside inc:\emacs\bin
(e.g. pdftools) and some others inc:\emacs\usr\bin
(e.g. mu and mbsync). - Even though elisp files are provided, it is highly recommended that you install pdf-tools and mu4e from Melpa or other repositories, to properly take care of dependencies from other elisp libraries.
TO-DO
- Consider GitHub actions for automated continuous integration and release
system. References:
- Setting up an MSYS/MINGW system https://github.com/marketplace/actions/setup-msys2
- MINGW packages recipes https://github.com/msys2/MINGW-packages/blob/master/.github/workflows/main.yml
- Uploading artifacts https://github.com/actions/upload-artifact