Skip to content

Commit 973a2df

Browse files
authored
Merge pull request #112 from wipedlifepotato/master
macos compilation for workflow
2 parents 9f28d84 + 8ac777d commit 973a2df

File tree

2 files changed

+95
-64
lines changed

2 files changed

+95
-64
lines changed

.github/workflows/build.yml

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ jobs:
1212
build:
1313
strategy:
1414
matrix:
15-
os: [ubuntu-latest] #, windows-latest]
15+
os: [ubuntu-latest, macos-latest]
1616
compiler: [clang]
1717

1818
runs-on: ${{ matrix.os }}
19+
1920
steps:
2021
- name: Checkout Repository
2122
uses: actions/checkout@v3
@@ -31,38 +32,59 @@ jobs:
3132
sudo apt update
3233
sudo apt install --no-install-recommends -y build-essential libboost-all-dev libssl-dev git
3334
34-
- name: Cache build artifacts (Ubuntu)
35-
if: matrix.os == 'ubuntu-latest'
36-
uses: actions/cache@v3
37-
with:
38-
path: |
39-
obj
40-
libi2pd.a
41-
key: ubuntu-build-${{ runner.os }}-${{ hashFiles('**/*.cpp', '**/*.h') }}
42-
#
35+
#######################
36+
# macOS dependencies #
37+
#BY VADE = https://github.com/MetanoicArmor
38+
#######################
39+
- name: Install dependencies (macOS)
40+
if: matrix.os == 'macos-latest'
41+
run: |
42+
brew update
43+
brew install boost openssl@3 cmake make
44+
45+
#######################
46+
# Windows dependencies #
47+
#######################
4348
# - name: Install MSYS2 (Windows)
4449
# if: matrix.os == 'windows-latest'
45-
# run: |
46-
# Invoke-WebRequest -Uri "https://github.com/msys2/msys2-installer/releases/download/2025-08-30/msys2-x86_64-20250830.exe" -OutFile "msys2-installer.exe"
47-
# Start-Process -Wait -FilePath "msys2-installer.exe" -ArgumentList "/S"
48-
# C:\msys64\usr\bin\bash.exe -lc "pacman -Syu --noconfirm"
49-
# C:\msys64\usr\bin\bash.exe -lc "export ARCH=x86_64; export MINGW=mingw64; pacman -S --noconfirm mingw-w64-$ARCH-gcc mingw-w64-$ARCH-boost mingw-w64-$ARCH-openssl git make"
50+
## uses: msys2/setup-msys2@v2
51+
# with:
52+
# msystem: CLANG64
53+
# install: base-devel git mingw-w64-x86_64-clang mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-miniupnpc
54+
# update: true
5055

5156
- name: Initialize Git Submodules
5257
run: git submodule update --init --recursive
5358

59+
#######################
60+
# Build Project
61+
#######################
5462
- name: Build Project (Ubuntu)
5563
if: matrix.os == 'ubuntu-latest'
5664
run: |
57-
make -j8
65+
make -j$(nproc)
66+
make stripall
67+
make builddir
68+
69+
- name: Build Project (macOS)
70+
if: matrix.os == 'macos-latest'
71+
run: |
72+
make HOMEBREW=1 -j8
5873
make stripall
5974
make builddir
60-
#
75+
6176
# - name: Build Project (Windows)
6277
# if: matrix.os == 'windows-latest'
63-
# run: |
64-
# C:\msys64\usr\bin\bash.exe -lc "cd /c/runner/work/i2pd-tools/i2pd-tools && make && make stripall && make builddir"
65-
#
78+
## shell: msys2 {0}
79+
# run: |
80+
# cd "${GITHUB_WORKSPACE}"
81+
# make -j$(nproc)
82+
# make stripall
83+
# make builddir
84+
85+
#######################
86+
# Upload binaries
87+
#######################
6688
- name: Upload binaries
6789
uses: actions/upload-artifact@v4
6890
with:

