Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New features for Makefile 🐧 #57

Merged
merged 31 commits into from
Jul 8, 2023
Merged

New features for Makefile 🐧 #57

merged 31 commits into from
Jul 8, 2023

Conversation

mitsuki31
Copy link
Owner

What's Changed

  • Added new rule named build-docs, that builds and generates the HTML pages of JMatrix's javadocs automatically.

    Warning This rule is standalone and can't be combined with other rules.

  • Added new file named makefile-usage.txt that would stores all of usage instructions and the list of available Make's options.

    Note This change also created new directory docs/.

  • Refactored the all rule and moved all usage instructions to makefile-usage.txt file.

    Note This refactor only change its method to prints the usage information,
    and does not change its original behavior.

  • Added a new Bash script that processes the command-line arguments and searches for a specific argument in the list, then outputs the index of the desired argument.

    Note This change also created new directory bin/.

  • Refactored the build-docs rule to be a standalone rule that ignores other rules.
  • The build-docs rule now supports several options.

    Note The build-docs supports 3 verbose modes:

    • Quiet mode (default) -> make build-docs
    • Normal mode -> make build-docs VERBOSE=true
    • All mode -> make build-docs VERBOSE=all

Summary

These changes introduce new functionality and improvements to the build process and documentation. The build-docs rule allows for easy generation of JMatrix's javadocs in HTML format. The addition of the makefile-usage.txt file centralizes the usage instructions and available options. These changes enhance the functionality and flexibility of the Makefile for building and documenting the project.

mitsuki31 added 13 commits July 5, 2023 15:28
The `build-docs` is the new `make` rule that would
creates and generates the JMatrix's Java documentation (javadoc).

Note: Generated docs will be saved in "docs/jmatrix/" directory.
This new file for now on and later will stores the usage information of JMatrix's `Make`.
Also by using this method, it can reduces time to generate or print
the usage information rather than using `@echo` in `Make`.

