Skip to content

Commit

Permalink
static build
Browse files Browse the repository at this point in the history
  • Loading branch information
fdobad committed Aug 28, 2024
1 parent ac03349 commit ca146ad
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 63 deletions.
63 changes: 0 additions & 63 deletions .github/workflows/build-fedora.yml

This file was deleted.

89 changes: 89 additions & 0 deletions .github/workflows/build-manylinux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: build manylinux

on:
pull_request:
branches:
- main
workflow_dispatch:
workflow_call:

permissions:
contents: write

jobs:
ubuntu_build:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Install Dependencies
run: |
sudo apt update
sudo apt install -y g++-12 libboost-all-dev libeigen3-dev libtiff-dev libjpeg-dev libjbig-dev liblzma-dev libzstd-dev libwebp-dev libdeflate-dev libleptonica-dev
- name: Check Packages Versions
run: |
dpkg-query -W -f='${binary:Package} ${Version}\n' g++-12 libboost-all-dev libeigen3-dev libtiff-dev libjpeg-dev libjbig-dev liblzma-dev libzstd-dev libwebp-dev libdeflate-dev libleptonica-dev > new_pkgs_ubuntu.txt
cat new_pkgs_ubuntu.txt
# if [ -n "$(diff new_pkgs_ubuntu.txt pkgs_ubuntu.txt)" ]; then
# echo "::warning:: apt packages versions diff! $(diff new_pkgs_ubuntu.txt pkgs_ubuntu.txt)"
# diff_output=$(diff --side-by-side --suppress-common-lines new_pkgs_ubuntu.txt pkgs_ubuntu.txt || true)
# echo "$diff_output" | while IFS= read -r line; do
# echo "$line"
# done
# fi
- name: Get Environment
id: get_env
run: |
DISTRIBUTION=$( lsb_release --short --id 2>/dev/null )
CODENAME=$( lsb_release --short --codename 2>/dev/null )
MACHINE=$( uname --machine 2>/dev/null )
echo "SUFFIX=".${DISTRIBUTION}.${CODENAME}.${MACHINE}"" >> $GITHUB_ENV
- name: Build
run: |
cd Cell2Fire
make clean
make
ldd Cell2Fire
mv Cell2Fire Cell2Fire${{ env.SUFFIX }}
make clean
make -f makefile.static
ldd Cell2Fire
- name: Test
run: |
cd test
bash test.sh
- name: Upload
uses: actions/upload-artifact@v4
with:
name: binaries
path: Cell2Fire/Cell2Fire*

test:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: binaries
path: Cell2Fire

- name: TestManyLinux
run: |
cd test
bash test.sh
- name: TestSuffix
run: |
cd test
bash test.sh ${{ env.SUFFIX }}
33 changes: 33 additions & 0 deletions Cell2Fire/makefile.static
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Compiler
CXX = g++-12

# Compiler and linker flags
CXXFLAGS = -m64 -fPIC -fno-strict-aliasing -fexceptions -fopenmp -DNDEBUG -DIL_STD -std=c++14 -O3 -I /usr/include -I /usr/include/eigen3
LDFLAGS = -m64 -fPIC -fno-strict-aliasing -fexceptions -fopenmp -DNDEBUG -DIL_STD -static -static-libgcc -static-libstdc++ -lm -lpthread -ltiff -ljpeg -ljbig -llzma -lzstd -lwebp -ldeflate -lz -lLerc

# Source files
SRCS = Cell2Fire.cpp Cells.cpp FuelModelSpain.cpp FuelModelKitral.cpp FuelModelFBP.cpp Spotting.cpp ReadCSV.cpp ReadArgs.cpp Lightning.cpp WriteCSV.cpp Ellipse.cpp DataGenerator.cpp

# Object files
OBJS = $(SRCS:.cpp=.o)

# Target executable
TARGET = Cell2Fire

# Build rules
all: $(TARGET)

$(TARGET): $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LDFLAGS)

%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@

clean:
rm -f $(OBJS) $(TARGET)

DESTDIR = /usr/local/bin
install: all
cp $(TARGETS) $(DESTDIR)
uninstall: all
rm $(DESTDIR)/$(TARGETS)

0 comments on commit ca146ad

Please sign in to comment.