juanjosegarciaripoll / emacs-build

Scripts to build a distribution of Emacs from sources, using MSYS2 and Mingw64(32)
MIT License
40 stars 54 forks source link

emacs-build v0.4.1

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

Usage

The script supports two way of being invoked:

Steps

  1. Download or clone the script from GitHub
  2. Open a Windows terminal and move to the folder for this script
  3. Issue whatever commands you need, such as .\emacs-build.cmd --clone --deps --build --pack-emacs
  4. Inspect the zips folder for the products of the script

General options

Usage:
   emacs-build [--version] [--help] [--features]
                    [--branch b] [--clone] [--build] [--deps]
                    [--slim] [--[no-]compress] [--[no-]strip]
                    [--with-all] [--without-X] [--with-X]
                    [--pdf-tools] [--aspell] [--hunspell] [--mu] [--isync]
                    [--pack-emacs] [--pack-all]
Actions:
   --build       Configure and build Emacs from sources.
   --clean       Remove all directories except sources and zip files.
   --clone       Download Savannah's git repository for Emacs.
   --deps        Create a ZIP file with all the Mingw64/32 dependencies.
   --help        Output this help message, --features and exit.
   --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).
   --features    Shows all active and inactive features for the selected options.
   --version     Output emacs-build version number and exit.

   Multiple actions can be selected. The default is to run them all in a logical
   order: clone, build, deps and pack-all.

Build options:
   --branch b    Select Emacs branch (or tag) 'b' for the remaining operations.
   --compress    Ship Emacs with gunzip and compress documentation and Emacs
                 script files.
   --debug       Output all statements run by the script.
   --debug-dependencies
                 Describe which MSYS/MINGW packages depend on which, and
                 which files are discarded from the ZIP files.
   --no-strip    Disable the --strip option.
   --no-compress Disable the --compress option.
   --slim        Remove Cairo, SVG and TIFF support for a slimmer build.
                 Remove also documentation files and other support files
                 from the dependencies file. Activate --compress and
                 --strip. (Default configuration)
   --strip       Strip executables and DLL's from debug information.
   --with-all    Add all Emacs features.
   --with-*      Add requested feature in the dependencies and build
                 * is any of the known features for emacs in Windows/Mingw
                 (see --features).
   --without-*   Remove requested feature in the dependencies and build.

   Options are processed in order. Thus --slim followed by --with-cairo
   would enable Cairo, even though --slim removes it.

Extensions:
   --pdf-tools   Build and package PDF-TOOLS.
   --hunspell    Install Hunspell spell checker.
   --aspell      Install Aspell spell checker.
   --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

  1. Download the latest release of MSYS
  2. Download a minimal set of MSYS and MINGW programs needed to build Emacs and the extensions
  3. Clone the latest emacs repository on the branch emacs-27
  4. Ensure that all required packages Mingw64 are installed, or install them.
  5. Configure and build Emacs using those packages
  6. Pack all the dependencies into a ZIP file.
  7. Download and build pdf-tools, hunspell, mu and isync (plus xapian and gmime3). In the process, ensure that the required packages are also installed.
  8. Create a ZIP file with Emacs, all the dependencies and all the extensions.

The script, just like its creator, is a bit opinionated. The default build (without arguments), assumes --slim and performs takes some extra steps to reduce the size of the distribution

Considerations

There are implicit dependencies in the various actions:

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:

Regarding the extensions to Emacs and third-party utilities:

TO-DO

Changelog

v0.1

v0.2

v0.3

v0.3.1

v0.3.2

v0.4

v0.4.1