]> granicus.if.org Git - graphviz/commitdiff
CMake: enable 'diffimg'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 26 Mar 2022 20:39:07 +0000 (13:39 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 28 Mar 2022 14:41:27 +0000 (07:41 -0700)
Note that the rtest/rtest.py work around is still not fully removed because
libgd is not currently available in the 64-bit Windows CI environment.

Gitlab: closes #1788

CHANGELOG.md
CMakeLists.txt
ci/tests.py
contrib/diffimg/CMakeLists.txt [new file with mode: 0644]
rtest/rtest.py

index 6bb4e69f9d0aad692f65fd0d2815e158470c7d1d..8ea800479bf7d0157e7e95e94978edf02463a40e 100644 (file)
@@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Changed
 
-- the `mingle` and `edgepaint` binaries are now included in the CMake build
+- the `mingle`, `diffimg`, and `edgepaint` binaries are now included in the
+  CMake build system
 - a brief note about the (previously undocumented) behavior of Graphviz when
   sent `SIGUSR1` is now mentioned in the man page
 
index 8186859f8148b953ff2d2e516b59df548a4617c7..e77e87c547c886cb99aaab04aa4cdf72dc1ac72d 100644 (file)
@@ -279,6 +279,7 @@ include(CPack)
 Include(CTest)
 
 # ======================= Specify subdirectories to build ======================
+add_subdirectory(contrib/diffimg)
 add_subdirectory(lib)
 add_subdirectory(plugin)
 add_subdirectory(cmd)
index 39eea310d5736a48c933fd3c195f3113af1b1703..a2a2dae10825a24a5472d5410bfb98276f02ca7f 100644 (file)
@@ -100,7 +100,6 @@ def test_existence(binary: str):
 
   tools_not_built_with_cmake = [
     "cluster",
-    "diffimg",
     "dot_builtins",
     "dotty",
     "gv2gxl",
@@ -171,6 +170,10 @@ def test_existence(binary: str):
     check_that_tool_does_not_exist(binary, os_id)
     pytest.skip(f"{binary} is not built on some Windows due to lacking libANN")
 
+  if binary == "diffimg" and is_win64():
+    check_that_tool_does_not_exist(binary, os_id)
+    pytest.skip(f"{binary} is not built on 64-bit Windows due to lacking libgd")
+
   assert shutil.which(binary) is not None
 
 def check_that_tool_does_not_exist(tool, os_id):
diff --git a/contrib/diffimg/CMakeLists.txt b/contrib/diffimg/CMakeLists.txt
new file mode 100644 (file)
index 0000000..17c44b1
--- /dev/null
@@ -0,0 +1,37 @@
+find_package(GD)
+
+if(GD_FOUND)
+
+  add_executable(diffimg diffimg.c)
+  target_include_directories(diffimg PRIVATE ${GRAPHVIZ_LIB_DIR})
+  target_include_directories(diffimg SYSTEM PRIVATE ${GD_INCLUDE_DIRS})
+  target_link_libraries(diffimg ${GD_LIBRARIES})
+
+  install(
+    TARGETS diffimg
+    RUNTIME DESTINATION ${BINARY_INSTALL_DIR}
+    LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
+    ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
+  )
+
+  if(GZIP)
+    add_custom_target(man-diffimg ALL DEPENDS diffimg.1.gz
+                      COMMENT "diffimg man page")
+    add_custom_command(
+      OUTPUT diffimg.1.gz
+      COMMAND ${GZIP} -9 --no-name --to-stdout diffimg.1
+        >"${CMAKE_CURRENT_BINARY_DIR}/diffimg.1.gz"
+      MAIN_DEPENDENCY diffimg.1
+      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+      COMMENT "compress diffimg man page")
+    install(
+      FILES ${CMAKE_CURRENT_BINARY_DIR}/diffimg.1.gz
+      DESTINATION ${MAN_INSTALL_DIR}/man1)
+  else()
+    install(
+      FILES diffimg.1
+      DESTINATION ${MAN_INSTALL_DIR}/man1
+    )
+  endif()
+
+endif()
index 874b76fa57eee399cbbda2c5fb44d13b27761e78..e50682e3f37d1590b240f862d46933d41a2cc113 100755 (executable)
@@ -152,10 +152,11 @@ def doDiff(OUTFILE, testname, subtest_index, fmt):
     returncode = 0 if a.strip() == b.strip() else -1
   elif F == "png":
     # FIXME: remove when https://gitlab.com/graphviz/graphviz/-/issues/1788 is fixed
-    if os.environ.get("build_system") == "cmake":
+    if os.environ.get("build_system") == "cmake" and \
+        platform.system() == "Windows":
       print(f"Warning: Skipping PNG image comparison for test {testname}:"
-            f"{subtest_index} : format: {fmt} because CMake builds does not "
-             "contain the diffimg utility (#1788)",
+            f"{subtest_index} : format: {fmt} because CMake builds on Windows "
+             "do not contain the diffimg utility (#1788)",
             file=sys.stderr)
       return
     returncode = subprocess.call(
@@ -404,7 +405,8 @@ if not GENERATE:
     print("Could not find a value for DIFFIMG", file=sys.stderr)
     # FIXME: Remove workaround for missing diffimg when
     # https://gitlab.com/graphviz/graphviz/-/issues/1788 is fixed
-    if os.environ.get("build_system") != "cmake":
+    if os.environ.get("build_system") != "cmake" or \
+        platform.system() != "Windows":
       sys.exit(1)
 #    sys.exit(1)