feat: windows support

feat: ci caching for faster builds
This commit is contained in:
Czarek Nakamoto
2024-03-15 22:13:28 +01:00
parent 0a564488a5
commit 707b5b07ee
5 changed files with 91 additions and 26 deletions

View File

@@ -18,7 +18,22 @@ steps:
- cd monero && git submodule update --init --force && cd ..
- ./apply_patches.sh
- cd monero/contrib/depends
- for i in sources built; do cp "/root/.cache/$i" . -r || true; done
- make download
volumes:
- /opt/cache/monero_c/dotcache:/root/.cache
- name: x86_64-w64-mingw32
image: git.mrcyjanek.net/mrcyjanek/debian:buster
commands:
- apt update
- apt install -y gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 gperf libtinfo5
- ./build_single.sh x86_64-w64-mingw32 -j$(nproc)
- name: i686-w64-mingw32
image: git.mrcyjanek.net/mrcyjanek/debian:buster
commands:
- apt update
- apt install -y gcc-mingw-w64-i686 g++-mingw-w64-i686 gperf libtinfo5
- ./build_single.sh i686-w64-mingw32 -j$(nproc)
- name: x86_64-linux-gnu
image: git.mrcyjanek.net/mrcyjanek/debian:buster
commands:
@@ -55,6 +70,13 @@ steps:
- apt update
- apt install -y libtinfo5 gperf
- ./build_single.sh arm-linux-androideabi -j$(nproc)
- name: cache depends
image: git.mrcyjanek.net/mrcyjanek/debian:buster
commands:
- cd monero/contrib/depends
- for i in sources built; do cp "$i" "/root/.cache/" -r || true; done
volumes:
- /opt/cache/monero_c/dotcache:/root/.cache
- name: upload artifact
image: git.mrcyjanek.net/mrcyjanek/debian:bookworm
commands:

View File

@@ -8,4 +8,4 @@
To contribute you can visit git.mrcyjanek.net/mrcyjanek/monero_c and open a PR, alternatively use any other code mirror or send patches directly.
**IMPORTANT** I don't have time to write better README, please check `build_single.sh` for build instructions, in general it comes down to
**IMPORTANT** I don't have time to write better README, please check `build_single.sh` for build instructions, in general it comes down to running the script.

View File

@@ -21,36 +21,36 @@ CC=""
CXX=""
case "$HOST_ABI" in
"x86_64-linux-gnu")
export CC="x86_64-linux-gnu-gcc"
export CXX="x86_64-linux-gnu-g++"
export CC="${HOST_ABI}-gcc"
export CXX="${HOST_ABI}-g++"
;;
"i686-linux-gnu")
export CC="i686-linux-gnu-gcc"
export CXX="i686-linux-gnu-g++"
export CC="${HOST_ABI}-gcc"
export CXX="${HOST_ABI}-g++"
;;
"aarch64-linux-gnu")
export CC="aarch64-linux-gnu-gcc"
export CXX="aarch64-linux-gnu-g++"
export CC="${HOST_ABI}-gcc"
export CXX="${HOST_ABI}-g++"
;;
"x86_64-linux-android")
export PATH="$WDIR/monero/contrib/depends/x86_64-linux-android/native/bin/:$PATH"
export CC=x86_64-linux-android-clang
export CXX=x86_64-linux-android-clang++
export PATH="$WDIR/monero/contrib/depends/${HOST_ABI}/native/bin/:$PATH"
export CC=${HOST_ABI}-clang
export CXX=${HOST_ABI}-clang++
;;
"i686-linux-android")
export PATH="$WDIR/monero/contrib/depends/i686-linux-android/native/bin/:$PATH"
export CC=i686-linux-android-clang
export CXX=i686-linux-android-clang++
export PATH="$WDIR/monero/contrib/depends/${HOST_ABI}/native/bin/:$PATH"
export CC=${HOST_ABI}-clang
export CXX=${HOST_ABI}-clang++
;;
"aarch64-linux-android")
export PATH="$WDIR/monero/contrib/depends/aarch64-linux-android/native/bin/:$PATH"
export CC=aarch64-linux-android-clang
export CXX=aarch64-linux-android-clang++
export PATH="$WDIR/monero/contrib/depends/${HOST_ABI}/native/bin/:$PATH"
export CC=${HOST_ABI}-clang
export CXX=${HOST_ABI}-clang++
;;
"arm-linux-androideabi")
export PATH="$WDIR/monero/contrib/depends/arm-linux-androideabi/native/bin/:$PATH"
export CC=arm-linux-androideabi-clang
export CXX=arm-linux-androideabi-clang++
export PATH="$WDIR/monero/contrib/depends/${HOST_ABI}/native/bin/:$PATH"
export CC=${HOST_ABI}-clang
export CXX=${HOST_ABI}-clang++
;;
"i686-w64-mingw32")
update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix
@@ -85,7 +85,7 @@ fi
pushd monero/contrib/depends
make HOST="$HOST_ABI" "$NPROC"
CC=gcc CXX=g++ make HOST="$HOST_ABI" "$NPROC"
popd
rm -rf monero/build/${HOST_ABI} 2>/dev/null || true
@@ -140,6 +140,11 @@ popd
mkdir release 2>/dev/null || true
pushd release
xz -e ../libbridge/build/${HOST_ABI}/libwallet2_api_c.so
mv ../libbridge/build/${HOST_ABI}/libwallet2_api_c.so.xz ${HOST_ABI}_libwallet2_api_c.so.xz
APPENDIX=so
if [[ "${HOST_ABI}" == "x86_64-w64-mingw32" || "${HOST_ABI}" == "i686-w64-mingw32" ]];
then
APPENDIX=dll
fi
xz -e ../libbridge/build/${HOST_ABI}/libwallet2_api_c.${APPENDIX}
mv ../libbridge/build/${HOST_ABI}/libwallet2_api_c.${APPENDIX}.xz ${HOST_ABI}_libwallet2_api_c.${APPENDIX}.xz
popd

