workflows: pre-init macos

This commit is contained in:
wipedlifepotato 2025-10-16 13:04:09 +03:00
parent ad258113c1
commit fb48cdd9e1
2 changed files with 74 additions and 52 deletions

View file

@ -12,10 +12,11 @@ jobs:
build: build:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
compiler: [clang] compiler: [clang]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -31,46 +32,58 @@ jobs:
sudo apt update sudo apt update
sudo apt install --no-install-recommends -y build-essential libboost-all-dev libssl-dev git sudo apt install --no-install-recommends -y build-essential libboost-all-dev libssl-dev git
- name: Cache build artifacts (Ubuntu) #######################
if: matrix.os == 'ubuntu-latest' # macOS dependencies #
uses: actions/cache@v3 #######################
with: - name: Install dependencies (macOS)
path: | if: matrix.os == 'macos-latest'
obj run: |
libi2pd.a brew update
key: ubuntu-build-${{ runner.os }}-${{ hashFiles('**/*.cpp', '**/*.h') }} brew install boost openssl@3 cmake make
#
# - name: Install MSYS2 (Windows) #######################
# if: matrix.os == 'windows-latest' # Windows dependencies #
# run: | #######################
# Invoke-WebRequest -Uri "https://github.com/msys2/msys2-installer/releases/download/2025-08-30/msys2-x86_64-20250830.exe" -OutFile "msys2-installer.exe"
# Start-Process -Wait -FilePath "msys2-installer.exe" -ArgumentList "/S"
# C:\msys64\usr\bin\bash.exe -lc "pacman -Syu --noconfirm"
# 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"
- name: Install MSYS2 (Windows) - name: Install MSYS2 (Windows)
uses: msys2/setup-msys2@v2
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
uses: msys2/setup-msys2@v2
with: with:
msystem: CLANG64 msystem: CLANG64
install: base-devel git mingw-w64-x86_64-clang mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-miniupnpc install: base-devel git mingw-w64-x86_64-clang mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-miniupnpc
update: true update: true
- name: Initialize Git Submodules - name: Initialize Git Submodules
run: git submodule update --init --recursive run: git submodule update --init --recursive
#######################
# Build Project
#######################
- name: Build Project (Ubuntu) - name: Build Project (Ubuntu)
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-latest'
run: | run: |
make -j8 make -j$(nproc)
make stripall make stripall
make builddir make builddir
#
# - name: Build Project (Windows) - name: Build Project (macOS)
# if: matrix.os == 'windows-latest' if: matrix.os == 'macos-latest'
# run: | run: |
# C:\msys64\usr\bin\bash.exe -lc "cd /c/runner/work/i2pd-tools/i2pd-tools && make && make stripall && make builddir" make HOMEBREW=1 -j8
# make stripall
make builddir
- name: Build Project (Windows)
if: matrix.os == 'windows-latest'
shell: msys2 {0}
run: |
cd "${GITHUB_WORKSPACE}"
make -j$(nproc)
make stripall
make builddir
#######################
# Upload binaries
#######################
- name: Upload binaries - name: Upload binaries
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:

View file

