From 7b16f7f69f4f500e6c2b5243a2f2bba3d0212c80 Mon Sep 17 00:00:00 2001
From: Greg Hogan <code@greghogan.com>
Date: Wed, 3 Nov 2021 15:20:51 +0000
Subject: [PATCH 1/2] gnu: Add bloomberg-bde-tools.

* gnu/packages/cpp.scm (bloomberg-bde-tools): New variable.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/cpp.scm                          | 28 ++++++
 ...bloomberg-bde-tools-fix-install-path.patch | 95 +++++++++++++++++++
 3 files changed, 124 insertions(+)
 create mode 100644 gnu/packages/patches/bloomberg-bde-tools-fix-install-path.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index d20a51070b..9bafada1fa 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -913,6 +913,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/blender-2.79-oiio2.patch			\
   %D%/packages/patches/blender-2.79-python-3.7-fix.patch	\
   %D%/packages/patches/blender-2.79-python-3.8-fix.patch	\
+  %D%/packages/patches/bloomberg-bde-tools-fix-install-path.patch	\
   %D%/packages/patches/bpftrace-disable-bfd-disasm.patch	\
   %D%/packages/patches/byobu-writable-status.patch		\
   %D%/packages/patches/cabal-install-base16-bytestring1.0.patch		\
diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index c3b6403e02..5b3180e326 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -45,6 +45,7 @@ (define-module (gnu packages cpp)
   #:use-module (guix utils)
   #:use-module (guix git-download)
   #:use-module (guix build-system cmake)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
   #:use-module (guix modules)
@@ -1450,3 +1451,30 @@ (define-public simdjson
 validation.")
     (home-page "https://github.com/simdjson/simdjson")
     (license license:asl2.0)))
+
+(define-public bloomberg-bde-tools
+  (let ((commit "3ff522692e87e5350889d7d3c6b7a7b3743f6bed"))
+    (package
+      (name "bloomberg-bde-tools")
+      ;; Recent releases are not tagged so commit must be used for checkout.
+      (version "3.96.0.0")
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/bloomberg/bde-tools")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0ckkykcbajg56nn7l4qwlj3ypyb09r31qjl0gv9lpmnyg9lqsbz4"))
+                (patches
+                 (search-patches
+                  "bloomberg-bde-tools-fix-install-path.patch"))))
+      (build-system copy-build-system)
+      ;; Unable to be an inline dependency of bloomberg-bde due to patch.
+      (properties '((hidden? . #t)))
+      (synopsis "Tools for developing and building libraries modeled on BDE")
+      (description
+       "This package provides the cmake imports needed to build bloomberg-bde.")
+      (home-page "https://github.com/bloomberg/bde-tools")
+      (license license:asl2.0))))
diff --git a/gnu/packages/patches/bloomberg-bde-tools-fix-install-path.patch b/gnu/packages/patches/bloomberg-bde-tools-fix-install-path.patch
new file mode 100644
index 0000000000..a80c6c3ea3
--- /dev/null
+++ b/gnu/packages/patches/bloomberg-bde-tools-fix-install-path.patch
@@ -0,0 +1,95 @@
+Install shared libraries into "lib". Do not create symbolic links to static
+libraries since only shared libraries are built.
+
+--- a/cmake/layers/ufid.cmake
++++ b/cmake/layers/ufid.cmake
+@@ -6,10 +6,7 @@ bde_prefixed_override(ufid project_setup_install_opts)
+ function(ufid_project_setup_install_opts proj)
+     bde_assert_no_extra_args()
+ 
+-    set(libPath "bin/so")
+-    if (${bde_ufid_is_64}) 
+-        string(APPEND libPath "/64")
+-    endif()
++    set(libPath "lib")
+ 
+     bde_struct_create(
+         installOpts
+@@ -86,13 +83,6 @@ function(bde_create_ufid_symlink uor installOpts)
+             "${symlinkPrefix}/${symlinkDir}/${libLinkName}"
+         )
+ 
+-        install(
+-            CODE
+-                "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
+-                ${symlinkVal} ${symlinkFile})"
+-            COMPONENT "${component}-symlinks"
+-        )
+-
+         # This code creates compatibility symlinks
+         # WARNING: This is custom logic that has nothing to do with our build system.
+         # Some external build systems expect to find a variaty of ufids in dpkg.
+@@ -110,14 +100,6 @@ function(bde_create_ufid_symlink uor installOpts)
+                 symlinkFile
+                 "${symlinkPrefix}/${symlinkDir}/${libLinkName}"
+             )
+-
+-            # IMPORTANT: symlinkFile is the same as above!
+-            install(
+-                CODE
+-                    "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
+-                    ${symlinkVal} ${symlinkFile})"
+-                COMPONENT "${component}-symlinks"
+-            )
+         endif()
+ 
+         if (${bde_ufid_is_pic})
+@@ -134,14 +116,6 @@ function(bde_create_ufid_symlink uor installOpts)
+                 "${symlinkPrefix}/${symlinkDir}/${libLinkName}"
+             )
+ 
+-            # IMPORTANT: symlinkFile is the same as above!
+-            install(
+-                CODE
+-                    "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
+-                    ${symlinkVal} ${symlinkFile})"
+-                COMPONENT "${component}-pic-symlink-hack"
+-            )
+-
+             # And another one for "64" - remove "pic", add "64"
+             if (${bde_ufid_is_64})
+                 set(temp_ufid_flags ${install_ufid_flags})
+@@ -157,14 +131,6 @@ function(bde_create_ufid_symlink uor installOpts)
+                     symlinkFile
+                     "${symlinkPrefix}/${symlinkDir}/${libLinkName}"
+                 )
+-
+-                # IMPORTANT: symlinkFile is the same as above!
+-                install(
+-                    CODE
+-                        "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
+-                        ${symlinkVal} ${symlinkFile})"
+-                    COMPONENT "${component}-pic-symlink-hack"
+-                )
+             endif()
+         endif()
+ 
+@@ -177,18 +143,5 @@ function(bde_create_ufid_symlink uor installOpts)
+             symlinkReleaseFile
+             "${symlinkPrefix}/${symlinkDir}/${libReleaseLinkName}"
+         )
+-        install(
+-            CODE
+-                "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
+-                ${symlinkVal} ${symlinkReleaseFile})"
+-            COMPONENT "${component}-release-symlink"
+-        )
+-        install(
+-            CODE
+-                "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
+-                ${symlinkVal} ${symlinkReleaseFile})"
+-            COMPONENT "release-symlink"
+-            EXCLUDE_FROM_ALL
+-        )
+     endif()
+ endfunction()
-- 
2.34.0

