Skip to content

Commit 4882955

Browse files
committed
ci: Add CMake CI for macOS
Other changes: * Prevent known warnings from being treated as errors on macOS * Fix berkdb configure on macOS * Fix GUI build on macOS
1 parent d0aa0ae commit 4882955

File tree

10 files changed

+153
-17
lines changed

10 files changed

+153
-17
lines changed

.github/workflows/cmake-ci.yml

Lines changed: 101 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ jobs:
99
runs-on: ubuntu-latest
1010
env:
1111
CCACHE_DIR: ${{github.workspace}}/ccache
12-
CCACHE_MAXSIZE: 100M
12+
CCACHE_MAXSIZE: 400M
13+
CCACHE_COMPILERCHECK: content
1314
strategy:
1415
matrix:
1516
tag:
@@ -22,21 +23,28 @@ jobs:
2223
deps: null
2324
options: -DENABLE_PIE=ON -DUSE_ASM=OFF
2425
- tag: gui-full
25-
deps: |
26+
deps: >-
2627
libminiupnpc-dev
2728
libqrencode-dev
2829
qtbase5-dev
2930
qttools5-dev
30-
options: -DENABLE_GUI=ON -DENABLE_QRENCODE=ON -DENABLE_UPNP=ON -DUSE_DBUS=ON
31+
options: >-
32+
-DENABLE_GUI=ON
33+
-DENABLE_QRENCODE=ON
34+
-DENABLE_UPNP=ON
35+
-DUSE_DBUS=ON
3136
- tag: system-libs
32-
deps: |
37+
deps: >-
3338
libdb5.3++-dev
3439
libleveldb-dev
3540
libsnappy-dev
3641
libsecp256k1-dev
3742
libunivalue-dev
3843
xxd
39-
options: -DSYSTEM_BDB=ON -DSYSTEM_LEVELDB=ON -DSYSTEM_UNIVALUE=ON
44+
options: >-
45+
-DSYSTEM_BDB=ON
46+
-DSYSTEM_LEVELDB=ON
47+
-DSYSTEM_UNIVALUE=ON
4048
steps:
4149
- name: Checkout
4250
uses: actions/checkout@v3
@@ -73,6 +81,7 @@ jobs:
7381
-DENABLE_TESTS=ON
7482
- name: Restore cache
7583
uses: actions/cache/restore@v3
84+
if: always()
7685
with:
7786
path: ${{env.CCACHE_DIR}}
7887
key: ccache-linux-${{matrix.tag}}-${{github.run_id}}
@@ -83,6 +92,7 @@ jobs:
8392
cmake --build ${{github.workspace}}/build -v -j $(nproc)
8493
- name: Save cache
8594
uses: actions/cache/save@v3
95+
if: always()
8696
with:
8797
path: ${{env.CCACHE_DIR}}
8898
key: ccache-linux-${{matrix.tag}}-${{github.run_id}}
@@ -96,3 +106,89 @@ jobs:
96106
name: testlog-linux-${{matrix.tag}}
97107
path: ${{github.workspace}}/build/Testing/Temporary/LastTest.log
98108
retention-days: 7
109+
110+
test-macos:
111+
runs-on: macos-latest
112+
env:
113+
CCACHE_DIR: ${{github.workspace}}/ccache
114+
CCACHE_MAXSIZE: 400M
115+
CCACHE_COMPILERCHECK: content
116+
strategy:
117+
matrix:
118+
tag:
119+
- minimal
120+
- no-asm
121+
- gui-full
122+
- system-libs
123+
include:
124+
- tag: no-asm
125+
deps: null
126+
options: -DENABLE_PIE=ON -DUSE_ASM=OFF
127+
- tag: gui-full
128+
deps: >-
129+
miniupnpc
130+
qrencode
131+
qt@5
132+
options: >-
133+
-DENABLE_GUI=ON
134+
-DQt5_DIR=/usr/local/opt/qt5/lib/cmake/Qt5
135+
-DENABLE_QRENCODE=ON
136+
-DENABLE_UPNP=ON
137+
- tag: system-libs
138+
deps: >-
139+
berkeley-db@5
140+
secp256k1
141+
vim
142+
options: >-
143+
-DSYSTEM_BDB=ON
144+
-DBerkeleyDB_INCLUDE_DIR=/usr/local/opt/berkeley-db@5/include
145+
-DBerkeleyDB_CXX_LIBRARY=/usr/local/opt/berkeley-db@5/lib/libdb_cxx.dylib
146+
-DSYSTEM_SECP256K1=ON
147+
-DSYSTEM_XXD=ON
148+
steps:
149+
- name: Checkout
150+
uses: actions/checkout@v3
151+
- name: Install dependencies
152+
run: |
153+
brew install boost ccache ninja ${{matrix.deps}}
154+
- name: Configure
155+
run: |
156+
PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig:${PKG_CONFIG_PATH}"
157+
export PKG_CONFIG_PATH
158+
159+
pushd src
160+
../contrib/nomacro.pl
161+
popd
162+
163+
cmake -B ${{github.workspace}}/build -G Ninja \
164+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
165+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
166+
${{matrix.options}} \
167+
-DENABLE_TESTS=ON
168+
- name: Restore cache
169+
uses: actions/cache/restore@v3
170+
if: always()
171+
with:
172+
path: ${{env.CCACHE_DIR}}
173+
key: ccache-macos-${{matrix.tag}}-${{github.run_id}}
174+
restore-keys: |
175+
ccache-macos-${{matrix.tag}}-
176+
- name: Build
177+
run: |
178+
cmake --build ${{github.workspace}}/build -v -j $(sysctl -n hw.logicalcpu)
179+
- name: Save cache
180+
uses: actions/cache/save@v3
181+
if: always()
182+
with:
183+
path: ${{env.CCACHE_DIR}}
184+
key: ccache-macos-${{matrix.tag}}-${{github.run_id}}
185+
- name: Run tests
186+
run: |
187+
ctest --test-dir ${{github.workspace}}/build -j $(sysctl -n hw.logicalcpu)
188+
- name: Upload test logs
189+
uses: actions/upload-artifact@v3
190+
if: always()
191+
with:
192+
name: testlog-macos-${{matrix.tag}}
193+
path: ${{github.workspace}}/build/Testing/Temporary/LastTest.log
194+
retention-days: 7

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ endif()
174174

