From 50e02226de9ad542191963c74863cfc5bdbd0bdb Mon Sep 17 00:00:00 2001 From: heck Date: Wed, 30 Aug 2023 15:27:10 +0200 Subject: [PATCH] Build: pEp wide build consistency / rename local.conf to build.conf /add BUILD_CONF / support DEBUG=[debug|release] --- .gitignore | 2 +- Makefile | 2 +- Makefile.conf | 32 +++++++++++++++++++++++--------- build.conf.example | 7 +++++++ docs/source/install.rst | 10 ++++++---- local.conf.example | 11 ----------- 6 files changed, 38 insertions(+), 26 deletions(-) create mode 100644 build.conf.example delete mode 100644 local.conf.example diff --git a/.gitignore b/.gitignore index d28142e..6ff45e5 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,7 @@ docs/build/ .tox/ ======= # Build config -local.conf +build.conf # Python artifacts /build/ diff --git a/Makefile b/Makefile index 623ee29..457e093 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ install-user: compile # Envrionment # =========== # Creates and activates a new venv that has the LD_LIBRARY_PATH/DYLD_LIBRARY_PATH -# already set for the prefix specified in local.conf +# already set for the prefix specified in build.conf # Only activates venv if already existing venv: python3 -m venv $(VENV_DIR) diff --git a/Makefile.conf b/Makefile.conf index eb00e92..f2618ba 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -1,4 +1,25 @@ -HERE:=$(dir $(lastword $(MAKEFILE_LIST))) +# BUILD_CONF must be specified relative to the repo root or must be an absolute path +# BUILD_CONF defaults to ./build.conf +REPO_ROOT_REL:=$(dir $(lastword $(MAKEFILE_LIST))) +ifndef BUILD_CONF + BUILD_CONF=$(REPO_ROOT_REL)/build.conf + -include $(BUILD_CONF) +else + BUILD_CONF_EFF=$(BUILD_CONF) + ifeq ($(dir $(BUILD_CONF)),./) + BUILD_CONF_EFF=$(REPO_ROOT_REL)/$(BUILD_CONF) + endif + ifeq ($(wildcard $(BUILD_CONF_EFF)),) + $(info BUILD_CONF must be specified relative to the repo root or must be an absolute path) + $(error file specified using BUILD_CONF ($(BUILD_CONF)) not found) + endif + include $(BUILD_CONF_EFF) +endif + +# Build config Defaults +PREFIX?=$(HOME) +DEBUG?=debug + # Constants BUILD_DIR = ./build @@ -10,14 +31,7 @@ PYTHON_ARTIFACTS += ./src/pEp.egg-info PYTHON_ARTIFACTS += ./.pytest_cache VENV_DIR = ./_venv -# Build config Defaults -DEBUG=1 -PREFIX=$(HOME) - -######### Overrides ######### --include $(HERE)local.conf - -ifeq ($(DEBUG),1) +ifeq ($(DEBUG),debug) DEBUG_OPT+=--debug endif diff --git a/build.conf.example b/build.conf.example new file mode 100644 index 0000000..22270fc --- /dev/null +++ b/build.conf.example @@ -0,0 +1,7 @@ +# This is an Example build config file (build.conf) +# The values represent the defaults. +# If the defaults dont work for you You can override them here. +# Tweak the values to your needs and rename it to build.conf + +# PREFIX=$(HOME) +# DEBUG=debug # [debug|release] diff --git a/docs/source/install.rst b/docs/source/install.rst index 8a85064..0ebc7fb 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -25,10 +25,12 @@ compiled first. So, before any use or installation, the module needs to be built Build config ~~~~~~~~~~~~ -Create a local build config by creating a 'local.conf' file. There is a 'local.conf.example' describing -all the build options. You can use this as a template. +The build configuration file is called `build.conf` or can be specified (relative to repo root) using +the env var `BUILD_CONF`. -``cp local.conf.example local.conf`` +There is a 'build.conf.example' describing all the build options. You can use this as a template. + +``cp build.conf.example build.conf`` If you have pEp-base installed under a custom prefix (e.g. /home/foo/local) it is important that you specify "PREFIX". @@ -47,7 +49,7 @@ Virtualenv ---------- We recommend using a venv to work on/with the pEpPythonAdapter. There is a convenience make target that will create and activate a venv that already has the LD_LIBRARY_PATH -or DYLD_LIBRARY_PATH set according to your ``local.conf``. +or DYLD_LIBRARY_PATH set according to your ``build.conf``. If the venv does not exist yet it will be created and activated. If the venv already exists it will only be activated. diff --git a/local.conf.example b/local.conf.example deleted file mode 100644 index 9438ccf..0000000 --- a/local.conf.example +++ /dev/null @@ -1,11 +0,0 @@ -# This is an Example build config file (local.conf) -# you might not need this file, but if the defaults dont work for you -# You can override them here. -# Tweak the values to your needs and rename it to local.conf - -######### C++ Compiler ######### -# DEBUG=1 -# DEBUG=0 - -############# DIRS ############# -# PREFIX=$(HOME)/local