Add optional support for git submodule building (#172)

This commit is contained in:
Lee *!* Clagett
2025-07-03 18:43:00 -04:00
committed by Lee *!* Clagett
parent 448c6740f4
commit d382c73b51
4 changed files with 145 additions and 89 deletions

View File

@@ -14,8 +14,40 @@ env:
echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom echo "Acquire::Retries \"3\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom echo "Acquire::http::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom echo "Acquire::ftp::Timeout \"120\";" | sudo tee -a /etc/apt/apt.conf.d/80-custom
BREW_INSTALL_MAC: 'HOMEBREW_NO_AUTO_UPDATE=1 brew install boost hidapi openssl zmq libpgm miniupnpc expat libunwind-headers protobuf unbound'
jobs: jobs:
build-beginner:
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: set apt conf (Debian base Linux)
if: matrix.os == 'ubuntu-latest'
run: ${{env.APT_SET_CONF}}
- name: update apt (Debian based Linux)
if: matrix.os == 'ubuntu-latest'
run: sudo apt update
- name: Install dependencies (Debian based Linux)
if: matrix.os == 'ubuntu-latest'
run: ${{env.APT_INSTALL_LINUX}}
- name: Install dependencies (MacOS)
if: matrix.os == 'macos-latest'
run: ${{env.BREW_INSTALL_MAC}}
- name: Checkout LWS Source
uses: actions/checkout@v4
with:
path: ${{github.workspace}}/lws
submodules: recursive
- name: Configure LWS
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/lws/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{github.workspace}}/lws
- name: Build LWS
# Build your program with the given configuration
run: (cd ${{github.workspace}}/lws/build && make -j$(nproc))
build-tests: build-tests:
runs-on: ${{matrix.os}} runs-on: ${{matrix.os}}
strategy: strategy:
@@ -39,7 +71,7 @@ jobs:
- name: Install dependencies (MacOS) - name: Install dependencies (MacOS)
if: matrix.os == 'macos-latest' || matrix.os == 'macos-13' || matrix.os == 'macos-14' if: matrix.os == 'macos-latest' || matrix.os == 'macos-13' || matrix.os == 'macos-14'
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install boost hidapi openssl zmq libpgm miniupnpc expat libunwind-headers protobuf run: ${{env.BREW_INSTALL_MAC}}
- name: Install RabbitMQ iff WITH_RMQ (MacOS) - name: Install RabbitMQ iff WITH_RMQ (MacOS)
if: matrix.rmq == 'WITH_RMQ=ON' && (matrix.os == 'macos-latest' || matrix.os == 'macos-13' || matrix.os == 'macos-14') if: matrix.rmq == 'WITH_RMQ=ON' && (matrix.os == 'macos-latest' || matrix.os == 'macos-13' || matrix.os == 'macos-14')
run: HOMEBREW_NO_AUTO_UPDATE=1 brew install rabbitmq-c run: HOMEBREW_NO_AUTO_UPDATE=1 brew install rabbitmq-c

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "external/monero"]
path = external/monero
url = https://github.com/monero-project/monero.git

View File