Note: JMatrix `Make` is using bash as command shell, for Windows please consider
to install Git Bash before using it.
This refactor only change its method to prints the usage information,
and does not change its original behavior (which prints the usage about
JMatrix's `Make`).
This script processes command-line arguments and searches for a specific
argument in the list, then outputs the index of the desired argument.

Usage:
    bash get_argument.sh [OPTIONS] ARGUMENTS
    bash get_argument.sh [-s ARG | -v] ARGUMENTS
This changes make the `build-docs` rule to be standalone rule,
which means it does not needs and ignores other rules, otherwise raises
an error.

This refactor would make the `FLAGS` options does not conflicting with
other rule that also uses `FLAGS` to add some either additional options or flags (e.g `compile`).
Thus, with refactoring the `build-docs` rule to make it a standalone rule,
it should makes code more easier to maintain on next patch.
And also remove the `-quiet` flag, it can be added again with...

    $ make build-docs FLAGS="-quiet"

...asign the `-quiet` flag to `FLAGS` as Make arguments.
This changes make the `build-docs` support some options such as:
  - FLAGS
  - VERBOSE

Usage:
    $ make build-docs [options] ...
    $ make build-docs [VERBOSE[=<bool>] | FLAGS[=<flags>]]

Please note, the `build-docs` rule does not supported multiple rules,
due to conflict between compiler's flags (`javac`) and `javadoc`'s flags.
The following code will get an error:

    $ make build-docs compile package
    $ make compile package build-docs
    $ make build-docs clean
@mitsuki31 mitsuki31 added the enhancement Enhancing existing features label Jul 6, 2023
@mitsuki31 mitsuki31 self-assigned this Jul 6, 2023
Makefile Outdated
$(if $(shell [ ! -f $(DOCS_PATH)makefile-usage.txt ] && echo 1),\
$(error $(PREFIX) File "$(DOCS_PATH)makefile-usage.txt" is missing)\
)
@cat $(DOCS_PATH)makefile-usage.txt
Copy link
Owner Author

@mitsuki31 mitsuki31 Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage instructions and list of available rules and options has been moved to makefile-usage.txt.
And here, the only way to print the usage instructions it uses cat command (Unix built-in).
This also improve the flexibility and reduce the code.

mitsuki31 added 3 commits July 7, 2023 00:51
Now the `clean` rule will also clean the temporary directory (`tmp/`).
This change fixed the temporary directory is get generated
even the verbose mode is deactivated (off).

# Only create temporary directory if the
# verbose activated
mkdir -p `dirname $tmpfile`
Copy link
Owner Author

@mitsuki31 mitsuki31 Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this code is inside of case block and only create the temporary directory if one of arguments activating the verbose mode (e.g -v or --verbose).

@mitsuki31
Copy link
Owner Author

Please note, this function below doesn't echoing the info message directly onto standard output, instead it writes the info message to log file named get_argument.log in tmp/ directory.

info() {
[ $1 = "Info" ] && echo -ne "[\033[1;92m$1\033[0m]${@/$1}\n" &>>$log
[ $1 = "Warning" ] && echo -ne "[\033[1;93m$1\033[0m]${@/$1}\n" &>>$log
}

Note The log file and its temporary directory only created if the verbose output is activated by using switch -v or --verbose.
See more details.

mitsuki31 added 9 commits July 7, 2023 15:40
Now the ` clean` rule will include the `docs/jmatrix/` directory
during cleaning the working directory and clean it recursively.

And this change also refactored the code, for now on before clean the
specific directory such as `tmp/` or `docs/jmatrix/` it will checks
whether the directory is exist, and cleans the directory only if exist.
This rule would cleans the generated docs recursively.

Note: This only clean the gemerated HTML pages of JMatrix's javadocs
recursively and does not clean other working directories.
Consider use the `clean` rule to clean the working directories thoroughly.
This change fixed the issue when both `FLAGS` and `VERBOSE` options
get defined at the same time, the `FLAGS`'s value will get changed by
`VERBOSE`. For example:

    $ make build-docs VERBOSE=all FLAGS="-quiet"

This will not trigger the `javadoc` to use the given FLAGS, instead it
will uses flags that given by `VERBOSE`, which is `-verbose`.
For more details, see 6a39b4d.
- Fixed unexpected behavior
  When user assign value "false" to VERBOSE option and invoke the `build-docs` rule,
  the `build-docs` would override the verbose mode NORMAL instead QUIET (no verbose).

- Added comments on each `ifeq` statements.
@mitsuki31
Copy link
Owner Author

Now several rules has supported using VERBOSE option:

  • clean - Cleans the working directory thoroughly.
  • cleanbin - Cleans the compiled class files only.
  • cleandocs - Cleans the generated HTML documentation only.

Usage:

$ make [rules] VERBOSE[=<bool>]
$ make [clean | cleanbin | cleandocs] VERBOSE[=<bool>]

mitsuki31 added 2 commits July 8, 2023 21:20
Both files contain the same contents but in `makefile-usage.txcc` file,
it has several texts with color coded, whereas in the other one is
the original contents with no color coded.

The extension `.txcc` chosen, it because `txcc` is stands for "text color coded".
This make the `all` rule to checks whether the current shell environment
to execute the Make is Bash or else (like Powershell). If the current shell is Bash, then
displays the contents from `makefile-usage.txcc` file which is the color coded version,
otherwise the another one.
@mitsuki31 mitsuki31 merged commit baa226c into master Jul 8, 2023
@mitsuki31 mitsuki31 deleted the update-makefile branch July 8, 2023 16:09
@mitsuki31 mitsuki31 added the releases Release a new version label Jul 9, 2023
@mitsuki31 mitsuki31 added feature Add new features to improve the project and removed enhancement Enhancing existing features labels Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Add new features to improve the project releases Release a new version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant