add Makefile and CI support

Add a Makefile so that pEpEngineSequoiaBackend can be build using the
usual pEp style without directly invoking cargo, supporting the usual
targets build, install, uninstall, test, clean, all.
Make the project easy to install and uninstall, with a user-settable
prefix.
The Makefile is extensible with a local.conf file, of which we provide
an example.

Add CI support.

Add a .gitignore file.

Co-authored-by: Heck <heck@pep.foundation>
Co-authored-by: Neal H. Walfield <neal@walfield.org>
Co-authored-by: Luca Saiu <positron@pep.foundation>
Co-authored-by: Devan Carpenter <dvn@pep-project.org>
Co-authored-by: Volker Birk <volker.birk@pep-project.org>
pull/18/head
heck 3 weeks ago committed by Luca Saiu
parent a26552db00
commit f6addca5fc

1
.gitignore vendored

@ -1,2 +1,3 @@
*~
/target
/local.conf

@ -60,6 +60,24 @@ bookworm:
CARGO_HOME: /cargo
after_script: []
makefile:
tags:
- linux
stage: build
image: registry.gitlab.com/sequoia-pgp/build-docker-image/bookworm-prebuild:latest
needs:
- codespell
script:
- make build
- make test
- make clean
- DEBUG=debug make test
variables:
BUILD: /target
CARGO_HOME: /cargo
CARGO_TARGET_DIR:
after_script: []
all_commits:
# Test each commit up to main, to facilitate bisecting.
stage: test

@ -0,0 +1,86 @@
# Copyright 2023, pEp Foundation
# This file is part of pEpEngineSequoiaBackend
# This file may be used under the terms of the GNU General Public License version 3
# see COPYING
# Build config defaults
DEBUG?=debug
PREFIX?=/usr/local
CARGO?=cargo
BUILD?=_build
# Build config overrides
-include ./local.conf
# Make sure CARGO_TARGET_DIR is not set by the user -- it would be ignored.
CARGO_TARGET_DIR?=
ifneq ($(CARGO_TARGET_DIR),)
$(error "the user should not set 'CARGO_TARGET_DIR': 'BUILD' can be used \
instead.")
endif
#export as env var to sub-shells
export CARGO_TARGET_DIR=$(BUILD)
# constants
LIB_NAME=libpep_engine_sequoia_backend
# determine library file extension
PLATFORM:=$(shell uname)
ifeq ($(PLATFORM),Linux)
DYNLIB_EXT=so
else ifeq ($(PLATFORM),Darwin)
DYNLIB_EXT=dylib
else
$(error "Dont know how to build for '$(PLATFORM)'")
endif
# DEBUG can be defined as "release", "debug" or "maintainer".
ifeq ($(DEBUG),maintainer) # For compatibility with other pEp repos.
VARIANT_NAME=debug
VARIANT_FLAGS=
else ifeq ($(DEBUG),debug)
VARIANT_NAME=debug
VARIANT_FLAGS=
else ifeq ($(DEBUG),release)
VARIANT_NAME=release
VARIANT_FLAGS=--release
else
$(error "build option 'DEBUG' must be 'release', 'debug' or 'maintainer'")
endif
LIB_DYNAMIC_PATH=$(CARGO_TARGET_DIR)/$(VARIANT_NAME)/$(LIB_NAME).$(DYNLIB_EXT)
LIB_STATIC_PATH=$(CARGO_TARGET_DIR)/$(VARIANT_NAME)/$(LIB_NAME).a
PKGCONFIG_PATH=$(CARGO_TARGET_DIR)/$(VARIANT_NAME)/pep_engine_sequoia_backend.pc
LIB_DIR=$(PREFIX)/lib/
PKGCONFIG_DIR=$(PREFIX)/share/pkgconfig/
CARGO_FLAGS+=$(VARIANT_FLAGS)
ifneq ($(filter Darwin %BSD,$(shell uname -s)),)
INSTALL?=ginstall
else
INSTALL?=install
endif
.PHONY: all build install uninstall test clean
all: build
build:
$(CARGO) build $(CARGO_FLAGS)
install: build
mkdir -p $(LIB_DIR) $(PKGCONFIG_DIR)
$(INSTALL) $(LIB_DYNAMIC_PATH) $(LIB_DIR)
$(INSTALL) $(LIB_STATIC_PATH) $(LIB_DIR)
$(INSTALL) $(PKGCONFIG_PATH) $(PKGCONFIG_DIR)
uninstall:
rm -f $(LIB_DIR)/$(LIB_NAME).$(DYNLIB_EXT)
rm -f $(LIB_DIR)/$(LIB_NAME).a
rm -f $(PKGCONFIG_DIR)/pep_engine_sequoia_backend.pc
test:
$(CARGO) test $(CARGO_FLAGS)
clean:
$(CARGO) clean

@ -0,0 +1,17 @@
# This is an Example build config (local.conf)
# The values here reflect the defaults.
# If needed, copy this file into a file called
# `local.conf` and adjust the values
# The dir where the build artifacts get installed into
# PREFIX=/usr/local
# Build variant: one of release , debug , maintainer (maintainer exists for
# compatibility with other pEp projects: in this project maintainer and debug
# builds are the same). The default is debug .
# DEBUG=release
# Defines the build dir. This can be a relative or an absolute path.
# BUILD=_build
Loading…
Cancel
Save