Skip to content

Commit

Permalink
Support cooking all dependencies as static libraries (#34)
Browse files Browse the repository at this point in the history
As titled
  • Loading branch information
nlighting committed Jul 13, 2023
1 parent 8c38e39 commit 5b4833b
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Expand Up @@ -66,6 +66,10 @@ option (Hiactor_COOK_DEPENDENCIES
"Download and build all dependencies by Hiactor."
OFF)

option (Hiactor_COOK_DEPENDENCIES_ALL_STATIC
"Cook all dependencies as static libraries."
OFF)

set (Hiactor_COOK_EXCLUDES
""
CACHE
Expand Down Expand Up @@ -122,6 +126,13 @@ if (NOT EXISTS ${Hiactor_BUILD_SEASTAR_SOURCE_DIR})
COMMAND git config --local user.email hiactor@alibaba-inc.com
COMMAND git am -q ${Hiactor_SOURCE_DIR}/seastar/patch/hiactor-hackings.patch
WORKING_DIRECTORY ${Hiactor_BUILD_SEASTAR_SOURCE_DIR})
if (Hiactor_COOK_DEPENDENCIES_ALL_STATIC)
execute_process (
COMMAND git config --local user.name hiactor
COMMAND git config --local user.email hiactor@alibaba-inc.com
COMMAND git am -q ${Hiactor_SOURCE_DIR}/seastar/patch/cooking-deps-all-static.patch
WORKING_DIRECTORY ${Hiactor_BUILD_SEASTAR_SOURCE_DIR})
endif ()
endif ()

if (Hiactor_DPDK)
Expand Down Expand Up @@ -191,6 +202,11 @@ if (Hiactor_COOK_DEPENDENCIES)
execute_process (
COMMAND ./cooking.sh -d ${Hiactor_COOKING_BUILD_DIR} -f ${Hiactor_COOKING_INSTALL_DIR} ${exclude_args}
WORKING_DIRECTORY ${Hiactor_BUILD_SEASTAR_SOURCE_DIR})
if (Hiactor_COOK_DEPENDENCIES_ALL_STATIC)
execute_process (
COMMAND bash -c "rm -f lib*.so*"
WORKING_DIRECTORY ${Hiactor_COOKING_INSTALL_DIR}/lib)
endif ()
endif ()

set (CMAKE_PREFIX_PATH ${Hiactor_COOKING_INSTALL_DIR})
Expand Down
132 changes: 132 additions & 0 deletions seastar/patch/cooking-deps-all-static.patch
@@ -0,0 +1,132 @@
From d92eb709be6200f5c75fa89161c37a715abdac3f Mon Sep 17 00:00:00 2001
From: Zichao Zhang <everlight.tomorrow@gmail.com>
Date: Tue, 11 Jul 2023 16:15:18 +0800
Subject: [PATCH] hiactor hackings: Cooking all dependencies with static
libraries

---
cooking_recipe.cmake | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/cooking_recipe.cmake b/cooking_recipe.cmake
index cea386fe..ff4869ea 100644
--- a/cooking_recipe.cmake
+++ b/cooking_recipe.cmake
@@ -69,7 +69,7 @@ cooking_ingredient (gmp
EXTERNAL_PROJECT_ARGS
URL https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2
URL_MD5 8ddbb26dc3bd4e2302984debba1406a5
- CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR> ${info_dir}/gmp
+ CONFIGURE_COMMAND <SOURCE_DIR>/configure --enable-static=yes --enable-shared=no --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR> ${info_dir}/gmp
BUILD_COMMAND <DISABLE>
INSTALL_COMMAND ${make_command} install)

@@ -83,7 +83,7 @@ cooking_ingredient (colm
URL_MD5 16aaf566cbcfe9a06154e094638ac709
# This is upsetting.
BUILD_IN_SOURCE YES
- CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR>
+ CONFIGURE_COMMAND ./configure --enable-static=yes --enable-shared=no --prefix=<INSTALL_DIR>
BUILD_COMMAND <DISABLE>
INSTALL_COMMAND ${make_command} install)

@@ -91,7 +91,7 @@ cooking_ingredient (libpciaccess
EXTERNAL_PROJECT_ARGS
URL https://www.x.org/releases/individual/lib/libpciaccess-0.13.4.tar.gz
URL_MD5 cc1fad87da60682af1d5fa43a5da45a4
- CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR>
+ CONFIGURE_COMMAND <SOURCE_DIR>/configure --enable-static=yes --enable-shared=no --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR>
BUILD_COMMAND <DISABLE>
INSTALL_COMMAND ${make_command} install)

@@ -102,6 +102,7 @@ cooking_ingredient (nettle
URL_MD5 dc0f13028264992f58e67b4e8915f53d
CONFIGURE_COMMAND
<SOURCE_DIR>/configure
+ --disable-shared
--prefix=<INSTALL_DIR>
--srcdir=<SOURCE_DIR>
--libdir=<INSTALL_DIR>/lib
@@ -115,7 +116,7 @@ cooking_ingredient (numactl
EXTERNAL_PROJECT_ARGS
URL https://github.com/numactl/numactl/releases/download/v2.0.12/numactl-2.0.12.tar.gz
URL_MD5 2ba9777d78bfd7d408a387e53bc33ebc
- CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR>
+ CONFIGURE_COMMAND <SOURCE_DIR>/configure --enable-static=yes --enable-shared=yes --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR>
BUILD_COMMAND <DISABLE>
INSTALL_COMMAND ${make_command} install)

@@ -123,7 +124,7 @@ cooking_ingredient (zlib
EXTERNAL_PROJECT_ARGS
URL https://zlib.net/zlib-1.2.13.tar.gz
URL_MD5 9b8aa094c4e5765dabf4da391f00d15c
- CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
+ CONFIGURE_COMMAND <SOURCE_DIR>/configure --static --prefix=<INSTALL_DIR>
BUILD_COMMAND <DISABLE>
INSTALL_COMMAND ${make_command} install)

@@ -149,7 +150,7 @@ cooking_ingredient (Boost
--build-dir=<BINARY_DIR>
install
variant=debug
- link=shared
+ link=static
threading=multi
hardcode-dll-paths=true
dll-path=<INSTALL_DIR>/lib)
@@ -164,6 +165,8 @@ cooking_ingredient (GnuTLS
CONFIGURE_COMMAND
${CMAKE_COMMAND} -E env ${PKG_CONFIG_PATH}
<SOURCE_DIR>/configure
+ --enable-static=yes
+ --enable-shared=no
--prefix=<INSTALL_DIR>
--srcdir=<SOURCE_DIR>
--with-included-unistring
@@ -183,7 +186,7 @@ cooking_ingredient (hwloc
EXTERNAL_PROJECT_ARGS
URL https://download.open-mpi.org/release/hwloc/v2.2/hwloc-2.2.0.tar.gz
URL_MD5 762c93cdca3249eed4627c4a160192bd
- CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR>
+ CONFIGURE_COMMAND <SOURCE_DIR>/configure --enable-static=yes --enable-shared=no --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR>
BUILD_COMMAND <DISABLE>
INSTALL_COMMAND ${make_command} install)

@@ -210,7 +213,7 @@ cooking_ingredient (lksctp-tools
URL https://sourceforge.net/projects/lksctp/files/lksctp-tools/lksctp-tools-1.0.16.tar.gz
URL_MD5 708bb0b5a6806ad6e8d13c55b067518e
PATCH_COMMAND ./bootstrap
- CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR>
+ CONFIGURE_COMMAND <SOURCE_DIR>/configure --enable-static=yes --enable-shared=no --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR>
BUILD_COMMAND <DISABLE>
INSTALL_COMMAND ${make_command} install)

@@ -218,7 +221,7 @@ cooking_ingredient (yaml-cpp
REQUIRES Boost
CMAKE_ARGS
-DYAML_CPP_BUILD_TESTS=OFF
- -DBUILD_SHARED_LIBS=ON
+ -DBUILD_SHARED_LIBS=OFF
EXTERNAL_PROJECT_ARGS
URL https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.3.tar.gz
URL_MD5 b45bf1089a382e81f6b661062c10d0c2)
@@ -231,13 +234,15 @@ cooking_ingredient (c-ares
EXTERNAL_PROJECT_ARGS
URL https://c-ares.haxx.se/download/c-ares-1.13.0.tar.gz
URL_MD5 d2e010b43537794d8bedfb562ae6bba2
- CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR>
+ CONFIGURE_COMMAND <SOURCE_DIR>/configure --enable-static=yes --enable-shared=no --prefix=<INSTALL_DIR> --srcdir=<SOURCE_DIR>
BUILD_COMMAND <DISABLE>
INSTALL_COMMAND ${make_command} install)

cooking_ingredient (cryptopp
CMAKE_ARGS
-DCMAKE_INSTALL_LIBDIR=<INSTALL_DIR>/lib
+ -DBUILD_STATIC=ON
+ -DBUILD_SHARED=OFF
-DBUILD_TESTING=OFF
EXTERNAL_PROJECT_ARGS
URL https://github.com/weidai11/cryptopp/archive/CRYPTOPP_5_6_5.tar.gz
--
2.34.1

0 comments on commit 5b4833b

Please sign in to comment.