Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoking MSYS bash from Windows cmd

I'm using GCC on Windows 7 (using the TDM's build). I installed MSYS to be able to execute Make and compile using makefiles. However, it is tedious to every time start up the MSYS Bash shell, navigate to the directory of the project and run make.

What I want is to automate this process. I prefer to have a batch file in Windows, or something similar, from which I then invoke the MSYS Bash shell. It should navigate to the directory the batch file resides in and call make.

Is this possible? Can I send commands to MSYS Bash from cmd (like navigation/invoking make)? Or can I let the MSYS Bash run a "Bash script", which sets the commands to be executed much like batch scripts?

PS: This is something similar to Stack Overflow question Executing MSYS from cmd.exe with arguments.

like image 594
Taco de Wolff Avatar asked May 02 '10 09:05

Taco de Wolff


People also ask

How do I run a bash command in Windows?

Execute Shell Script Files Open Command Prompt and navigate to the folder where the script file is available. Type Bash script-filename.sh and hit the enter key. It will execute the script, and depending on the file, you should see an output.

What is Msys shell?

MSYS is an application that gives the user a Bourne shell that can run configure scripts and Makefiles. No compilers come with MSYS. In the Cygwin, MinGW, and MSYS hierarchy, it is at the bottom the food chain in terms of tools provided. However, it is very easy to use and build the OS project with MSYS.


2 Answers

Just add executables to your Windows PATH:

C:\msys64\mingw64\bin
C:\msys64\usr\bin

Keep in mind, this adds a lot of executables to your path which might conflict with other applications. The ..\usr\bin directory contains all installed MSYS2 packages. There is a lot of unnecessary stuff. ..mingw64\bin directory has a smaller list.

Source

like image 169
Dmitry Avatar answered Oct 05 '22 13:10

Dmitry


Not an MSYS expert, but does something like this work for you:

rem Call this something like compile-project.bat
c:
cd \src\project
bash -c "make"
like image 41
clstrfsck Avatar answered Oct 05 '22 13:10

clstrfsck