From 3493fda418410cf973331b954e74df3b2de82fac Mon Sep 17 00:00:00 2001 From: bog Date: Sat, 16 Mar 2024 20:45:32 +0100 Subject: [PATCH] :tada: C project and base documentation. --- .gitignore | 5 +++ CMakeLists.txt | 8 +++++ Makefile | 12 +++++++ ccm/CMakeLists.txt | 18 +++++++++++ ccm/main.c | 7 ++++ doc/Makefile | 2 ++ doc/requirements.txt | 28 ++++++++++++++++ doc/src/conf.py | 4 +++ doc/src/index.rst | 7 ++++ doc/src/installation.rst | 70 ++++++++++++++++++++++++++++++++++++++++ lib/CMakeLists.txt | 18 +++++++++++ lib/node.c | 1 + lib/node.h | 4 +++ 13 files changed, 184 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 Makefile create mode 100644 ccm/CMakeLists.txt create mode 100644 ccm/main.c create mode 100644 doc/Makefile create mode 100644 doc/requirements.txt create mode 100644 doc/src/conf.py create mode 100644 doc/src/index.rst create mode 100644 doc/src/installation.rst create mode 100644 lib/CMakeLists.txt create mode 100644 lib/node.c create mode 100644 lib/node.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a7a3a8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.cache +*~* +*\#* +build +doc/build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b03ace8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.28) + +project(CoCoMango) + +set(CMAKE_EXPORT_COMPILE_COMMANDS On) + +add_subdirectory(lib) +add_subdirectory(ccm) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..598d72a --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.PHONY: build install check doc + +build: + cmake -B build + cmake --build build + +install: build + sudo cmake --install build + +check: + @cppcheck --enable=all -q ccm lib \ + --suppress=missingIncludeSystem diff --git a/ccm/CMakeLists.txt b/ccm/CMakeLists.txt new file mode 100644 index 0000000..344dbd0 --- /dev/null +++ b/ccm/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.28) + +project(ccm) + +add_executable(ccm + main.c +) + +set_property(TARGET ccm PROPERTY C_STANDARD 99) + +add_dependencies(ccm ccm_lib) + +target_link_libraries(ccm + ccm_lib +) + +install(TARGETS ccm) + diff --git a/ccm/main.c b/ccm/main.c new file mode 100644 index 0000000..059c5a0 --- /dev/null +++ b/ccm/main.c @@ -0,0 +1,7 @@ +#include + +int main() +{ + printf("Hello World!\n"); + return 0; +} diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..0b96e1c --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,2 @@ +all: + sphinx-build src build diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 0000000..0403d93 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,28 @@ +accessible-pygments==0.0.4 +alabaster==0.7.16 +Babel==2.14.0 +beautifulsoup4==4.12.3 +certifi==2024.2.2 +charset-normalizer==3.3.2 +docutils==0.20.1 +idna==3.6 +imagesize==1.4.1 +Jinja2==3.1.3 +MarkupSafe==2.1.5 +packaging==24.0 +pydata-sphinx-theme==0.15.2 +Pygments==2.17.2 +requests==2.31.0 +snowballstemmer==2.2.0 +soupsieve==2.5 +Sphinx==7.2.6 +sphinx-basic-ng==1.0.0b2 +sphinx-book-theme==1.1.2 +sphinxcontrib-applehelp==1.0.8 +sphinxcontrib-devhelp==1.0.6 +sphinxcontrib-htmlhelp==2.0.5 +sphinxcontrib-jsmath==1.0.1 +sphinxcontrib-qthelp==1.0.7 +sphinxcontrib-serializinghtml==1.1.10 +typing_extensions==4.10.0 +urllib3==2.2.1 diff --git a/doc/src/conf.py b/doc/src/conf.py new file mode 100644 index 0000000..b300452 --- /dev/null +++ b/doc/src/conf.py @@ -0,0 +1,4 @@ +project = 'CoCo Mango' +version = '0.0.0' + +html_theme = 'sphinx_book_theme' diff --git a/doc/src/index.rst b/doc/src/index.rst new file mode 100644 index 0000000..558c97b --- /dev/null +++ b/doc/src/index.rst @@ -0,0 +1,7 @@ +CCM Documentation +================= + +.. toctree:: + + installation + diff --git a/doc/src/installation.rst b/doc/src/installation.rst new file mode 100644 index 0000000..99c1709 --- /dev/null +++ b/doc/src/installation.rst @@ -0,0 +1,70 @@ +Installation +============ + +CCM is not distributed as binaries, therefore you have to compile it yourself. +But don't worry, once downloaded you can compile the project using only one command (``make install``). + +Let's start. First, you have to get the source code of CCM. Then you have to build and install it. + +Getting the source code +----------------------- +The easy way to get the sources is to download the source zip archive directly from +`this link `_. +All you have to do now is to unzip it. + +.. code-block:: bash + :caption: Extracting the zip archive + + # unzip the project source code + unzip ccm-main.zip + + # go to project directory + cd ccm-main + + + +If you have git installed on your system, you can get the repository with the command: + +.. code-block:: bash + :caption: Cloning the repository + + # clone the repository into the ccm directory + git clone https://git.shellbox.fr/bog/ccm.git + + # goto project directory + cd ccm + + +Get the sources here: https://git.shellbox.fr/bog/ccm + +Building and Installing +----------------------- +Compiling CCM is easy. All you have to do, is type one command: + +.. code-block:: bash + :caption: Installing CCM the quick way + + # may ask you root access via sudo + make install + +However, if you want more control over the compilation and installation, +you can use those 3 cmake commands to build the project the way you want. + +.. code-block:: bash + :caption: Step 1/3 Initialize cmake + + cmake -B build + + +.. code-block:: bash + :caption: Step 2/3 Compile CCM + + cmake --build build + + +.. code-block:: bash + :caption: Step 3/3 Install CCM + + cmake --install build + + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 0000000..a11bfc4 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.28) + +project(ccm_library) + +add_library(ccm_lib + node.c +) + +set_property(TARGET ccm_lib PROPERTY C_STANDARD 99) + +target_compile_options(ccm_lib + PUBLIC -Wall -Wextra -g +) + +target_include_directories(ccm_lib + PUBLIC "${CMAKE_SOURCE_DIR}/lib" +) +install(TARGETS ccm_lib) diff --git a/lib/node.c b/lib/node.c new file mode 100644 index 0000000..b6347a4 --- /dev/null +++ b/lib/node.c @@ -0,0 +1 @@ +#include "node.h" diff --git a/lib/node.h b/lib/node.h new file mode 100644 index 0000000..4579a1f --- /dev/null +++ b/lib/node.h @@ -0,0 +1,4 @@ +#ifndef NODE_H +#define NODE_H + +#endif