1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-13 11:42:18 +00:00
ton/tdutils/CMakeLists.txt
neodiX42 5a47495d87
Add cross-platform Linux and macOS binaries (statically compiled with NixPkgs) + wasm artifacts (#621)
* fix build

* nix flake

* nix package

* static musl build env

* make all builds in static env

* GH Actions nightly and static workflows

* deb package

* cmake install {adnl-proxy,blockchain-explorer,create-state,http-proxy,rldp-http-proxy,storage-cli}

* nix flake: add static glibc build variant

* GH Actions: deb-nightly-{musl,glibc_static}, tests-rolling jobs

* rpm package

* build blockchain-explorer

* GH Actions: deb_rpm-nightly: ubuntu-{latest=>22.04}

* crypto/pow-miner: skip install

* ghactions: tests-rolling: show tests run, progress

* ghactions: deb_rpm-nightly: add manual trigger [skip ci]

* nix flake refactor

* find_package=>pkg-config(zlib)

FindZLIB.cmake can't find static zlib prior to CMake 3.24, so use
pkg-config.

* nix old glibc build

* nix aarch64 support

* packages: Populate APT and RPM repos at ton-repo

- {deb,rpm}.sh: Separate build and install dirs
- rpm.sh: Conditionally include lib/
- Accomodate local CI runs w/act

* [skip ci] README packages

* fix aarch64 build -Wnoerror=address

* [skip ci] rpm set releasever

* [skip ci] document local packages upload

* m1 build: gate cpu=apple-m1 by clang version

* packages: Ship musl binaries + old glibc dylibs

* packages: macos build

* nix: bump nixpkgs

* fix windows CI build

* [skip ci] nix: static aarch64 builds

* packages: deb,rpm multiarch

* ghactions: aarch64 musl deb,rpm build

* [skip ci] deb build: deref source links, -x

* [skip ci] nix darwin static build

* [skip ci] nix common hostPkgs

* [skip ci] brew: move formula over to homebrew-ton-repo

* [skip ci] nix fix aarch64-linux build

* [skip ci] ghactions: nix use GITHUB_TOKEN

* [skip ci] Move from ton-repo to gh releases

* [skip ci] ghactions aarch64-darwin self-hosted runner

* [skip ci] ghactions deb,rpm nightly 10h timeout

* [skip ci] fix brew install

fixes
Errno::EACCES: Permission denied @ dir_s_mkdir - /private/tmp/ton-XXX/bin/.brew_home

* [skip ci] ghactions deb,rpm nightly: don't upload ton-packages as we gh release them later

* [skip ci] README: brew instructions

* [skip ci] nightly linux binaries release

* [skip ci] packages: ship macos dylib

* [skip ci] ghactions: Run Windows build nightly, upload to gh releases

* nix: remove defaultPackage, switch to different oldglibc build method

We used to rebuild nixpkgs-stable with old glibc, which broke on aarch64
due to its particular bootstrap toolchain. This just takes nixos 19.09's
version of GCC but new dependencies, sidestepping the issue.

* fix rpm release, add aur release

* fix local (act) ci run

* ghactions: linux-nightly: Print out SSH public keys

* ghactions: bump cachix actions

* nix: default devShell

* [skip ci] rpm,aur: Ship lib

* [skip ci] packages: windows: Remove CMake files from out

* [skip ci] packages: Import chocolatey package

* fixup! fix rpm release, add aur release

* [skip ci] packages: aarch64-linux: build dylib as well

* [skip ci] ghactions: run on self-hosted

* [skip ci] ghactions: windows-nightly: Bump nodejs actions

* [skip ci] nix: Only add Linux packaging tools on Linux

* [skip ci] doc: document direct download binaries in README

* fix tonlib android jni ci

* fixup! fix tonlib android jni ci

* [skip ci] ghactions: Update GH release dates

Errata: doesn't update tags.

* [skip ci] ghactions: Fix racy brew gh release by splitting arch

* initiali commit - binaries only

* fixes

* fixes

* fixes

* fixes

* remove packages dir for now

* add storage-daemon storage-daemon-cli

* fix emulator

* try macos aarch64

* try macos aarch64

* try macos aarch64

* try macos aarch64

* try macos aarch64

* try macos aarch64

* try macos aarch64

* try macos aarch64

* try macos aarch64

* try macos aarch64

* try macos aarch64 sh

* try macos aarch64 sh

* try macos aarch64 bash

* try macos aarch64 bash

* try macos aarch64 bash

* try macos aarch64 bash

* try macos aarch64 bash

* try macos aarch64 bash

* try macos aarch64 bash

* fix funcfiftlib compilation with emscripten

* fix funcfiftlib compilation with emscripten

* add github action to compile TON with emscripten

* add github action to compile TON with emscripten

* add github action to compile TON with emscripten

* add github action to compile TON with emscripten

* add github action to compile TON with emscripten

* add github action to compile TON with emscripten

* try macos aarch64

* fix funcfiftlib compilation with emscripten

* fix funcfiftlib compilation with emscripten

* add github action to compile TON with emscripten

* disable aarch64 github actions for now

* disable aarch64 github actions for now

* trigger all GH actions

* trigger all GH actions 2

* trigger all GH actions 3

* trigger all GH actions 4

* trigger all GH actions 5

* put back rldp-http-proxy to win build

* put back rldp-http-proxy to win build

* dont use pkgConfig for zlib

* fix zlib_library

* use BUILD_SHARED_LIBS flag for static compilation

* test 1

* test 2

* add wasm binaries to release.
test 3

* add simple binaries' execution test

* build emulator-emscripten

* build and add into artifacts wasm tlbc and emulator-emscripten

* build and add into artifacts wasm tlbc and emulator-emscripten, 2

* build and add into artifacts wasm tlbc and emulator-emscripten, 3

* build and add into artifacts wasm tlbc and emulator-emscripten, 4

* build emulator-emscripten with static libs

* minor nix mac aarch64 fix

* add single artifacts to release

* bypass $repo to Dockerfile

* add wasm artifacts to release

* add wasm artifacts to release

* add wasm artifacts to release

* add wasm artifacts to release

* add more artifacts to release; remove compilation against Ubuntu 18.04.

* retrieve GITHUB_TOKEN for ton-blockchain/ton

* remove binary check for arm64

---------

Co-authored-by: tonthemoon <tonthemoon@mailbox.org>
2023-02-27 12:32:41 +03:00

360 lines
9.5 KiB
CMake

cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
option(TDUTILS_MIME_TYPE "Generate mime types conversion (gperf is required)" ON)
if (WIN32)
if (WINGETOPT_FOUND)
set(TD_HAVE_GETOPT 1)
endif()
else()
set(TD_HAVE_GETOPT 1)
endif()
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
find_package(PkgConfig REQUIRED)
if (NOT ZLIB_FOUND)
pkg_check_modules(ZLIB zlib)
endif()
if (ZLIB_FOUND)
set(TD_HAVE_ZLIB 1)
message(STATUS "Found ZLIB: ${ZLIB_INCLUDE_DIR} ${ZLIB_LIBRARIES}")
# OpenSSL internally depends on zlib
if (NOT OPENSSL_FOUND)
find_package(OpenSSL)
endif()
if (OPENSSL_FOUND)
set(TD_HAVE_OPENSSL 1)
endif()
endif()
if (CRC32C_FOUND)
set(TD_HAVE_CRC32C 1)
endif()
if (ABSL_FOUND)
set(TD_HAVE_ABSL 1)
endif()
configure_file(td/utils/config.h.in td/utils/config.h @ONLY)
add_subdirectory(generate)
# TDUTILS
set_source_files_properties(${TDMIME_AUTO} PROPERTIES GENERATED TRUE)
if (CLANG OR GCC)
set_property(SOURCE ${TDMIME_AUTO} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-conversion")
elseif (MSVC)
set_property(SOURCE ${TDMIME_AUTO} APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4267")
endif()
if (CLANG)
set_property(SOURCE ${TDMIME_AUTO} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-deprecated-register")
endif()
set(TDUTILS_SOURCE
td/utils/port/Clocks.cpp
td/utils/port/FileFd.cpp
td/utils/port/IPAddress.cpp
td/utils/port/MemoryMapping.cpp
td/utils/port/path.cpp
td/utils/port/PollFlags.cpp
td/utils/port/rlimit.cpp
td/utils/port/ServerSocketFd.cpp
td/utils/port/signals.cpp
td/utils/port/sleep.cpp
td/utils/port/SocketFd.cpp
td/utils/port/stacktrace.cpp
td/utils/port/Stat.cpp
td/utils/port/StdStreams.cpp
td/utils/port/thread_local.cpp
td/utils/port/user.cpp
td/utils/port/UdpSocketFd.cpp
td/utils/port/uname.cpp
td/utils/port/user.cpp
td/utils/port/wstring_convert.cpp
td/utils/port/detail/Epoll.cpp
td/utils/port/detail/EventFdBsd.cpp
td/utils/port/detail/EventFdLinux.cpp
td/utils/port/detail/EventFdWindows.cpp
td/utils/port/detail/Iocp.cpp
td/utils/port/detail/KQueue.cpp
td/utils/port/detail/NativeFd.cpp
td/utils/port/detail/Poll.cpp
td/utils/port/detail/Select.cpp
td/utils/port/detail/ThreadIdGuard.cpp
td/utils/port/detail/ThreadPthread.cpp
td/utils/port/detail/WineventPoll.cpp
${TDMIME_AUTO}
td/utils/base64.cpp
td/utils/BigNum.cpp
td/utils/buffer.cpp
td/utils/BufferedUdp.cpp
td/utils/check.cpp
td/utils/crypto.cpp
td/utils/FileLog.cpp
td/utils/filesystem.cpp
td/utils/find_boundary.cpp
td/utils/Gzip.cpp
td/utils/GzipByteFlow.cpp
td/utils/Hints.cpp
td/utils/HttpUrl.cpp
td/utils/JsonBuilder.cpp
td/utils/logging.cpp
td/utils/misc.cpp
td/utils/MpmcQueue.cpp
td/utils/OptionParser.cpp
td/utils/PathView.cpp
td/utils/Random.cpp
td/utils/SharedSlice.cpp
td/utils/Slice.cpp
td/utils/StackAllocator.cpp
td/utils/Status.cpp
td/utils/StringBuilder.cpp
td/utils/Time.cpp
td/utils/Timer.cpp
td/utils/TsFileLog.cpp
td/utils/tests.cpp
td/utils/tl_parsers.cpp
td/utils/translit.cpp
td/utils/TsFileLog.cpp
td/utils/unicode.cpp
td/utils/utf8.cpp
td/utils/port/Clocks.h
td/utils/port/config.h
td/utils/port/CxCli.h
td/utils/port/EventFd.h
td/utils/port/EventFdBase.h
td/utils/port/FileFd.h
td/utils/port/IPAddress.h
td/utils/port/IoSlice.h
td/utils/port/MemoryMapping.h
td/utils/port/path.h
td/utils/port/platform.h
td/utils/port/Poll.h
td/utils/port/PollBase.h
td/utils/port/PollFlags.h
td/utils/port/rlimit.h
td/utils/port/RwMutex.h
td/utils/port/ServerSocketFd.h
td/utils/port/signals.h
td/utils/port/sleep.h
td/utils/port/SocketFd.h
td/utils/port/stacktrace.h
td/utils/port/Stat.h
td/utils/port/StdStreams.h
td/utils/port/thread.h
td/utils/port/thread_local.h
td/utils/port/user.h
td/utils/port/UdpSocketFd.h
td/utils/port/uname.h
td/utils/port/user.h
td/utils/port/wstring_convert.h
td/utils/port/detail/Epoll.h
td/utils/port/detail/EventFdBsd.h
td/utils/port/detail/EventFdLinux.h
td/utils/port/detail/EventFdWindows.h
td/utils/port/detail/Iocp.h
td/utils/port/detail/KQueue.h
td/utils/port/detail/NativeFd.h
td/utils/port/detail/Poll.h
td/utils/port/detail/PollableFd.h
td/utils/port/detail/Select.h
td/utils/port/detail/skip_eintr.h
td/utils/port/detail/ThreadIdGuard.h
td/utils/port/detail/ThreadPthread.h
td/utils/port/detail/ThreadStl.h
td/utils/port/detail/WineventPoll.h
td/utils/AesCtrByteFlow.h
td/utils/as.h
td/utils/base64.h
td/utils/benchmark.h
td/utils/BigNum.h
td/utils/bits.h
td/utils/buffer.h
td/utils/BufferedFd.h
td/utils/BufferedReader.h
td/utils/BufferedUdp.h
td/utils/ByteFlow.h
td/utils/CancellationToken.h
td/utils/ChangesProcessor.h
td/utils/check.h
td/utils/Closure.h
td/utils/common.h
td/utils/ConcurrentHashTable.h
td/utils/Container.h
td/utils/Context.h
td/utils/crypto.h
td/utils/DecTree.h
td/utils/Destructor.h
td/utils/Enumerator.h
td/utils/EpochBasedMemoryReclamation.h
td/utils/FileLog.h
td/utils/filesystem.h
td/utils/find_boundary.h
td/utils/FloodControlFast.h
td/utils/FloodControlStrict.h
td/utils/format.h
td/utils/Gzip.h
td/utils/GzipByteFlow.h
td/utils/Hash.h
td/utils/HashMap.h
td/utils/HashSet.h
td/utils/HazardPointers.h
td/utils/Heap.h
td/utils/Hints.h
td/utils/HttpUrl.h
td/utils/int_types.h
td/utils/invoke.h
td/utils/JsonBuilder.h
td/utils/List.h
td/utils/logging.h
td/utils/MemoryLog.h
td/utils/misc.h
td/utils/MovableValue.h
td/utils/MpmcQueue.h
td/utils/MpmcWaiter.h
td/utils/MpscPollableQueue.h
td/utils/MpscLinkQueue.h
td/utils/Named.h
td/utils/ObjectPool.h
td/utils/Observer.h
td/utils/optional.h
td/utils/OptionParser.h
td/utils/OrderedEventsProcessor.h
td/utils/overloaded.h
td/utils/Parser.h
td/utils/PathView.h
td/utils/queue.h
td/utils/Random.h
td/utils/ScopeGuard.h
td/utils/SharedObjectPool.h
td/utils/SharedSlice.h
td/utils/Slice-decl.h
td/utils/Slice.h
td/utils/Span.h
td/utils/SpinLock.h
td/utils/StackAllocator.h
td/utils/Status.h
td/utils/StealingQueue.h
td/utils/Storer.h
td/utils/StorerBase.h
td/utils/StringBuilder.h
td/utils/tests.h
td/utils/ThreadLocalStorage.h
td/utils/ThreadSafeCounter.h
td/utils/Time.h
td/utils/date.h
td/utils/TimedStat.h
td/utils/Timer.h
td/utils/TsFileLog.h
td/utils/tl_helpers.h
td/utils/tl_parsers.h
td/utils/tl_storers.h
td/utils/translit.h
td/utils/TsFileLog.h
td/utils/TsList.h
td/utils/type_traits.h
td/utils/UInt.h
td/utils/uint128.h
td/utils/unicode.h
td/utils/unique_ptr.h
td/utils/utf8.h
td/utils/Variant.h
td/utils/VectorQueue.h
)
if (TDUTILS_MIME_TYPE)
set(TDUTILS_SOURCE
${TDUTILS_SOURCE}
td/utils/MimeType.cpp
td/utils/MimeType.h
)
endif()
set(TDUTILS_TEST_SOURCE
${CMAKE_CURRENT_SOURCE_DIR}/test/buffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/ConcurrentHashMap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/crypto.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/Enumerator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/filesystem.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/gzip.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/HazardPointers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/heap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/json.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/List.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/log.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/misc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/MpmcQueue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/MpmcWaiter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/MpscLinkQueue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/OptionParser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/OrderedEventsProcessor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/port.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/pq.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/SharedObjectPool.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/SharedSlice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/StealingQueue.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/variant.cpp
PARENT_SCOPE
)
#RULES
#LIBRARIES
add_library(tdutils STATIC ${TDUTILS_SOURCE})
if (WIN32)
# find_library(WS2_32_LIBRARY ws2_32)
# find_library(MSWSOCK_LIBRARY Mswsock)
# target_link_libraries(tdutils PRIVATE ${WS2_32_LIBRARY} ${MSWSOCK_LIBRARY})
target_link_libraries(tdutils PRIVATE ws2_32 Mswsock Normaliz psapi)
endif()
if (NOT CMAKE_CROSSCOMPILING AND TDUTILS_MIME_TYPE)
add_dependencies(tdutils tdmime_auto)
endif()
if (DEFINED CMAKE_THREAD_LIBS_INIT)
target_link_libraries(tdutils PUBLIC ${CMAKE_THREAD_LIBS_INIT})
endif()
target_include_directories(tdutils PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
if (OPENSSL_FOUND)
target_link_libraries(tdutils PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES})
target_include_directories(tdutils SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
endif()
if (ZLIB_FOUND)
target_link_libraries(tdutils PRIVATE ${ZLIB_LIBRARIES})
target_include_directories(tdutils SYSTEM PRIVATE ${ZLIB_INCLUDE_DIR})
endif()
if (CRC32C_FOUND)
target_link_libraries(tdutils PRIVATE crc32c)
endif()
if (ABSL_FOUND)
target_link_libraries_system(tdutils absl::flat_hash_map absl::flat_hash_set absl::hash)
endif()
if (WIN32 AND WINGETOPT_FOUND)
target_link_libraries(tdutils PRIVATE wingetopt)
endif()
if (ANDROID)
target_link_libraries(tdutils PRIVATE log)
endif()
if (CMAKE_HOST_SYSTEM_NAME MATCHES "NetBSD")
target_link_libraries(tdutils PUBLIC /usr/pkg/gcc5/i486--netbsdelf/lib/libatomic.so)
endif()
install(TARGETS tdutils EXPORT TdTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)