From 021ee98bebda07afa487b57b72e1b1ae76182f9a Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Fri, 4 Nov 2022 15:03:36 +0100 Subject: [PATCH] Fix gnatcov 23 for Windows and macOS --- specs/gnatcov.anod | 17 +++++++++-- specs/patches/gnatcov-23.0.patch | 51 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 specs/patches/gnatcov-23.0.patch diff --git a/specs/gnatcov.anod b/specs/gnatcov.anod index 926f225..5a32f43 100644 --- a/specs/gnatcov.anod +++ b/specs/gnatcov.anod @@ -7,7 +7,7 @@ from e3.diff import patch import os -patch_name = "gnatcov.patch" +patch_name = "gnatcov-23.0.patch" class GNATcov(spec("common")): @@ -33,8 +33,9 @@ class GNATcov(spec("common")): @property def build_source_list(self): return [ - Anod.Source(name=self.tarball, publish=True, dest="") - ] + Anod.Source(name=self.tarball, publish=True, dest=""), + self.Source(name=patch_name, publish=True, unpack_cmd=cp, dest="patches"), + ] @property def build_deps(self): @@ -63,6 +64,16 @@ class GNATcov(spec("common")): for m in [d for d in self.deps if d != "binutils"]: self.deps[m].setenv() + # Little hack to apply the patch only once, there is probably a clean + # way to do that. + patched = os.path.join(self["SRC_DIR"], "patches", ".patched") + if not os.path.exists(patched): + patch( + os.path.join(self["SRC_DIR"], "patches", patch_name), + self.build_space.src_dir, + ) + touch(patched) + build_mode = "prod" exec_dir = os.path.join(self["SRC_DIR"], "tools", "gnatcov") diff --git a/specs/patches/gnatcov-23.0.patch b/specs/patches/gnatcov-23.0.patch new file mode 100644 index 0000000..ca814e7 --- /dev/null +++ b/specs/patches/gnatcov-23.0.patch @@ -0,0 +1,51 @@ +diff --git tools/gnatcov/Makefile tools/gnatcov/Makefile +index 1282b82fb..d7e90fad4 100644 +--- tools/gnatcov/Makefile ++++ tools/gnatcov/Makefile +@@ -95,8 +95,12 @@ ifeq ($(C_SUPPORT), True) + include libclang_common.mk + else + CURRENT_DIR := $(dir $(abspath $(firstword $(MAKEFILE_LIST)))) ++ifeq ($(HOST_OS), windows) ++GPR_PROJECT_PATH := $(CURRENT_DIR)/gpr_stubs;$(GPR_PROJECT_PATH) ++else + GPR_PROJECT_PATH := $(CURRENT_DIR)/gpr_stubs:$(GPR_PROJECT_PATH) + endif ++endif + + ##################################################################### + # Targets to build the core tool and the trace adapters, optionally # +@@ -325,7 +329,7 @@ install-adapters: $(INSTALL_ADAPTER_TARGETS) + # which has its own extra info embedded and eventually installs just all what + # the distrib tree contains. We don't want any toplevel item there. + +-.PHONY: distrib-linux-extra distrib-windows-extra distrib ++.PHONY: distrib-linux-extra distrib-windows-extra distrib-darwin-extra distrib + + distrib-linux-extra: + [ -f COPYING3 ] || $(CP) ../../COPYING3 . +@@ -337,6 +341,8 @@ distrib-linux-extra: + + distrib-windows-extra: + ++distrib-darwin-extra: ++ + distrib-common: install-adapters distrib-${HOST_OS}-extra + distrib-without-doc: distrib-common install-without-doc + distrib: distrib-without-doc +diff --git tools/gnatcov/host.mk tools/gnatcov/host.mk +index 53ba4b0be..445095784 100644 +--- tools/gnatcov/host.mk ++++ tools/gnatcov/host.mk +@@ -14,6 +14,11 @@ HOST_OS=linux + LN_S=ln -sf + exeext= + endif ++ifneq (,$(filter Darwin, $(HOST_UNAME))) ++HOST_OS=darwin ++LN_S=ln -sf ++exeext= ++endif + + RM=rm -f + CP=cp -pf