Makefile

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,64 @@
1-
UNAME = $(shell uname -s)
1+
UNAME := $(shell uname -s)
22

3-
I2PD_PATH = i2pd
4-
I2PD_LIB = libi2pd.a
3+
I2PD_PATH := i2pd
4+
I2PD_LIB := libi2pd.a
55

6-
LIBI2PD_PATH = $(I2PD_PATH)/libi2pd
7-
LIBI2PD_CLIENT_PATH = $(I2PD_PATH)/libi2pd_client
6+
LIBI2PD_PATH := $(I2PD_PATH)/libi2pd
7+
LIBI2PD_CLIENT_PATH := $(I2PD_PATH)/libi2pd_client
88

99
CXX ?= g++
10-
CXXFLAGS = -Wall -std=c++17 -O2
11-
INCFLAGS = -I$(LIBI2PD_PATH) -I$(LIBI2PD_CLIENT_PATH)
12-
DEFINES = -DOPENSSL_SUPPRESS_DEPRECATED
13-
14-
LDFLAGS =
15-
LDLIBS = $(I2PD_PATH)/$(I2PD_LIB) -lboost_system$(BOOST_SUFFIX) -lboost_program_options$(BOOST_SUFFIX) -lssl -lcrypto -lz
10+
CXXFLAGS := -Wall -std=c++17 -O2
11+
INCFLAGS := -I$(LIBI2PD_PATH) -I$(LIBI2PD_CLIENT_PATH)
12+
DEFINES := -DOPENSSL_SUPPRESS_DEPRECATED
1613

14+
LDFLAGS :=
15+
LDLIBS := $(I2PD_PATH)/$(I2PD_LIB) -lboost_program_options$(BOOST_SUFFIX) -lssl -lcrypto -lz
1716

1817
ifeq ($(UNAME),Linux)
19-
CXXFLAGS += -g
18+
CXXFLAGS += -g
19+
LDLIBS += -lrt -lpthread
2020
else ifeq ($(UNAME),Darwin)
21-
CXXFLAGS += -g
22-
else ifeq ($(UNAME),FreeBSD)
23-
CXXFLAGS += -g
24-
else
25-
# Win32
26-
CXXFLAGS += -Os -fPIC -msse
27-
DEFINES += -DWIN32_LEAN_AND_MEAN
28-
BOOST_SUFFIX = -mt
29-
endif
21+
CXXFLAGS += -g
22+
LDLIBS += -lpthread
3023

31-
ifeq ($(UNAME),Linux)
32-
LDLIBS += -lrt -lpthread
33-
else ifeq ($(UNAME),Darwin)
34-
LDLIBS += -lpthread
35-
LDFLAGS += -L/usr/local/opt/openssl@1.1/lib -L/usr/local/lib
36-
INCFLAGS += -I/usr/local/opt/openssl@1.1/include -I/usr/local/include
24+
ifeq ($(shell test -d /opt/homebrew && echo "true"),true)
25+
BREW_PREFIX := /opt/homebrew
26+
else
27+
BREW_PREFIX := /usr/local
28+
endif
29+
30+
INCFLAGS += -I$(BREW_PREFIX)/include -I$(BREW_PREFIX)/opt/openssl@3/include
31+
LDFLAGS += -L$(BREW_PREFIX)/lib -L$(BREW_PREFIX)/opt/openssl@3/lib
32+
33+
LDLIBS += -lboost_program_options
3734
else ifeq ($(UNAME),FreeBSD)
38-
LDLIBS += -lthr -lpthread
39-
LDFLAGS += -L/usr/local/lib
40-
INCFLAGS += -I/usr/local/include
35+
CXXFLAGS += -g
36+
LDLIBS += -lthr -lpthread
37+
LDFLAGS += -L/usr/local/lib
38+
INCFLAGS += -I/usr/local/include
4139
else
42-
# Win32
43-
LDLIBS += -lwsock32 -lws2_32 -liphlpapi -lpthread
44-
LDFLAGS += -s -static
40+
# Windows
41+
CXXFLAGS += -Os -fPIC -msse
42+
DEFINES += -DWIN32_LEAN_AND_MEAN
43+
LDFLAGS += -L/clang64/lib
44+
INCFLAGS += -I/clang64/include
45+
BOOST_SUFFIX =
46+
LDLIBS += -lwsock32 -lws2_32 -liphlpapi -lpthread
4547
endif
4648

