标题: [其他] 批处理版gcc编译器 [打印本页]
作者: happy886rr 时间: 2017-5-23 20:17 标题: 批处理版gcc编译器
本帖最后由 happy886rr 于 2017-5-23 20:20 编辑
城通网盘下载:https://page37.ctfile.com/fs/14274637-203903157发个自己写的批处理版gcc编译器,仅有5M大小,对于.c或.cpp后缀的文件,直接拖拽到MinGW.cmd图标上,瞬间编译出exe文件,所编译的exe体积超小,不依赖任何运行库。该工具也是自己的主要开发工具:记事本+批处理gcc。可以开发绝大多数第三方,黑窗口比用IDE更快、更轻便。
演示:用批处理版gcc编译的pdll仅有8KB,且无dll依赖。
脚本代码:- @echo off&color 0f
- ::*********************用户设置********************
- REM 用户指令
- set USER_COMMAND=
-
- ::*********************高级设置********************
- REM 环境变量
- set "PATH=%~dp0MinGW\bin;%PATH%"
- REM 优化参数
- set "OPTIMIZATION_COMMAND=-std=gnu99 -O2 -s"
- set "OPTIMIZATION_COMMAND++=-O2 -s"
- REM 编译器项
- set "COMPILER=gcc.exe"
- set "COMPILER++=g++.exe"
-
- ::*********************后缀筛选********************
- if /i "%~f1"=="" (goto :CMD_CONSOLE )
- if /i "%~x1"==".c" (goto :MINGW32_COMPILER)
- if /i "%~x1"==".cpp" (
- set "COMPILER=%COMPILER++%"
- set "OPTIMIZATION_COMMAND=%OPTIMIZATION_COMMAND++%"
- goto :MINGW32_COMPILER
- )
- set/p=Error: 非.c或.cpp后缀文件
- exit /b
-
- MINGW32_COMPILER()
- {
- :MINGW32_COMPILER
- pushd "%~dp1"
- echo ================================================================================
- echo Mingw32 compiler 编译器
- echo ================================================================================
- echo 编译...
- %COMPILER% "%~nx1" %OPTIMIZATION_COMMAND% %USER_COMMAND% -o "%~n1.exe"
- echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- echo 运行...
- if exist "%~n1.exe" ("%~n1.exe")
- echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- echo 结束.
- pause>NUL
- exit /b
- }
-
- CMD_CONSOLE()
- {
- :CMD_CONSOLE
- echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- echo [GCC console]
- set/p PCOMMANDLINE=^>
- %PCOMMANDLINE%
- echo;
- goto :CMD_CONSOLE
- }
复制代码
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |