Question

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.

Was it helpful?

Solution

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"

OTHER TIPS

You don't have to use bash to execute make, or any of the other MSYS programs. If you put the MSYS bin directory on your path, you can execute them from a Windows command shell. Alternatively, the bash shell has an enormously powerful scripting language built in. But I'm not clear if that's what you are asking about - you should clarify your question with an actual example of what you want to do, spelling out the steps you want automated.

My own setup is to have a Windows Explorer context menu called "Bash here" which opens a bash shell in the directory I select. This is done via the following registry entries:

[HKEY_CLASSES_ROOT\Directory\shell\mybash]
@="Bash Here"

[HKEY_CLASSES_ROOT\Directory\shell\mybash\command]
@="cmd /c c:\\bash.cmd %1"

And the following bash.cmd file in c::

@echo off
title bash
cd %1%
bash

Note that the MSYS bin directory is on my path. And of course, any registry hacking is at your own risk.

On my MSYS-1.0.11 with the MSYS developers packages, I can call a bash script (CurrentScript.sh) with a cmd/bat file in the current folder with this command:

R:\MinGW\MSYS-1.0.11\bin\sh "%cd%\CurrentScript.sh"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top