diff --git a/.appveyor-script.ps1 b/.appveyor-script.ps1 index e7e46620..3094b682 100644 --- a/.appveyor-script.ps1 +++ b/.appveyor-script.ps1 @@ -2,7 +2,7 @@ # Instead, we store the stdout/stderr and grep for "FAILED". function Run-Test { param( $TestName ) - $command = "emacs --batch -L build -L test -l libegit2 -l test-helper -l $($TestName)-test -f ert-run-tests-batch-and-exit" + $command = "C:\emacs\bin\emacs --batch -L build -L test -l libegit2 -l test-helper -l $($TestName)-test -f ert-run-tests-batch-and-exit" $output = Invoke-Expression "$command 2>&1" Write-Host $output if ($output | select-string -Pattern "FAILED") { diff --git a/.travis.yml b/.travis.yml index bcf904ac..0d21009c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,9 @@ cache: env: global: - - EMACSCONFFLAGS="--with-x-toolkit=no --without-x --without-all --with-xml2 --with-modules --with-toolkit-scroll-bars=yes --with-gameuser=$USER" - PATH="$HOME/bin:$PATH" + - EMAKE_SHA1=1b23379eb5a9f82d3e2d227d0f217864e40f23e0 matrix: - - EMACS_VERSION=25.1 - EMACS_VERSION=25.3 - EMACS_VERSION=26.1 - EMACS_VERSION=snapshot @@ -26,9 +25,10 @@ matrix: - env: EMACS_VERSION=snapshot before_install: + - wget "https://raw.githubusercontent.com/vermiculus/emake.el/${EMAKE_SHA1}/emake.mk" - make emacs - - make emake.el script: - make build/libegit2.so + - make compile - make test diff --git a/Makefile b/Makefile index fbee2707..0c27133d 100644 --- a/Makefile +++ b/Makefile @@ -1,43 +1,18 @@ -EENVS = PACKAGE_FILE="libgit.el" -EENVS += PACKAGE_LISP="libgit.el" -EENVS += PACKAGE_TESTS="$(wildcard test/*.el)" -EENVS += PACKAGE_ARCHIVES="gnu" -EMAKE = $(EENVS) emacs -batch -l emake.el $(EMACS_OPTS) --eval "(emake (pop argv))" +EMAKE_SHA1 ?= 1b23379eb5a9f82d3e2d227d0f217864e40f23e0 +PACKAGE_BASENAME := libgit -.PHONY: emacs clean test +include emake.mk -libgit2: +libgit2: ## pull down libgit2 git submodule init git submodule update -build/libegit2.so: libgit2 +build/libegit2.so: libgit2 ## build the module mkdir build cd build && cmake .. && make -test: EMACS_OPTS=-L build/ -l libegit2 -test: emake.el build/libegit2.so - $(EMAKE) test ert +test: EMACS_ARGS += -L build/ -l libegit2 +test: build/libegit2.so test-ert ## run tests -clean: +clean: ## removes build directories rm -rf build/ libgit2/ - -emake.el: - wget 'https://raw.githubusercontent.com/vermiculus/emake.el/master/emake.el' - -emacs-travis.mk: - wget 'https://raw.githubusercontent.com/flycheck/emacs-travis/master/emacs-travis.mk' -ifeq ($(TRAVIS_OS_NAME),osx) - cp emacs-travis.mk /tmp/emacs-travis.mk - cat /tmp/emacs-travis.mk | sed 's/configure_emacs: install_gnutls//' > emacs-travis.mk -endif - -ifeq ($(TRAVIS_OS_NAME),osx) -emacs: emacs-travis.mk - brew upgrade gnutls - $(MAKE) -f emacs-travis.mk install_emacs - mkdir -p $(HOME)/bin - ln -s $(HOME)/emacs/$(EMACS_VERSION)/nextstep/Emacs.app/Contents/MacOS/Emacs $(HOME)/bin/emacs -else -emacs: emacs-travis.mk - $(MAKE) -f emacs-travis.mk install_emacs -endif diff --git a/appveyor.yml b/appveyor.yml index ac415605..906a196f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,16 +1,21 @@ environment: + global: + GENERATOR: "MinGW Makefiles" matrix: - - GENERATOR: "MinGW Makefiles" + # - EMACS_VERSION: "25.1" + # - EMACS_VERSION: "25.2" + - EMACS_VERSION: "25.3" + - EMACS_VERSION: "26.1" + - EMACS_VERSION: "snapshot" install: - git submodule update --init --recursive - # Use the chocolatey emacs64 package for testing - # TODO: Any better solutions? Build Emacs ourselves? What about 64-bit? - - cinst emacs64 + - set MSYSTEM=MINGW64 + - C:\msys64\usr\bin\bash -l -c "cd /c/projects/libegit2 && make -f emacs-appveyor.mk install_emacs" before_build: - set PATH=%PATH:C:\Program Files\Git\usr\bin;=% - - set PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH% + - set PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;C:\emacs;%PATH% build_script: - mkdir build diff --git a/emacs-appveyor.mk b/emacs-appveyor.mk new file mode 100644 index 00000000..40b677d1 --- /dev/null +++ b/emacs-appveyor.mk @@ -0,0 +1,87 @@ +# Copyright (c) 2018 Magit contributors +# Copyright (c) 2017-2018 Flycheck contributors +# Copyright (c) 2015-2016 Sebastian Wiesner + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE.EMACS_VERSION ?= 25.3 + + +MAKE_JOBS ?= 2 + +# Tear the version apart +VERSION_PARTS := $(subst -, ,$(EMACS_VERSION)) +VERSION_PART := $(word 1,$(VERSION_PARTS)) +PRE_RELEASE_PART := $(word 2,$(VERSION_PARTS)) +MAJOR_VERSION := $(word 1,$(subst ., ,$(EMACS_VERSION))) +# Whether the version is a release candidate +PRETEST ?= $(findstring rc,$(PRE_RELEASE_PART)) + +# Build a minimal Emacs with no special flags, to build as fast as possible +ifndef EMACSCONFFLAGS +EMACSCONFFLAGS := --with-modules --with-gnutls=no --prefix=/c/emacs CFLAGS='-O2 -march=native' CXXFLAGS='-O2 -march=native' +endif + +# Clone Emacs from the Github mirror because it's way faster than upstream +EMACS_GIT_URL = https://github.com/emacs-mirror/emacs.git +ifeq ($(PRETEST),) +EMACS_FTP_URL = "https://ftp.gnu.org/gnu/emacs" +else +EMACS_FTP_URL = "http://alpha.gnu.org/pub/gnu/emacs/pretest" +endif +EMACS_TAR_URL = $(EMACS_FTP_URL)/emacs-$(EMACS_VERSION).tar.xz + +# If it's an RC the real reported Emacs version is the version without the +# prerelease postfix. Otherwise it's just the version that we get. +ifneq ($(PRETEST),) +REPORTED_EMACS_VERSION = $(VERSION_PART) +else +REPORTED_EMACS_VERSION = $(EMACS_VERSION) +endif + +CONFIGUREFLAGS = --quiet --enable-silent-rules --prefix="$(HOME)" + +.PHONY: download_emacs_stable clone_emacs_snapshot +.PHONY: configure_emacs install_emacs + +download_emacs_stable: + mkdir tmp + echo "Download Emacs $(EMACS_VERSION) from $(EMACS_TAR_URL)" + curl -o "tmp/emacs-$(EMACS_VERSION).tar.xz" "$(EMACS_TAR_URL)" + tar xf "tmp/emacs-$(EMACS_VERSION).tar.xz" -C tmp + mkdir -p `dirname "$(EMACS_DIR)"` + mv tmp/emacs-$(REPORTED_EMACS_VERSION) "$(EMACS_DIR)" + +clone_emacs_snapshot: + echo "Clone Emacs from Git" + git clone -q --depth=1 '$(EMACS_GIT_URL)' $(EMACS_DIR) + cd $(EMACS_DIR) && ./autogen.sh + +configure_emacs: + echo "Configure Emacs $(EMACS_VERSION)" + cd "$(EMACS_DIR)" && ./configure $(CONFIGUREFLAGS) $(EMACSCONFFLAGS) $(SILENT) + +EMACS_DIR = tmp/emacs +ifeq ($(EMACS_VERSION),snapshot) +configure_emacs: clone_emacs_snapshot +else +configure_emacs: download_emacs_stable +endif + +install_emacs: configure_emacs + echo "Install Emacs $(EMACS_VERSION)" + make -C "$(EMACS_DIR)" -j$(MAKE_JOBS) install prefix=/c/emacs