Advertisement
yy981

MSYS2 Mingw64 Compiler Auxiliary

Dec 22nd, 2023
1,683
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. chcp 65001>nul
  3. title [%~n1]MSYS2-Mingw64_Compiler
  4.  
  5. setlocal enabledelayedexpansion
  6. if "%1"=="" goto generate
  7. set x=%~x1
  8. set xo=0
  9. if "%x%"==".c" set xo=1
  10. if "%x%"==".cpp" set xo=1
  11. if "%x%"==".ybp" set xo=1
  12. if %xo%==0 echo C(.c) もしくは C++(.cpp) もしくは Build_Profile(.ybp) ではありません&pause&exit /b
  13. if "%x%"==".ybp" goto ybp
  14.  
  15. set exename=%~n1
  16. set original=nooption
  17. set "addlibrary= "
  18. set /p original=独自オプション:
  19. set /p exename=実行ファイル名(拡張子除く):
  20. set /p addlibrary=追加するライブラリ(各ファイル名の前に-lを追加):
  21. set /p option=オプション:
  22. goto noybp
  23.  
  24. :ybp
  25. set line=0
  26. for /f "delims=" %%a in (%1) do (
  27. set /a line=!line!+1
  28. if !line!==1 set exename=%%a
  29. if !line!==2 set addlibrary=%%a
  30. if !line!==3 set option=%%a
  31. if !line!==4 set original=%%a
  32. )
  33.  
  34. if "%addlibrary%"=="nul" set "addlibrary="
  35. if "%option%"=="nul" set "option="
  36.  
  37. :noybp
  38.  
  39. if not "%addlibrary:qt=%"=="%addlibrary%" set "addlibrary=-lQt6Core -lQt6Widgets -lQt6Gui"
  40. if "%original:nocp932=%"=="%original%" set "cp932=-fexec-charset^=cp932"
  41. if not "%original:qt=%"=="%original%" (
  42. set "addlibrary=-lQt6Core -lQt6Widgets -lQt6Gui"
  43. c:\msys64\mingw64\share\qt6\bin\moc.exe %1 -o %~dp1_.moc
  44. set mocfile=%~dp1_.moc
  45. )
  46.  
  47. :loop
  48.  
  49. echo LOADING
  50.  
  51. echo CC  = g++>_.mk
  52. echo CFLAGS  = %option%>>_.mk
  53. echo TARGET  = %exename%.exe>>_.mk
  54. echo SRCS    = %~n1.cpp %mocfile:\=/%>>_.mk
  55. echo OBJS    = %~n1.o>>_.mk
  56. echo INCDIR  = -Ic:/msys64/mingw64/include>>_.mk
  57. echo LIBDIR  = -Lc:/msys64/mingw64/lib>>_.mk
  58. echo LIBS    = %addlibrary%>>_.mk
  59. echo $(TARGET): $(OBJS)>>_.mk
  60. echo    $(CC) -o $@ $^^ $(LIBDIR) $(LIBS)>>_.mk
  61. echo %%.o: %%.cpp>>_.mk
  62. echo    $(CC)  %cp932% $(CFLAGS) $(INCDIR) -c $^< -o $@>>_.mk
  63.  
  64. set _=%~dp1
  65. set _=%_:\=/%
  66. set temp_=%temp:\=/%
  67.  
  68. cd %_:~0,-1%
  69. c:\GnuWin32\bin\make.exe -B -f %_:~0,-1%/_.mk
  70. del "%~n1.o"
  71. pause
  72. for /l %%a in (1,1,10) do echo.
  73. goto loop
  74.  
  75. :generate
  76. echo ファイルを%0にドラッグ^&ドロップされなかったのでBuild_Profileを作成モードで起動します
  77.  
  78. set /p codename=ソースコードファイル名(拡張子除く):
  79. set exename=%codename%
  80. set addlibrary=nul
  81. set option=nul
  82. set /p exename=実行ファイル名(拡張子除く):
  83. set /p addlibrary=追加するライブラリ(各ファイル名の前に-lを追加):
  84. set /p option=追加オプション:
  85. set /p original=独自オプション:
  86. echo %exename%>%codename%.ybp
  87. echo %addlibrary%>>%codename%.ybp
  88. echo %option%>>%codename%.ybp
  89. echo %original%>>%codename%.ybp
  90. exit /b
  91.  
Advertisement
Comments
  • yy981
    1 year
    Comment was deleted
  • yy981
    1 year
    Comment was deleted
Add Comment
Please, Sign In to add comment
Advertisement