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

Fixes some issue on MinGW (Windows) 🪛 #39

Merged
merged 4 commits into from
Jun 13, 2023
Merged

Fixes some issue on MinGW (Windows) 🪛 #39

merged 4 commits into from
Jun 13, 2023

Conversation

mitsuki31
Copy link
Owner

@mitsuki31 mitsuki31 commented Jun 12, 2023

What's Changed

  • Changed the newline character (\n) in Makefile with echo "". (457a3f2)
  • Update the message on cleanbin rule in Makefile. (1666711)
  • Fixes unable to compile issue on Windows when using make. (a868ad9)
  • Fixes trailing whitespaces. (37dd3b5)

Description

The messages which printed by make is always prints the \n as text instead treating it as a newline character on Windows with Git Bash and MinGW installed. On my device (Linux), it works well but if I'm using -e flag it would just prints the given flag.

@echo -e "some message"
# Output: e some message

So to make it fair, I've changed the newline with the implicit one (print a blank message with echo).

More details, see below:

jmatrix/Makefile

Lines 96 to 102 in 457a3f2

@echo ""
@echo ""
@echo " * Include source files while packaging"
@echo ""
@echo " \`make [options] INCLUDE-SRC=true\`"
@echo ""
@echo "Usage:"


Besides that, there's some issue that the javac command unable to compile, because the given source files list (sourceFiles.lst) has Windows file separator (\).
In that case, javac treats it as flag then raise an error invalid flag: "\".
Once again, this issue only occur on Windows system.

So, I've once again changed the newline character from os.sep (based on operating system) to Unix-based separator (/). See below:

('target_path'): ('/').join(['src', 'main', 'java']),
('class_path'): ('/').join(['target', 'classes']) + '/',
('out_path'): ('/').join(['target', 'generated-list']) + '/',
('source'): ('/').join(['target', 'generated-list', 'sourceFiles.lst']),
('output'): ('/').join(['target', 'generated-list', 'outputFiles.lst'])

And also instead using command based on operating system (that would cause an error when using Git Bash), the command to retrieve the sources and classes files now uses Unix command (which supports Git Bash) both Windows and Unix system.

command = self.__command['unix']['source']
if self.__verbose:
Utils.pr_banner('GENERATING LIST')
Utils.info_msg('Generating list...')
err_code: int = os.system(command)


Also I've encountered some issue with the output message that given by command java -jar "path/to/jmatrix.jar" -V, and this only occurred when using make to build the project (on Windows with MinGW installed).
So here I've fixed it by adding strip() method after retrieving the config on config.xml (the config.xml itself is generated by Python program).

XMLConfig.programName = xml.getElementsByTagName("program_name").item(0).getTextContent().strip();
XMLConfig.author = xml.getElementsByTagName("author").item(0).getTextContent().strip();
XMLConfig.version = xml.getElementsByTagName("version").item(0).getTextContent().strip();
XMLConfig.releaseType = xml.getElementsByTagName("version").item(0)
.getAttributes().getNamedItem("type").getNodeValue().strip();
XMLConfig.packageName = xml.getElementsByTagName("package").item(0).getTextContent().strip();

Summary

All of bugs and issues above only occurred on Windows operating system. And now it has been fixed and tested on Windows 10 with Git Bash as shell environment and MinGW installed.

Note It is recommended to use Git Bash instead Command Prompt or Powershell for shell environment if want to build the project using make (also make sure you've MinGW installed).
Or if you want a simple one, try using Maven. It supports both Command Prompt and Powershell.

The messages always prints the "\n" as text instead of treating it as a newline character on Windows with Git Bash and MinGW installed.
In my device (Linux), it works well and if I'm using `-e` flag it would just prints the flag.

So to make it fair, here I changed the newline with implicit one (print blank message with `echo`). I hope this changes fix the issue.
@mitsuki31 mitsuki31 added the bugfix Fixes some bug or issue label Jun 12, 2023
@mitsuki31 mitsuki31 self-assigned this Jun 12, 2023
Update the message on `cleanbin` rule.
@mitsuki31 mitsuki31 changed the title Fixes the message for MinGW Fixes the Makefile message for MinGW Jun 12, 2023
The `javac` command unable to compile, it because the given source files list (`sourceFiles.lst`) has Windows file separator (`\`).
In that case, `javac` treats it as flag then raise an error `invalid flag: "\"`

Please note, the error commonly occurs on Windows. And the recommended way to build the project is by using `Maven`.
@mitsuki31 mitsuki31 added bug Small bug or issue that need to be fixed documentation Improvements or additions to documentation fatal This error is fatal for future/existing features and removed bug Small bug or issue that need to be fixed documentation Improvements or additions to documentation fatal This error is fatal for future/existing features labels Jun 12, 2023
@mitsuki31 mitsuki31 changed the title Fixes the Makefile message for MinGW Fixes some issue on MinGW (Windows) 🪛 Jun 12, 2023
@mitsuki31 mitsuki31 marked this pull request as ready for review June 12, 2023 15:57
Striping all whitespaces and newlines with `strip()` method after retrieving config from `config.xml`.
@mitsuki31 mitsuki31 merged commit ca88104 into master Jun 13, 2023
@mitsuki31 mitsuki31 deleted the fix-makefile branch June 13, 2023 02:11
@mitsuki31 mitsuki31 added the lang:python Some changes on Python code label Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes some bug or issue lang:python Some changes on Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant