From 1c4270be9c99301487045227777c424b67226f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20R=C3=B3=C5=BCewski?= Date: Fri, 26 Apr 2024 01:40:53 +0200 Subject: [PATCH] refactor: rename 'amarok' demo to 'amarooke' This commit updates the project to rename the 'amarok' demo program to 'amarooke', extending across CMake configurations, documentation, and source files. It includes adjustments in the CMakeLists.txt for executable generation, linking, and installation paths; updates to README.md to ensure the documentation reflects the new demo program name; and a source file rename with corresponding string updates to match the new naming convention. This change aligns with a decision to standardize demo program names more closely with their thematic representation, enhancing clarity and project cohesion. --- CMakeLists.txt | 8 ++++---- README.md | 26 +++++++++++++++----------- lib/mdsanima.c | 7 ++++--- lib/mdsanima.h | 16 ++++++++-------- project/mdsanima-amarok/main.c | 19 ------------------- project/mdsanima-amarooke/main.c | 17 +++++++++++++++++ project/mdsanima-blizzard/main.c | 16 +++++++--------- project/mdsanima-conquest/main.c | 16 +++++++--------- 8 files changed, 62 insertions(+), 63 deletions(-) delete mode 100644 project/mdsanima-amarok/main.c create mode 100644 project/mdsanima-amarooke/main.c diff --git a/CMakeLists.txt b/CMakeLists.txt index a59fe91..6999ce1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ add_library(stunning SHARED example/mdsanima-stunning/lib.cxx) target_link_libraries(${PROJECT_NAME}-stunning stunning) # Project demo programs -add_executable(${PROJECT_NAME}-amarok project/mdsanima-amarok/main.c) +add_executable(${PROJECT_NAME}-amarooke project/mdsanima-amarooke/main.c) add_executable(${PROJECT_NAME}-blizzard project/mdsanima-blizzard/main.c) add_executable(${PROJECT_NAME}-conquest project/mdsanima-conquest/main.c) @@ -33,17 +33,17 @@ add_executable(${PROJECT_NAME}-conquest project/mdsanima-conquest/main.c) add_library(${PROJECT_NAME} STATIC lib/mdsanima.c) # Targeting demo library -target_link_libraries(mdsanima-amarok mdsanima) +target_link_libraries(mdsanima-amarooke mdsanima) target_link_libraries(mdsanima-blizzard mdsanima) target_link_libraries(mdsanima-conquest mdsanima) # Targeting demo programs -target_include_directories(mdsanima INTERFACE project/mdsanima-amarok/) +target_include_directories(mdsanima INTERFACE project/mdsanima-amarooke/) target_include_directories(mdsanima INTERFACE project/mdsanima-blizzard/) target_include_directories(mdsanima INTERFACE project/mdsanima-conquest/) # Installing demo programs -install(TARGETS mdsanima-amarok DESTINATION bin) +install(TARGETS mdsanima-amarooke DESTINATION bin) install(TARGETS mdsanima-blizzard DESTINATION bin) install(TARGETS mdsanima-conquest DESTINATION bin) diff --git a/README.md b/README.md index 042c38c..2f41051 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Introduction to [CMake](https://cmake.org/) configuration for building and runni **C/C++** programs. > [!NOTE] +> > To build the sample _demo_ programs that are in the _example_ and _project_ directory, we are > using `cmake` build system command on **WSL** or another virtual machine with a **GNU/Linux** > system, such as **Debian**, **Ubuntu**, **Fedora**, **CentOS**, and so on. The choice is yours. @@ -38,6 +39,7 @@ make ``` > [!CAUTION] +> > For the build to succeed, you must copy the header file `mdsanima.h` into the `/usr/local/include` > directory. This is because the `mdsanima.h` header file is a part of the **MDSANIMA** library, > which is not a part of the **CMake** build system right now. To copy this file to the destination @@ -47,7 +49,7 @@ make You can now run the demo programs by typing the following command inside the `build` directory: ```shell -./mdsanima-amarok +./mdsanima-amarooke ./mdsanima-blizzard ./mdsanima-conquest ./mdsanima-fantastic @@ -65,7 +67,7 @@ the `build` directory. After running the first command `cmake -B build` to gener for the _example_ and _project_ programs, and then running the `make` command to build the executable files, you can run the _example_ programs that we showed above. -The _mdsanima-amarok_, _mdsanima-blizzard_ and _mdsanima-conquest_ program is quite different. You +The _mdsanima-amarooke_, _mdsanima-blizzard_ and _mdsanima-conquest_ program is quite different. You can install the project program by typing the following command: ```shell @@ -73,12 +75,12 @@ cd build sudo make install ``` -That command will install the _mdsanima-amarok_, _mdsanima-blizzard_ and _mdsanima-conquest_ project -demo programs in the `/usr/local/bin` directory, and you can run the program by typing the following -command: +That command will install the _mdsanima-amarooke_, _mdsanima-blizzard_ and _mdsanima-conquest_ +project demo programs in the `/usr/local/bin` directory, and you can run the program by typing the +following command: ```shell -mdsanima-amarok +mdsanima-amarooke mdsanima-blizzard mdsanima-conquest ``` @@ -97,6 +99,7 @@ are located in the `src` directory, but you can also put all the files in one di depends on the project. > [!NOTE] +> > To manualy build the demo programs, you can use the `gcc` or `g++` command to compile and link the > source code files. @@ -112,19 +115,20 @@ g++ -o build/mdsanima-fantastic main.cc This method is only recommended if you want to manually build the program. > [!IMPORTANT] +> > The sample projects are written in **C** and **C++** languages, and the source code files have > extensions `.c`, `.cc`, and `.cpp`. You can also use the `.cxx` file format, as we added in the -> example project. Here is just an example. Remember to use the chosen format and be consistent -> with it. +> example project. Here is just an example. Remember to use the chosen format and be consistent with +> it. All projects are the same; they only differ in the text displayed in the terminal and in other file extensions. ## Google Style Guide -Also, check how _Google_ does it. -Here is a [C++ Style Guide](https://google.github.io/styleguide/cppguide.html) -and [Objective-C Style Guide](https://google.github.io/styleguide/objcguide.html) provided by the +Also, check how _Google_ does it. Here is a +[C++ Style Guide](https://google.github.io/styleguide/cppguide.html) and +[Objective-C Style Guide](https://google.github.io/styleguide/objcguide.html) provided by the [Google Style Guide](https://github.com/google/styleguide). The complete guide for naming conventions, variables, functions, and more by _Google_. diff --git a/lib/mdsanima.c b/lib/mdsanima.c index 02a0f3b..790ebc3 100644 --- a/lib/mdsanima.c +++ b/lib/mdsanima.c @@ -1,11 +1,12 @@ // Copyright (c) 2024 MDSANIMA LAB. All rights reserved. // Licensed under the MIT license. -// The `MDSANIMA` demo library implementation. +// The C demo project file for the `MDSANIMA` static library implementation. #include #include -void cprint(char* text, int foreground, int background) { - printf("\e[38;5;%dm\e[48;5;%dm%s\e[0m", foreground, background, text); +void cprint(const char *text, int foreground, int background) +{ + printf("\e[38;5;%dm\e[48;5;%dm%s\e[0m\n", foreground, background, text); } diff --git a/lib/mdsanima.h b/lib/mdsanima.h index 7ef3358..95e6297 100644 --- a/lib/mdsanima.h +++ b/lib/mdsanima.h @@ -1,20 +1,20 @@ // Copyright (c) 2024 MDSANIMA LAB. All rights reserved. // Licensed under the MIT license. -// The `MDSANIMA` demo library that is used to print text in the terminal with colors. +// The header C demo project file for the `MDSANIMA` static library. #ifndef MDSANIMA_H #define MDSANIMA_H /** - * This is a simple color printing implementation. You can change the foreground and the background - * color of the text that will be printed in the terminal. This function is a wrapper for the ANSI - * escape sequence from the terminal. + * Advance color text message printing on the stdout. * - * @param text The text to print in the terminal with the color. - * @param foreground The foreground color is a number from 0 to 255. - * @param background The background color is a number from 0 to 255. + * @note Wrapper for the ANSI escape sequence, where 0 is black and 255 is white. + * + * @param text The text message to stdout print in the color on the terminal. + * @param foreground The foreground color of the text message. A number from 0 to 255. + * @param background The background color of the text message. A number from 0 to 255. */ -void cprint(char* text, int foreground, int background); +void cprint(const char *text, int foreground, int background); #endif diff --git a/project/mdsanima-amarok/main.c b/project/mdsanima-amarok/main.c deleted file mode 100644 index 66e3ad2..0000000 --- a/project/mdsanima-amarok/main.c +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2024 MDSANIMA LAB. All rights reserved. -// Licensed under the MIT license. - -// Simple C implementation of the demo `MDSANIMA AMAROK` project. This project is a simple demo of -// the basic usage of the `MDSANIMA` demo C library that can build and run on amd64 GNU/Linux -// system, such as Debian, Ubuntu, Fedora, CentOS, and so on. The main funcionality of this project -// is to print text in the terminal with a color. - -#include -#include - -int main(void) { - const int foregroundColor = 45; - const int backgroundColor = 27; - - cprint(" MDSANIMA AMAROK \n", foregroundColor, backgroundColor); - - return 0; -} diff --git a/project/mdsanima-amarooke/main.c b/project/mdsanima-amarooke/main.c new file mode 100644 index 0000000..79cc33c --- /dev/null +++ b/project/mdsanima-amarooke/main.c @@ -0,0 +1,17 @@ +// Copyright (c) 2024 MDSANIMA LAB. All rights reserved. +// Licensed under the MIT license. + +// The main C demo program for the `MDSANIMA AMAROOKE` project. + +#include + +int main(void) +{ + const char *message = " MDSANIMA AMAROOKE "; + const int orange = 202; // Text color + const int red = 196; // Background color + + cprint(message, orange, red); + + return 0; +} diff --git a/project/mdsanima-blizzard/main.c b/project/mdsanima-blizzard/main.c index e8f44f3..d428c7a 100644 --- a/project/mdsanima-blizzard/main.c +++ b/project/mdsanima-blizzard/main.c @@ -1,19 +1,17 @@ // Copyright (c) 2024 MDSANIMA LAB. All rights reserved. // Licensed under the MIT license. -// Simple C implementation of the demo `MDSANIMA BLIZZARD` project. This project is a simple demo of -// the basic usage of the `MDSANIMA` demo C library that can build and run on amd64 GNU/Linux -// system, such as Debian, Ubuntu, Fedora, CentOS, and so on. The main funcionality of this project -// is to print text in the terminal with a color. +// The main C demo program for the `MDSANIMA BLIZZARD` project. #include -#include -int main(void) { - const int foregroundColor = 48; - const int backgroundColor = 35; +int main(void) +{ + const char *message = " MDSANIMA BLIZZARD "; + const int teal = 36; // Text color + const int green = 46; // Background color - cprint(" MDSANIMA BLIZZARD \n", foregroundColor, backgroundColor); + cprint(message, teal, green); return 0; } diff --git a/project/mdsanima-conquest/main.c b/project/mdsanima-conquest/main.c index deecbde..2c88b3e 100644 --- a/project/mdsanima-conquest/main.c +++ b/project/mdsanima-conquest/main.c @@ -1,19 +1,17 @@ // Copyright (c) 2024 MDSANIMA LAB. All rights reserved. // Licensed under the MIT license. -// Simple C implementation of the demo `MDSANIMA CONQUEST` project. This project is a simple demo of -// the basic usage of the `MDSANIMA` demo C library that can build and run on amd64 GNU/Linux -// system, such as Debian, Ubuntu, Fedora, CentOS, and so on. The main funcionality of this project -// is to print text in the terminal with a color. +// The main C demo program for the `MDSANIMA CONQUEST` project. #include -#include -int main(void) { - const int foregroundColor = 45; - const int backgroundColor = 27; +int main(void) +{ + const char *message = " MDSANIMA CONQUEST "; + const int sky = 45; // Text color + const int blue = 27; // Background color - cprint(" MDSANIMA CONQUEST \n", foregroundColor, backgroundColor); + cprint(message, sky, blue); return 0; }