diff --git a/.gitignore b/.gitignore index 2632c7f..30a202f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,57 @@ -bin/ +# CMake build directories +/build*/ +/CMakeFiles/ +/CMakeCache.txt +/cmake_install.cmake +/*.cmake +/*.cbp +/*.layout +/*.stackdump +/CPackConfig.cmake +/Makefile +/CTestTestfile.cmake + +# Compiled binaries +/bin/ +/lib/ +/*.so +/*.dll +/*.dylib + +# Generated files +/*.a +/*.lib +/*.exe +/*.out +/*.app + +# Visual Studio Code specific +/.vscode/ + +# Sublime Text specific +/*.sublime-workspace + +# macOS specific +/.DS_Store + +# JetBrains IDEs specific +/.idea/ +/fleet/ + +# Emacs specific +*~ + +# Vim specific +*.swp + +# Other editor and tool specific files +*.bak +*.orig +*~ + +# Ignore all files in the root named test and tests +/test +/tests + +# Configuration files config.json diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..014ea08 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.20) + +# Project name and version +project(gh-wh-handler VERSION 0.1.0) + +# Determine the architecture +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + set(ARCH "x86_64") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + set(ARCH "aarch64") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l") + set(ARCH "armv7l") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686") + set(ARCH "i686") +else() + set(ARCH "unknown") +endif() + +# Set the executable name +set(EXECUTABLE_NAME "gh-wh-handler.${ARCH}") + +# Set the C++ standard +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Set the output directory +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) + +# Add source files +file(GLOB_RECURSE SOURCES "src/*.cpp") + +# Add the executable +add_executable(${EXECUTABLE_NAME} ${SOURCES}) + +# Add compilation flags +target_compile_options(${EXECUTABLE_NAME} PRIVATE -Wall -Werror) + +# Set linker flags for static linking +set_target_properties(${EXECUTABLE_NAME} PROPERTIES + LINK_FLAGS "-static -static-libgcc -static-libstdc++" +) + diff --git a/Makefile b/Makefile deleted file mode 100644 index 034f017..0000000 --- a/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -.PHONY: static - -static: - @mkdir -p bin || exit - @echo "Building static binary..." - @g++ -Wall -Werror -static -static-libgcc -static-libstdc++ -std=c++23 src/*.cpp -o bin/gh_wh_handler || exit - diff --git a/README.md b/README.md index 61a66a3..dc0947a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Head over to the [Releases Page](https://github.com/TiagoRG/gh-wh-handler/releas Run the application using your configuration file: ```console -/path/to/gh_wh_handler_ /path/to/config.json +/path/to/gh-wh-handler. /path/to/config.json ``` You can see the config file format below. @@ -24,17 +24,18 @@ Install the dependencies: - [CrowCpp](https://crowcpp.org/master/) - [nlohmann::json](https://github.com/nlohmann/json) -Compile the application: +Build the application: ```console -make +cmake -S . -B build +cmake --build build ``` Run the application using your configuration file: ```console -bin/gh_wh_handler /path/to/config.json +bin/gh-wh-handler. /path/to/config.json ``` -Note: default config file path is `/etc/gh_wh_handler/config.json` +Note: default config file path is `/etc/gh-wh-handler/config.json` ## Config File @@ -65,4 +66,4 @@ The configuration file should be a JSON file with the following format: ## Endpoint -Currently, the only endpoint for the application is /update-files +Currently, the only endpoint for the application is `/update-files` diff --git a/src/main.cpp b/src/main.cpp index ffa6c29..9312996 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,7 @@ int main(int argc, char **argv) { return 1; } - std::string config_file_path = argc == 2 ? 1[argv] : "/etc/gh_wh_handler/config.json"; + std::string config_file_path = argc == 2 ? 1[argv] : "/etc/gh-wh-handler/config.json"; // Open config file, exit if it fails std::ifstream config_file(config_file_path);