175175
set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_PIE})
176176

177+
# Set compiler flags
178+
if (APPLE)
179+
add_compile_options(-Wno-error=deprecated-declarations)
180+
add_compile_options(-Wno-error=thread-safety-analysis)
181+
add_compile_options(-Wno-error=thread-safety-reference)
182+
endif()
183+
177184
# Set endianness
178185
if(CMAKE_CXX_BYTE_ORDER EQUAL BIG_ENDIAN)
179186
set(WORDS_BIGENDIAN 1)

doc/build-macos.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ brew install cmake
5050
brew install automake libtool
5151

5252
brew install berkeley-db@5 boost curl leveldb libzip openssl pkgconf secp256k1
53+
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/opt/openssl@3/lib/pkgconfig"
5354
```
5455

5556
### 4. Clone Gridcoin repository
@@ -165,7 +166,11 @@ pip3 install ds_store mac_alias
165166

166167
```shell
167168
mkdir build && cd build
169+
168170
cmake ..
171+
# or, to configure with GUI
172+
cmake .. -DENABLE_GUI=ON -DQt5_DIR=/usr/local/opt/qt5/lib/cmake/Qt5
173+
169174
cmake --build .
170175
```
171176
* With Autotools:

src/bdb53/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ if(ENABLE_PIE)
1313
--with-pic
1414
)
1515
endif()
16+
if(APPLE)
17+
list(APPEND BDB_FLAGS
18+
CFLAGS=-Wno-implicit-function-declaration
19+
)
20+
endif()
1621
if(MINGW)
1722
list(APPEND BDB_FLAGS
1823
--enable-mingw

src/gridcoin/voting/registry.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,11 @@ const PollRegistry::Sequence PollRegistry::Polls() const
734734
{
735735
LOCK(GetPollRegistry().cs_poll_registry);
736736

737+
#pragma clang diagnostic push
738+
#pragma clang diagnostic ignored "-Wthread-safety-reference"
737739
return Sequence(m_polls);
740+
#pragma clang diagnostic pop
741+
738742
}
739743

740744
const PollReference* PollRegistry::TryLatestActive() const EXCLUSIVE_LOCKS_REQUIRED(PollRegistry::cs_poll_registry)

src/gridcoin/voting/result.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,10 @@ class VoteCounter
920920
throw InvalidVoteError();
921921
}
922922

923+
#pragma clang diagnostic push
924+
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
923925
ProcessLegacyVote(candidate.LegacyVote());
926+
#pragma clang diagnostic pop
924927
}
925928

926929
//!

src/qt/CMakeLists.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ add_library(gridcoinqt STATIC
9999

100100
if(WIN32)
101101
target_sources(gridcoinqt PRIVATE res/gridcoinresearch.rc)
102+
elseif(APPLE)
103+
target_sources(gridcoinqt PRIVATE
104+
macdockiconhandler.mm
105+
macnotificationhandler.mm
106+
macos_appnap.mm
107+
)
102108
endif()
103109

104110
set_target_properties(gridcoinqt PROPERTIES
@@ -136,6 +142,14 @@ target_link_libraries(gridcoinqt PUBLIC
136142
gridcoin_util
137143
)
138144

145+
if(APPLE)
146+
target_link_libraries(gridcoinqt PUBLIC
147+
"-framework Foundation"
148+
"-framework ApplicationServices"
149+
"-framework AppKit"
150+
)
151+
endif()
152+
139153
target_compile_definitions(gridcoinqt PUBLIC HAVE_CONFIG_H)
140154

141155
if(USE_DBUS)
@@ -158,14 +172,6 @@ add_dependencies(gridcoinqt gridcoinqt_l10n)
158172

159173
add_executable(gridcoinresearch WIN32 MACOSX_BUNDLE bitcoin.cpp)
160174

161-
if(APPLE)
162-
target_sources(gridcoinresearch PRIVATE
163-
macdockiconhandler.mm
164-
macnotificationhandler.mm
165-
macos_appnap.mm
166-
)
167-
endif()
168-
169175
target_link_libraries(gridcoinresearch PRIVATE
170176
Qt5::Widgets
171177
gridcoin_util

src/rpc/voting.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,13 @@ UniValue getpollresults(const UniValue& params, bool fHelp)
569569

570570
// We only need to lock the registry to retrieve the reference. If there is a reorg during the PollResultToJson, it will
571571
// throw.
572-
if (const PollReference* ref = WITH_LOCK(GetPollRegistry().cs_poll_registry, return TryPollByTitleOrId(title_or_id))) {
572+
573+
#pragma clang diagnostic push
574+
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
575+
if (const PollReference* ref = WITH_LOCK(GetPollRegistry().cs_poll_registry, return TryPollByTitleOrId(title_or_id))) {
573576
return PollResultToJson(*ref);
574577
}
578+
#pragma clang diagnostic pop
575579

576580
throw JSONRPCError(RPC_MISC_ERROR, "No matching poll found");
577581
}
@@ -722,9 +726,12 @@ UniValue votedetails(const UniValue& params, bool fHelp)
722726

723727
// We only need to lock the registry to retrieve the reference. If there is a reorg during the PollResultToJson, it will
724728
// throw.
725-
if (const PollReference* ref = WITH_LOCK(GetPollRegistry().cs_poll_registry, return TryPollByTitleOrId(title_or_id))) {
729+
#pragma clang diagnostic push
730+
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
731+
if (const PollReference* ref = WITH_LOCK(GetPollRegistry().cs_poll_registry, return TryPollByTitleOrId(title_or_id))) {
726732
return VoteDetailsToJson(*ref);
727733
}
734+
#pragma clang diagnostic pop
728735

729736
throw JSONRPCError(RPC_MISC_ERROR, "No matching poll found");
730737
}

src/script.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// Distributed under the MIT/X11 software license, see the accompanying
44
// file COPYING or https://opensource.org/licenses/mit-license.php.
55

6-
using namespace std;
7-
86
#include "script.h"
97
#include <crypto/sha1.h>
108
#include "keystore.h"
@@ -18,6 +16,8 @@ using namespace std;
1816

1917
#include <stdexcept>
2018

19+
using namespace std;
20+
2121
CScriptID::CScriptID(const CScript& in) : BaseHash(Hash160(in)) {}
2222
//CScriptID::CScriptID(const ScriptHash& in) : BaseHash(static_cast<uint160>(in)) {}
2323

src/serialize.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,10 @@ template<typename Stream, typename T> void Unserialize(Stream& os, std::unique_p
732732
template<typename Stream, typename T>
733733
inline void Serialize(Stream& os, const T& a)
734734
{
735+
#pragma clang diagnostic push
736+
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
735737
a.Serialize(os);
738+
#pragma clang diagnostic pop
736739
}
737740

738741
template<typename Stream, typename T>

0 commit comments

Comments
 (0)