47-
49+
# -------------------------
50+
# Targets
51+
# -------------------------
4852
all: $(I2PD_LIB) vain keygen keyinfo famtool routerinfo regaddr regaddr_3ld i2pbase64 offlinekeys b33address regaddralias x25519 verifyhost autoconf
49-
vain: vain.o $(I2PD_LIB)
53+
54+
vain: vain.o $(I2PD_LIB)
5055
$(CXX) -o vain $(LDFLAGS) vain.o $(LDLIBS)
5156

5257
autoconf: autoconf.o $(I2PD_LIB)
5358
$(CXX) -o autoconf $(DEFINES) $(LDFLAGS) autoconf.o $(LDLIBS)
5459

5560
routerinfo: routerinfo.o $(I2PD_LIB)
56-
$(CXX) -o routerinfo $(LDFLAGS) routerinfo.o $(LDLIBS) -latomic
61+
$(CXX) -o routerinfo $(LDFLAGS) routerinfo.o $(LDLIBS)
5762

5863
keygen: keygen.o $(I2PD_LIB)
5964
$(CXX) -o keygen $(DEFINES) $(LDFLAGS) keygen.o $(LDLIBS)
@@ -62,7 +67,7 @@ keyinfo: keyinfo.o $(I2PD_LIB)
6267
$(CXX) -o keyinfo $(DEFINES) $(LDFLAGS) keyinfo.o $(LDLIBS)
6368

6469
famtool: famtool.o $(I2PD_LIB)
65-
$(CXX) -o famtool $(DEFINES) $(LDFLAGS) famtool.o $(LDLIBS) -latomic
70+
$(CXX) -o famtool $(DEFINES) $(LDFLAGS) famtool.o $(LDLIBS)
6671

6772
regaddr: regaddr.o $(I2PD_LIB)
6873
$(CXX) -o regaddr $(DEFINES) $(LDFLAGS) regaddr.o $(LDLIBS)
@@ -88,7 +93,9 @@ x25519: x25519.o $(I2PD_LIB)
8893
verifyhost: verifyhost.o $(I2PD_LIB)
8994
$(CXX) -o verifyhost $(DEFINES) $(LDFLAGS) verifyhost.o $(LDLIBS)
9095

91-
.SUFFIXES:
96+
# -------------------------
97+
# Object compilation
98+
# -------------------------
9299
.SUFFIXES: .c .cc .C .cpp .o
93100

94101
$(I2PD_LIB):
@@ -97,6 +104,9 @@ $(I2PD_LIB):
97104
%.o: %.cpp $(I2PD_LIB)
98105
$(CXX) $(CXXFLAGS) $(DEFINES) $(INCFLAGS) -c -o $@ $<
99106

107+
# -------------------------
108+
# Cleanup
109+
# -------------------------
100110
count:
101111
wc *.c *.cc *.C *.cpp *.h *.hpp
102112

@@ -105,19 +115,18 @@ clean-i2pd:
105115

106116
clean-obj:
107117
rm -f $(wildcard *.o)
118+
108119
stripall:
109120
strip b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf
121+
110122
builddir:
111123
mkdir -p build
112124
mv b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf build/ || true
125+
113126
clean-bin:
114127
rm -f b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf
115128

116129
clean: clean-i2pd clean-obj clean-bin
117130

118-
.PHONY: all
119-
.PHONY: count
120-
.PHONY: clean-i2pd
121-
.PHONY: clean-obj
122-
.PHONY: clean-bin
123-
.PHONY: clean
131+
.PHONY: all count clean-i2pd clean-obj clean-bin clean
132+

0 commit comments

Comments
 (0)