Skip to content

Commit

Permalink
refactor: rename 'amarok' demo to 'amarooke'
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mdsanima committed Apr 25, 2024
1 parent d525e35 commit 1c4270b
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 63 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ 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)

# Project demo library
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)

Expand Down
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -65,20 +67,20 @@ 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
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
```
Expand All @@ -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.
Expand All @@ -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_.

Expand Down
7 changes: 4 additions & 3 deletions lib/mdsanima.c
Original file line number Diff line number Diff line change
@@ -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 <mdsanima.h>
#include <stdio.h>

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);
}
16 changes: 8 additions & 8 deletions lib/mdsanima.h
Original file line number Diff line number Diff line change
@@ -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
19 changes: 0 additions & 19 deletions project/mdsanima-amarok/main.c

This file was deleted.

17 changes: 17 additions & 0 deletions project/mdsanima-amarooke/main.c
Original file line number Diff line number Diff line change
@@ -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 <mdsanima.h>

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;
}
16 changes: 7 additions & 9 deletions project/mdsanima-blizzard/main.c
Original file line number Diff line number Diff line change
@@ -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 <mdsanima.h>
#include <stdio.h>

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;
}
16 changes: 7 additions & 9 deletions project/mdsanima-conquest/main.c
Original file line number Diff line number Diff line change
@@ -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 <mdsanima.h>
#include <stdio.h>

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;
}

0 comments on commit 1c4270b

Please sign in to comment.