Skip to content

Commit

Permalink
Fix gnatcov 23 for Windows and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien-Chouteau committed Nov 7, 2022
1 parent ad2567a commit 021ee98
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
17 changes: 14 additions & 3 deletions specs/gnatcov.anod
Original file line number Diff line number Diff line change
Expand Up @@ -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")):
Expand All @@ -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):
Expand Down Expand Up @@ -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")

Expand Down
51 changes: 51 additions & 0 deletions specs/patches/gnatcov-23.0.patch
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 021ee98

Please sign in to comment.