forked from exelearning/exelearning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.bat
More file actions
42 lines (36 loc) · 1.37 KB
/
make.bat
File metadata and controls
42 lines (36 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@echo off
setlocal
rem ----------------------------------------------------------------------------
rem This script ensures `make` runs inside Git Bash (or WSL fallback)
rem even if started from cmd.exe or PowerShell.
rem Usage:
rem make.bat <targets and vars> ← from cmd.exe
rem .\make.bat <targets and vars> ← from PowerShell
rem ----------------------------------------------------------------------------
set "PWD_WIN=%CD%"
rem Try Git Bash common paths
set "GITBASH=%ProgramFiles%\Git\bin\bash.exe"
if exist "%GITBASH%" goto run_gitbash
set "GITBASH=%ProgramFiles(x86)%\Git\bin\bash.exe"
if exist "%GITBASH%" goto run_gitbash
rem Try registry
for /f "tokens=2,*" %%A in ('
reg query "HKLM\SOFTWARE\GitForWindows" /v InstallPath 2^>nul ^| find "REG_SZ"
') do set "GITROOT=%%B"
if defined GITROOT set "GITBASH=%GITROOT%\bin\bash.exe"
if exist "%GITBASH%" goto run_gitbash
rem --- Fallback to WSL --------------------------------------------------------
where wsl.exe >nul 2>nul
if %ERRORLEVEL%==0 (
wsl.exe --cd "%PWD_WIN%" bash -lc "export MSYS_NO_PATHCONV=1; make %*"
endlocal
goto :eof
)
echo [ERROR] Neither Git Bash nor WSL found. Install Git for Windows or enable WSL.
endlocal
goto :eof
:run_gitbash
rem Convert cwd to POSIX and run make under Git Bash
"%GITBASH%" -lc "cd \"$(/usr/bin/cygpath -u \"%PWD_WIN%\")\"; export MSYS_NO_PATHCONV=1; make %*"
endlocal
goto :eof