Skip to content

Commit

Permalink
chore: switch build system to cmake
Browse files Browse the repository at this point in the history
There are multiple benefits of using CMake over Autotools like:
- CMake is much more modern and requires much less lines of code as
  compared to doing the same thing in autotools
- Autotools is years of bad decisions, generating a long 50k+ lines of
  bash script to generate the Makefiles definitely isn't a good idea and
  is really slow as well as makes debugging the build process very
  difficult
- Existing projects using termux-elf-cleaner using CMake should benefit
  from this.
  • Loading branch information
thunder-coding committed Apr 2, 2024
1 parent eab198c commit 77e4017
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 512 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/attach_termux_elf_cleaner_to_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ jobs:
echo "The versionName '${RELEASE_VERSION_NAME/v/}' is not a valid version as per semantic version '2.0.0' spec in the format 'major.minor.patch(-prerelease)(+buildmetadata)'. https://semver.org/spec/v2.0.0.html."
exit 1
fi
- name: Install required packages
run: |
sudo apt update
sudo apt upgrade
sudo apt install cmake ninja-build
- name: Build
run: |
autoreconf -vfi
mkdir build && cd build
../configure
make
cmake . -Bbuild -GNinja
ninja -C build/
- name: Test
run: |
ninja -C build/ test
- name: Attach termux-elf-cleaner to release
uses: termux/[email protected]
with:
Expand Down
23 changes: 8 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,15 @@ jobs:
with:
ref: ${{ env.GITHUB_REF }}

- name: Prepare
- name: Install required packages
run: |
autoreconf -vfi
mkdir build
- name: Configure
run: |
cd build
../configure
- name: Make
sudo apt update
sudo apt upgrade
sudo apt install cmake ninja-build
- name: Build
run: |
cd build
make
cmake . -Bbuild -GNinja
ninja -C build/
- name: Test
run: |
cd build
make check
ninja -C build/ test
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ elf-cleaner
# In case of out-of-src build in a directory build/:
build/

# Some people prefer to use this as build directory
out/

# Used for editor integration (completions, etc)
compile_commands.json

*~

# Generated files from old autotools
# Although we no longer use autotools, some contributors might still be having it in their trees
Makefile.in
aclocal.m4
autom4te.cache/
Expand Down
38 changes: 38 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)

set(VERSION_MAJOR 3)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)

set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

set(ARCHES aarch64;arm;i686;x86_64)
set(APIS 21;24)

project(elf-cleaner
LANGUAGES C CXX
VERSION ${VERSION}
)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(PACKAGE_NAME "termux-elf-cleaner" CACHE STRING "Name of the package")

add_executable("${PACKAGE_NAME}"
elf-cleaner.cpp
arghandling.c
)

target_compile_definitions("${PACKAGE_NAME}"
PRIVATE "COPYRIGHT=\"Copyright (C) 2022-2024 Termux and contributors.\""
PRIVATE "PACKAGE_VERSION=\"${VERSION}\""
PRIVATE "PACKAGE_NAME=\"${PACKAGE_NAME}\""
)

enable_testing()
add_test(
NAME "tests"
COMMAND bash -c "${CMAKE_CURRENT_SOURCE_DIR}/tests/test.sh ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME} ${CMAKE_CURRENT_SOURCE_DIR}"
)
24 changes: 0 additions & 24 deletions Makefile.am

This file was deleted.

43 changes: 0 additions & 43 deletions configure.ac

This file was deleted.

1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.test
62 changes: 0 additions & 62 deletions tests/Makefile.am

This file was deleted.

109 changes: 0 additions & 109 deletions tests/api-21.at

This file was deleted.

Loading

0 comments on commit 77e4017

Please sign in to comment.