View File

@@ -37,9 +37,10 @@ set_target_properties(ssl PROPERTIES IMPORTED_LOCATION
############
if(${HOST_ABI} STREQUAL "x86_64-linux-android" OR ${HOST_ABI} STREQUAL "aarch64-linux-android" OR ${HOST_ABI} STREQUAL "arm-linux-androideabi" OR ${HOST_ABI} STREQUAL "i686-linux-android")
set(CMAKE_LINKER ${HOST_ABI}-ld)
set(BOOST_WTF "-mt-s")
set(BOOST_WTF_PART "")
elseif(${HOST_ABI} STREQUAL "x86_64-w64-mingw32")
elseif(${HOST_ABI} STREQUAL "x86_64-w64-mingw32" OR ${HOST_ABI} STREQUAL "i686-w64-mingw32")
set(BOOST_WTF "-mt-s")
set(BOOST_WTF_PART "_win32")
else()
@@ -48,15 +49,30 @@ else()
endif()
if(${HOST_ABI} STREQUAL "x86_64-w64-mingw32")
set(CMAKE_SYSTEM_NAME "Windows")
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_LINKER "x86_64-w64-mingw32-ld")
set(TARGET "x86_64-w64-mingw32")
set(TARGET "x86_64-w64-mingw32")
elseif(${HOST_ABI} STREQUAL "i686-w64-mingw32")
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_LINKER "i686-w64-mingw32-ld")
set(TARGET "i686-w64-mingw32")
endif()
add_library(boost_chrono STATIC IMPORTED)
set_target_properties(boost_chrono PROPERTIES IMPORTED_LOCATION
${EXTERNAL_LIBS_DIR}/lib/libboost_chrono${BOOST_WTF}.a)
# win extra
add_library(boost_locale STATIC IMPORTED)
set_target_properties(boost_locale PROPERTIES IMPORTED_LOCATION
${EXTERNAL_LIBS_DIR}/lib/libboost_locale${BOOST_WTF}.a)
# win extra
add_library(iconv STATIC IMPORTED)
set_target_properties(iconv PROPERTIES IMPORTED_LOCATION
${EXTERNAL_LIBS_DIR}/lib/libiconv.a)
add_library(boost_date_time STATIC IMPORTED)
set_target_properties(boost_date_time PROPERTIES IMPORTED_LOCATION
${EXTERNAL_LIBS_DIR}/lib/libboost_date_time${BOOST_WTF}.a)
@@ -101,6 +117,13 @@ add_library(polyseed-wrapper STATIC IMPORTED)
set_target_properties(polyseed-wrapper PROPERTIES IMPORTED_LOCATION
${MONERO_DIR}/build/${HOST_ABI}/src/polyseed/libpolyseed_wrapper.a)
if(${HOST_ABI} STREQUAL "x86_64-w64-mingw32" OR ${HOST_ABI} STREQUAL "i686-w64-mingw32")
set(EXTRA_LIBS_POLYSEED polyseed-win)
add_library(polyseed-win STATIC IMPORTED)
set_target_properties(polyseed-win PROPERTIES IMPORTED_LOCATION
${MONERO_DIR}/build/${HOST_ABI}/external/polyseed/libpolyseed.dll.a)
endif()
#############
# Utf8proc
#############
@@ -218,6 +241,10 @@ add_library(cryptonote_format_utils_basic STATIC IMPORTED)
set_target_properties(cryptonote_format_utils_basic PROPERTIES IMPORTED_LOCATION
${MONERO_DIR}/build/${HOST_ABI}/src/cryptonote_basic/libcryptonote_format_utils_basic.a)
add_library(hidapi STATIC IMPORTED)
set_target_properties(hidapi PROPERTIES IMPORTED_LOCATION
${EXTERNAL_LIBS_DIR}/lib/libhidapi.a)
#############
# System
#############
@@ -236,6 +263,13 @@ endif()
# target_compile_options(wallet2_api_c PRIVATE -static-libstdc++)
if(${HOST_ABI} STREQUAL "x86_64-w64-mingw32" OR ${HOST_ABI} STREQUAL "i686-w64-mingw32")
set_target_properties(wallet2_api_c PROPERTIES SUFFIX ".dll")
set(EXTRA_LIBS_WINDOWS wsock32 ws2_32 iconv iphlpapi crypt32 hidapi)
endif()
target_link_libraries( wallet2_api_c
wallet_api
@@ -266,6 +300,7 @@ target_link_libraries( wallet2_api_c
${EXTRA_LIBS}
boost_chrono
boost_locale
boost_date_time
boost_filesystem
boost_program_options
@@ -277,10 +312,13 @@ target_link_libraries( wallet2_api_c
polyseed
polyseed-wrapper
${EXTRA_LIBS_POLYSEED}
utf8proc
ssl
crypto
sodium
${EXTRA_LIBS_WINDOWS}
)

View File

@@ -80,7 +80,7 @@ index 000000000..47a532907
+endef
+
+define $(package)_config_cmds
+ cmake -DCMAKE_INSTALL_PREFIX=$(host_prefix) -DCMAKE_C_COMPILER=${CC} .
+ cmake -DCMAKE_INSTALL_PREFIX=$(host_prefix) -DCMAKE_C_COMPILER=$($(package)_cc) .
+endef
+
+define $(package)_build_cmds