@@ -41,6 +41,14 @@ if (WITH_RMQ)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMLWS_RMQ_ENABLED") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMLWS_RMQ_ENABLED")
endif() endif()
if(STATIC)
if(MSVC)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll.a .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
endif()
set(MONERO_LIBRARIES set(MONERO_LIBRARIES
daemon_messages daemon_messages
serialization serialization
@@ -64,12 +72,13 @@ set(MONERO_LIBRARIES
easylogging easylogging
version version
wallet-crypto wallet-crypto
unbound
) )
set(MONERO_OPTIONAL unbound wallet-crypto) set(MONERO_OPTIONAL wallet-crypto)
set(MONERO_SEARCH_PATHS if (MONERO_BUILD_DIR)
set(MONERO_SEARCH_PATHS
"/contrib/epee/src" "/contrib/epee/src"
"/external/db_drivers/liblmdb" "/external/db_drivers/liblmdb"
"/external/easylogging++" "/external/easylogging++"
@@ -80,34 +89,22 @@ set(MONERO_SEARCH_PATHS
"/src/lmdb" "/src/lmdb"
"/src/ringct" "/src/ringct"
"/src/rpc" "/src/rpc"
) )
# #
# Pull some information from monero build # Pull some information from monero build
# #
# Needed due to "bug" in monero CMake - the `project` function is used twice! # Needed due to "bug" in monero CMake - the `project` function is used twice!
if (NOT MONERO_SOURCE_DIR) if (NOT MONERO_SOURCE_DIR)
message(FATAL_ERROR "The argument -DMONERO_SOURCE_DIR must specify a location of a monero source tree") message(FATAL_ERROR "The argument -DMONERO_SOURCE_DIR must specify a location of a monero source tree")
endif()
if (NOT MONERO_BUILD_DIR)
message(FATAL_ERROR "The argument -DMONERO_BUILD_DIR must specify a location of an existing monero build")
endif()
if(STATIC)
if(MSVC)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll.a .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif() endif()
endif()
# monero `master` and `release-v0.18` branches use different LIBSODIUM # monero `master` and `release-v0.18` branches use different LIBSODIUM
# find routines. So the upstream cmake names differ # find routines. So the upstream cmake names differ
load_cache(${MONERO_BUILD_DIR} READ_WITH_PREFIX monero_ load_cache(${MONERO_BUILD_DIR} READ_WITH_PREFIX monero_
Boost_THREAD_LIBRARY_RELEASE Boost_THREAD_LIBRARY_RELEASE
CMAKE_CXX_COMPILER CMAKE_CXX_COMPILER
EXTRA_LIBRARIES EXTRA_LIBRARIES
@@ -129,23 +126,65 @@ load_cache(${MONERO_BUILD_DIR} READ_WITH_PREFIX monero_
NORM_LIBRARY NORM_LIBRARY
GSSAPI_LIBRARY GSSAPI_LIBRARY
PROTOLIB_LIBRARY PROTOLIB_LIBRARY
) )
if (NOT (monero_monero_SOURCE_DIR MATCHES "${MONERO_SOURCE_DIR}(/src/cryptonote_protocol)")) if (NOT (monero_monero_SOURCE_DIR MATCHES "${MONERO_SOURCE_DIR}(/src/cryptonote_protocol)"))
message(FATAL_ERROR "Invalid Monero source dir - does not appear to match source used for build directory") message(FATAL_ERROR "Invalid Monero source dir - does not appear to match source used for build directory")
endif() endif()
if (NOT (CMAKE_CXX_COMPILER STREQUAL monero_CMAKE_CXX_COMPILER)) if (NOT (CMAKE_CXX_COMPILER STREQUAL monero_CMAKE_CXX_COMPILER))
message(FATAL_ERROR "Compiler for monero build differs from this project") message(FATAL_ERROR "Compiler for monero build differs from this project")
endif() endif()
if ("${monero_UNBOUND_LIBRARIES}" STREQUAL "UNBOUND_LIBRARIES-NOTFOUND") if ("${monero_UNBOUND_LIBRARIES}" STREQUAL "UNBOUND_LIBRARIES-NOTFOUND")
unset(monero_UNBOUND_LIBRARIES) unset(monero_UNBOUND_LIBRARIES)
endif() endif()
if ("${monero_HIDAPI_LIBRARY}" STREQUAL "HIDAPI_LIBRARY-NOTFOUND") if ("${monero_HIDAPI_LIBRARY}" STREQUAL "HIDAPI_LIBRARY-NOTFOUND")
unset(monero_HIDAPI_INCLUDE_DIR) unset(monero_HIDAPI_INCLUDE_DIR)
unset(monero_HIDAPI_LIBRARY) unset(monero_HIDAPI_LIBRARY)
endif()
foreach (LIB ${MONERO_LIBRARIES})
find_library(LIB_PATH NAMES "${LIB}" PATHS ${MONERO_BUILD_DIR} PATH_SUFFIXES "/src/${LIB}" "external/${LIB}" ${MONERO_SEARCH_PATHS} NO_DEFAULT_PATH)
list(FIND MONERO_OPTIONAL "${LIB}" LIB_OPTIONAL)
if (NOT LIB_PATH)
if (LIB_OPTIONAL EQUAL -1)
message(FATAL_ERROR "Unable to find required Monero library ${LIB}")
endif()
else ()
set(LIB_NAME "monero::${LIB}")
add_library(${LIB_NAME} STATIC IMPORTED)
set_target_properties(${LIB_NAME} PROPERTIES IMPORTED_LOCATION ${LIB_PATH})
list(APPEND IMPORTED_MONERO_LIBRARIES "${LIB_NAME}")
endif()
unset(LIB_PATH CACHE)
endforeach()
set(LMDB_INCLUDE "${monero_LMDB_INCLUDE}")
set(LMDB_LIB_PATH "monero::lmdb")
else () # NOT MONERO_BUILD_DIR
if (NOT MONERO_SOURCE_DIR)
set (MONERO_SOURCE_DIR "${monero-lws_SOURCE_DIR}/external/monero")
endif ()
include(FetchContent)
FetchContent_Declare(monero SOURCE_DIR "${MONERO_SOURCE_DIR}")
if (NOT monero_POPULATED)
FetchContent_MakeAvailable(monero)
endif ()
set(MONERO_BUILD_DIR "${monero_BINARY_DIR}")
set(IMPORTED_MONERO_LIBRARIES "${MONERO_LIBRARIES}")
set(monero_Boost_THREAD_LIBRARY_RELEASE "${Boost_THREAD_LIBRARY_RELEASE}")
set(monero_pkgcfg_lib_libzmq_zmq "${pkgcfg_lib_libzmq_zmq}")
if (SODIUM_LIBRARY)
set(monero_SODIUM_LIBRARY "${SODIUM_LIBRARY}")
else()
set(monero_SODIUM_LIBRARY "${monero_sodium_LIBRARY_RELEASE}")
endif()
endif() endif()
# #
@@ -177,8 +216,6 @@ else()
set(RMQ_LIBRARY "") set(RMQ_LIBRARY "")
endif() endif()
set(LMDB_INCLUDE "${monero_LMDB_INCLUDE}")
set(LMDB_LIB_PATH "monero::lmdb")
set(ZMQ_INCLUDE_PATH "${libzmq_INCLUDE_DIRS}") set(ZMQ_INCLUDE_PATH "${libzmq_INCLUDE_DIRS}")
set(ZMQ_LIB "${monero_pkgcfg_lib_libzmq_zmq}") set(ZMQ_LIB "${monero_pkgcfg_lib_libzmq_zmq}")
if (monero_SODIUM_LIBRARY) if (monero_SODIUM_LIBRARY)
@@ -212,23 +249,6 @@ if(STATIC AND NOT IOS)
endif() endif()
endif() endif()
foreach (LIB ${MONERO_LIBRARIES})
find_library(LIB_PATH NAMES "${LIB}" PATHS ${MONERO_BUILD_DIR} PATH_SUFFIXES "/src/${LIB}" "external/${LIB}" ${MONERO_SEARCH_PATHS} NO_DEFAULT_PATH)
list(FIND MONERO_OPTIONAL "${LIB}" LIB_OPTIONAL)
if (NOT LIB_PATH)
if (LIB_OPTIONAL EQUAL -1)
message(FATAL_ERROR "Unable to find required Monero library ${LIB}")
endif()
else ()
set(LIB_NAME "monero::${LIB}")
add_library(${LIB_NAME} STATIC IMPORTED)
set_target_properties(${LIB_NAME} PROPERTIES IMPORTED_LOCATION ${LIB_PATH})
list(APPEND IMPORTED_MONERO_LIBRARIES "${LIB_NAME}")
endif()
unset(LIB_PATH CACHE)
endforeach()
if(APPLE) if(APPLE)
find_library(IOKIT_LIBRARY IOKit) find_library(IOKIT_LIBRARY IOKit)
list(APPEND IMPORTED_MONERO_LIBRARIES ${IOKIT_LIBRARY}) list(APPEND IMPORTED_MONERO_LIBRARIES ${IOKIT_LIBRARY})

1
external/monero vendored Submodule

Submodule external/monero added at c572e1ad00