@ -11,42 +11,46 @@ CXXFLAGS = -Wall -std=c++17 -O2
INCFLAGS = -I$(LIBI2PD_PATH) -I$(LIBI2PD_CLIENT_PATH) INCFLAGS = -I$(LIBI2PD_PATH) -I$(LIBI2PD_CLIENT_PATH)
DEFINES = -DOPENSSL_SUPPRESS_DEPRECATED DEFINES = -DOPENSSL_SUPPRESS_DEPRECATED
LDFLAGS = LDFLAGS =
LDLIBS = $(I2PD_PATH)/$(I2PD_LIB) -lboost_system$(BOOST_SUFFIX) -lboost_program_options$(BOOST_SUFFIX) -lssl -lcrypto -lz LDLIBS = $(I2PD_PATH)/$(I2PD_LIB) -lboost_system$(BOOST_SUFFIX) -lboost_program_options$(BOOST_SUFFIX) -lssl -lcrypto -lz
# -------------------------
# Platform-specific flags
# -------------------------
ifeq ($(UNAME),Linux) ifeq ($(UNAME),Linux)
CXXFLAGS += -g CXXFLAGS += -g
else ifeq ($(UNAME),Darwin)
CXXFLAGS += -g
else ifeq ($(UNAME),FreeBSD)
CXXFLAGS += -g
else
# Win32
CXXFLAGS += -Os -fPIC -msse
DEFINES += -DWIN32_LEAN_AND_MEAN
BOOST_SUFFIX = -mt
endif
ifeq ($(UNAME),Linux)
LDLIBS += -lrt -lpthread LDLIBS += -lrt -lpthread
else ifeq ($(UNAME),Darwin) else ifeq ($(UNAME),Darwin)
CXXFLAGS += -g
LDLIBS += -lpthread LDLIBS += -lpthread
LDFLAGS += -L/usr/local/opt/openssl@1.1/lib -L/usr/local/lib ifdef HOMEBREW
INCFLAGS += -I/usr/local/opt/openssl@1.1/include -I/usr/local/include BREW_PREFIX := $(shell brew --prefix)
INCFLAGS += -I$(BREW_PREFIX)/include
LDFLAGS += -L$(BREW_PREFIX)/lib
else
INCFLAGS += -I/usr/local/opt/openssl@3/include -I/usr/local/include
LDFLAGS += -L/usr/local/opt/openssl@3/lib -L/usr/local/lib
endif
else ifeq ($(UNAME),FreeBSD) else ifeq ($(UNAME),FreeBSD)
CXXFLAGS += -g
LDLIBS += -lthr -lpthread LDLIBS += -lthr -lpthread
LDFLAGS += -L/usr/local/lib LDFLAGS += -L/usr/local/lib
INCFLAGS += -I/usr/local/include INCFLAGS += -I/usr/local/include
else else
# Win32 # Windows (MSYS2 / MinGW)
CXXFLAGS += -Os -fPIC -msse
DEFINES += -DWIN32_LEAN_AND_MEAN
BOOST_SUFFIX = -mt
LDLIBS += -lwsock32 -lws2_32 -liphlpapi -lpthread LDLIBS += -lwsock32 -lws2_32 -liphlpapi -lpthread
LDFLAGS += -s -static LDFLAGS += -s -static
endif endif
# -------------------------
# Build targets
# -------------------------
all: $(I2PD_LIB) vain keygen keyinfo famtool routerinfo regaddr regaddr_3ld i2pbase64 offlinekeys b33address regaddralias x25519 verifyhost autoconf all: $(I2PD_LIB) vain keygen keyinfo famtool routerinfo regaddr regaddr_3ld i2pbase64 offlinekeys b33address regaddralias x25519 verifyhost autoconf
vain: vain.o $(I2PD_LIB)
vain: vain.o $(I2PD_LIB)
$(CXX) -o vain $(LDFLAGS) vain.o $(LDLIBS) $(CXX) -o vain $(LDFLAGS) vain.o $(LDLIBS)
autoconf: autoconf.o $(I2PD_LIB) autoconf: autoconf.o $(I2PD_LIB)
@ -88,6 +92,9 @@ x25519: x25519.o $(I2PD_LIB)
verifyhost: verifyhost.o $(I2PD_LIB) verifyhost: verifyhost.o $(I2PD_LIB)
$(CXX) -o verifyhost $(DEFINES) $(LDFLAGS) verifyhost.o $(LDLIBS) $(CXX) -o verifyhost $(DEFINES) $(LDFLAGS) verifyhost.o $(LDLIBS)
# -------------------------
# Object compilation
# -------------------------
.SUFFIXES: .SUFFIXES:
.SUFFIXES: .c .cc .C .cpp .o .SUFFIXES: .c .cc .C .cpp .o
@ -97,6 +104,9 @@ $(I2PD_LIB):
%.o: %.cpp $(I2PD_LIB) %.o: %.cpp $(I2PD_LIB)
$(CXX) $(CXXFLAGS) $(DEFINES) $(INCFLAGS) -c -o $@ $< $(CXX) $(CXXFLAGS) $(DEFINES) $(INCFLAGS) -c -o $@ $<
# -------------------------
# Cleanup
# -------------------------
count: count:
wc *.c *.cc *.C *.cpp *.h *.hpp wc *.c *.cc *.C *.cpp *.h *.hpp
@ -105,19 +115,18 @@ clean-i2pd:
clean-obj: clean-obj:
rm -f $(wildcard *.o) rm -f $(wildcard *.o)
stripall: stripall:
strip b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf strip b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf
builddir: builddir:
mkdir -p build mkdir -p build
mv b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf build/ || true mv b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf build/ || true
clean-bin: clean-bin:
rm -f b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf rm -f b33address famtool i2pbase64 keygen keyinfo offlinekeys regaddr regaddr_3ld regaddralias routerinfo x25519 verifyhost vain autoconf
clean: clean-i2pd clean-obj clean-bin clean: clean-i2pd clean-obj clean-bin
.PHONY: all .PHONY: all count clean-i2pd clean-obj clean-bin clean
.PHONY: count
.PHONY: clean-i2pd
.PHONY: clean-obj
.PHONY: clean-bin
.PHONY: clean