]> granicus.if.org Git - graphviz/commitdiff
add Mingle to the CMake build system
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 25 Dec 2021 19:25:29 +0000 (11:25 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 19 Mar 2022 20:30:01 +0000 (13:30 -0700)
Gitlab: related to #1835, #1836, #1854

CHANGELOG.md
ci/tests.py
cmd/CMakeLists.txt
cmd/mingle/CMakeLists.txt [new file with mode: 0644]
rtest/test_tools.py

index 8dc35e90d82f4b5eca9000883e640110114379aa..cf4583472313b0c289237a455a5e7bbee9c1dae2 100644 (file)
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased (3.0.1)]
 
+### Changed
+
+- the `mingle` binary is now included in the CMake build
+
 ### Fixed
 
 - `agcanon`, `agcanonStr`, and `agwrite` now return error values on memory
index d5a5bb0ecfd0d02ca2d6e90aef2c45519e9b6458..753cacb14e089b180e4c800e48e011a3e120c41d 100644 (file)
@@ -13,7 +13,7 @@ from typing import Dict
 import pytest
 
 sys.path.append(os.path.join(os.path.dirname(__file__), "../rtest"))
-from gvtest import dot, is_cmake #pylint: disable=C0413
+from gvtest import dot, is_cmake, is_mingw #pylint: disable=C0413
 
 def _freedesktop_os_release() -> Dict[str, str]:
   """
@@ -39,6 +39,16 @@ def is_centos() -> bool:
   """
   return _freedesktop_os_release().get("ID") == "centos"
 
+def is_win64() -> bool:
+  """
+  is the Graphviz under test targeting the x64 Windows API?
+  """
+  if platform.system() != "Windows":
+    return False
+  if os.getenv("project_platform") != "x64":
+    return False
+  return True
+
 @pytest.mark.parametrize("binary", [
   "acyclic",
   "bcomps",
@@ -100,7 +110,6 @@ def test_existence(binary: str):
     "gvmap.sh",
     "gxl2dot",
     "lneato",
-    "mingle",
     "prune",
     "smyrna",
     "vimdot",
@@ -126,7 +135,7 @@ def test_existence(binary: str):
 
   # FIXME: Remove skip when
   # https://gitlab.com/graphviz/graphviz/-/issues/1835 is fixed
-  if os_id == "ubuntu" and binary == "mingle":
+  if os_id == "ubuntu" and binary == "mingle" and not is_cmake():
     check_that_tool_does_not_exist(binary, os_id)
     pytest.skip(f"mingle is not built for {os_id} (#1835)")
 
@@ -159,6 +168,10 @@ def test_existence(binary: str):
         check_that_tool_does_not_exist(binary, os_id)
         pytest.skip(f"{binary} is not built with autotools on macOS (#1854)")
 
+  if binary == "mingle" and is_cmake() and (is_win64() or is_mingw()):
+    check_that_tool_does_not_exist(binary, os_id)
+    pytest.skip(f"{binary} is not built on some Windows due to lacking libANN")
+
   assert shutil.which(binary) is not None
 
 def check_that_tool_does_not_exist(tool, os_id):
index 60f84ff6313acd70f2905aa878f50b98dbdf4f4f..d23c934c1baf9d41c9e8c23e4e88f2fa37ad725c 100644 (file)
@@ -1,3 +1,4 @@
 add_subdirectory(dot)
 add_subdirectory(gvpr)
+add_subdirectory(mingle)
 add_subdirectory(tools)
diff --git a/cmd/mingle/CMakeLists.txt b/cmd/mingle/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5c44790
--- /dev/null
@@ -0,0 +1,59 @@
+if(with_sfdp AND ANN_FOUND)
+
+  add_executable(mingle
+    minglemain.cpp
+  )
+
+  target_include_directories(mingle
+    PRIVATE
+      ${GRAPHVIZ_LIB_DIR}
+      ${GRAPHVIZ_LIB_DIR}/cdt
+      ${GRAPHVIZ_LIB_DIR}/cgraph
+      ${GRAPHVIZ_LIB_DIR}/common
+      ${GETOPT_INCLUDE_DIRS}
+  )
+
+  target_link_libraries(mingle
+    cdt
+    cgraph
+    common
+    ingraphs
+    libmingle
+    neatogen
+    rbtree
+    sfdpgen
+    sparse
+    ${ANN_LIBRARIES}
+  )
+  if(NOT HAVE_GETOPT_H)
+    target_link_libraries(mingle ${GETOPT_LINK_LIBRARIES})
+  endif()
+
+  install(
+    TARGETS mingle
+    RUNTIME DESTINATION ${BINARY_INSTALL_DIR}
+    LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
+    ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
+  )
+
+  if(GZIP)
+    add_custom_target(man-mingle ALL DEPENDS mingle.1.gz
+                      COMMENT "mingle man page")
+    add_custom_command(
+      OUTPUT mingle.1.gz
+      COMMAND ${GZIP} -9 --no-name --to-stdout mingle.1
+        >"${CMAKE_CURRENT_BINARY_DIR}/mingle.1.gz"
+      MAIN_DEPENDENCY mingle.1
+      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+      COMMENT "compress mingle man page")
+    install(
+      FILES ${CMAKE_CURRENT_BINARY_DIR}/mingle.1.gz
+      DESTINATION ${MAN_INSTALL_DIR}/man1)
+  else()
+    install(
+      FILES mingle.1
+      DESTINATION ${MAN_INSTALL_DIR}/man1
+    )
+  endif()
+
+endif()
index 5970dbd12c08588252b2fa7a33aded7c76680af3..ea98b3a695d88cfbf85dc10ff3d93c94e7d1d9b3 100644 (file)
@@ -11,8 +11,12 @@ import platform
 import re
 import shutil
 import subprocess
+import sys
 import pytest
 
+sys.path.append(os.path.dirname(__file__))
+from gvtest import is_cmake #pylint: disable=C0413
+
 @pytest.mark.parametrize("tool", [
     "acyclic",
     "bcomps",
@@ -81,6 +85,13 @@ def test_tools(tool):
   environ_copy = os.environ.copy()
   environ_copy.pop("DISPLAY", None)
 
+  # FIXME: mingle triggers ODR violations
+  if tool == "mingle":
+    if "ASAN_OPTIONS" in environ_copy:
+      environ_copy["ASAN_OPTIONS"] += ":detect_odr_violation=0"
+    else:
+      environ_copy["ASAN_OPTIONS"] = "detect_odr_violation=0"
+
   # Test usage
   with subprocess.Popen([tool, "-?"], env=environ_copy,
                         stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
@@ -88,6 +99,11 @@ def test_tools(tool):
     output, _ = p.communicate()
     ret = p.returncode
 
+  # FIXME: mingle built with CMake on Windows crashes
+  if tool == "mingle" and is_cmake() and platform.system() == "Windows":
+    assert ret != 0, "mingle on Windows with CMake fixed?"
+    return
+
   assert ret == 0, f"`{tool} -?` failed. Output was: {output}"
 
   assert re.match("usage", output, flags=re.IGNORECASE) is not None, \