Skip to content
Snippets Groups Projects
Commit 786a6a8c authored by Lucas Magalhães's avatar Lucas Magalhães
Browse files

Merge branch 'install_license' into 'master'

E3-1160: Install license files automatically

See merge request e3/e3-require!146
parents 0de7f581 9df22361
Branches master
No related tags found
No related merge requests found
......@@ -258,6 +258,12 @@ CFGS = ${CONFIGS}
CFGS += ${CONFIGS_${EPICSVERSION}}
export CFGS
INSTALL_LICENSE = ${MODULE_LOCATION}/doc
# Find all license files to distribute with binaries
LICENSES = $(shell find -not -path '*/.*' -type f -iname LICENSE)
LICENSES += $(shell find -not -path '*/.*' -type f -iname Copyright)
export LICENSES
# Filter architectures to build using EXCLUDE_ARCHS and ARCH_FILTER.
ALL_ARCHS = ${EPICS_HOST_ARCH} ${CROSS_COMPILER_TARGET_ARCHS}
BUILD_ARCHS = $(filter-out $(addprefix %,${EXCLUDE_ARCHS}),$(filter-out $(addsuffix %,${EXCLUDE_ARCHS}),\
......@@ -309,6 +315,7 @@ debug::
@echo "LIBVERSION = ${LIBVERSION}"
@echo "E3_SITEMODS_PATH = ${E3_SITEMODS_PATH}"
@echo "EPICS_MODULES = ${EPICS_MODULES}"
@echo "LICENSES = ${LICENSES}"
# Create e.g. build-$(T_A) rules for each architecture, so that we can just do
# build: build-arch1 build-arch2
......@@ -349,6 +356,20 @@ build:: ${COMMON_DIR}/${METAFILE}
install:: ${INSTALL_META}
# The licenses should be installed after everything
define license_install =
$1: $2
@echo "Installing license file $$^"
$$(INSTALL) -d -m444 $$^ $$(@D)
install:: $1
endef
# Creates a target for every license file to be installed. Some modules have
# more than one license file that needs distribution. For them we add the
# previous directory so we have them separate by projects inside /doc.
$(foreach d, $(LICENSES), $(eval $(call license_install, $(INSTALL_LICENSE)/$(filter-out ., $(lastword $(subst /, , $(dir $(d))))/$(notdir $(d))), $(d))))
else # T_A
ifeq ($(filter O.%,$(notdir ${CURDIR})),)
......
......@@ -736,3 +736,20 @@ def test_missing_record_dbd_file_causes_build_failure(wrapper: Wrapper):
),
errs,
)
def test_install_license(wrapper: Wrapper):
wrapper.add_file("LICENSE")
wrapper.add_directory("foo")
wrapper.add_file("foo/LICENSE")
rc, out, _ = wrapper.run_make("install")
assert rc == 0
assert re.search("Installing license file LICENSE", out)
assert re.search("Installing license file foo/LICENSE", out)
file_path = wrapper.package_dir / "doc/LICENSE"
assert file_path.exists()
file_path = wrapper.package_dir / "doc/foo/LICENSE"
assert file_path.exists()
......@@ -98,6 +98,9 @@ include $(E3_REQUIRE_TOOLS)/driver.makefile
def add_file(self, name):
(self.module_dir / name).touch()
def add_directory(self, name):
(self.module_dir / name).mkdir()
def write_dot_local_data(self, config_file: str, config_vars: dict):
"""Write config data to the specific .local file."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment