Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- chcp 65001>nul
- title [%~n1]MSYS2-Mingw64_Compiler
- setlocal enabledelayedexpansion
- if "%1"=="" goto generate
- set x=%~x1
- set xo=0
- if "%x%"==".c" set xo=1
- if "%x%"==".cpp" set xo=1
- if "%x%"==".ybp" set xo=1
- if %xo%==0 echo C(.c) もしくは C++(.cpp) もしくは Build_Profile(.ybp) ではありません&pause&exit /b
- if "%x%"==".ybp" goto ybp
- set exename=%~n1
- set original=nooption
- set "addlibrary= "
- set /p original=独自オプション:
- set /p exename=実行ファイル名(拡張子除く):
- set /p addlibrary=追加するライブラリ(各ファイル名の前に-lを追加):
- set /p option=オプション:
- goto noybp
- :ybp
- set line=0
- for /f "delims=" %%a in (%1) do (
- set /a line=!line!+1
- if !line!==1 set exename=%%a
- if !line!==2 set addlibrary=%%a
- if !line!==3 set option=%%a
- if !line!==4 set original=%%a
- )
- if "%addlibrary%"=="nul" set "addlibrary="
- if "%option%"=="nul" set "option="
- :noybp
- if not "%addlibrary:qt=%"=="%addlibrary%" set "addlibrary=-lQt6Core -lQt6Widgets -lQt6Gui"
- if "%original:nocp932=%"=="%original%" set "cp932=-fexec-charset^=cp932"
- if not "%original:qt=%"=="%original%" (
- set "addlibrary=-lQt6Core -lQt6Widgets -lQt6Gui"
- c:\msys64\mingw64\share\qt6\bin\moc.exe %1 -o %~dp1_.moc
- set mocfile=%~dp1_.moc
- )
- :loop
- echo LOADING
- echo CC = g++>_.mk
- echo CFLAGS = %option%>>_.mk
- echo TARGET = %exename%.exe>>_.mk
- echo SRCS = %~n1.cpp %mocfile:\=/%>>_.mk
- echo OBJS = %~n1.o>>_.mk
- echo INCDIR = -Ic:/msys64/mingw64/include>>_.mk
- echo LIBDIR = -Lc:/msys64/mingw64/lib>>_.mk
- echo LIBS = %addlibrary%>>_.mk
- echo $(TARGET): $(OBJS)>>_.mk
- echo $(CC) -o $@ $^^ $(LIBDIR) $(LIBS)>>_.mk
- echo %%.o: %%.cpp>>_.mk
- echo $(CC) %cp932% $(CFLAGS) $(INCDIR) -c $^< -o $@>>_.mk
- set _=%~dp1
- set _=%_:\=/%
- set temp_=%temp:\=/%
- cd %_:~0,-1%
- c:\GnuWin32\bin\make.exe -B -f %_:~0,-1%/_.mk
- del "%~n1.o"
- pause
- for /l %%a in (1,1,10) do echo.
- goto loop
- :generate
- echo ファイルを%0にドラッグ^&ドロップされなかったのでBuild_Profileを作成モードで起動します
- set /p codename=ソースコードファイル名(拡張子除く):
- set exename=%codename%
- set addlibrary=nul
- set option=nul
- set /p exename=実行ファイル名(拡張子除く):
- set /p addlibrary=追加するライブラリ(各ファイル名の前に-lを追加):
- set /p option=追加オプション:
- set /p original=独自オプション:
- echo %exename%>%codename%.ybp
- echo %addlibrary%>>%codename%.ybp
- echo %option%>>%codename%.ybp
- echo %original%>>%codename%.ybp
- exit /b
Advertisement
Advertisement