SEMS-data-collection/run.bat

100 lines
2.3 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
@REM @REM 检查环境变量
call:check_path
@REM 判断第一个参数是否为rb
if "%1"=="rb" (
@REM 判断是否存在build文件夹若存在就删除
call:remove_build_dir
@REM 编译生成Makefile
cmake -B build -G "MinGW Makefiles"
@REM 编译生成可执行程序
cmake --build build
@REM 判断第二个参数是否为e如果有代表要执行编译好的可执行程序
if "%2"=="e" (
call:run_build_exe
)
)
@REM run.bat b : Build 编译适用于已生成过Makefile且CMakeLists.txt没有变化仅仅需要重新编译生成exe文件
@REM run.bat b e : Build Execute 从头编译并执行
@REM 判断第一个参数是否为rb
if "%1"=="b" (
@REM 编译生成可执行程序
cmake --build build
@REM 判断第二个参数是否为e如果有代表要执行编译好的可执行程序
if "%2"=="e" (
call:run_build_exe
)
)
@REM run.bat e : Execute 运行可执行文件
if "%1"=="e" (
call:run_build_exe
)
@REM run.bat c : Clear 清理Build文件夹
if "%1"=="c" (
call:remove_build_dir
)
@REM run.bat e : 打包
if "%1"=="p" (
@REM 判断环境变量中是否存在编译所需要的文件夹,如果没有,就添加到环境变量
@REM 编译生成Makefile
cmake -B build -G "MinGW Makefiles"
@REM 编译生成可执行程序
cmake --build build
@REM 打包为安装包
cmake --build build --target package
)
@REM 在执行完过程后加上goto :eof跳到文件尾, 避免执行到文件结束才返回
goto :eof
:check_path
@REM 判断环境变量中是否存在编译所需要的文件夹,如果没有,就添加到环境变量
set Nowdir=%cd%
cd ../CompliteEnv
call set_temp_env.bat
cd %Nowdir%
set PATH=C:\Program Files\Common Files\Pleora\eBUS SDK;%cd%\lib;%PATH%
echo PATH is seted to %PATH%
goto:eof
:run_build_exe
echo Starting to run EXE files in build folder...
@REM 遍历build下的exe文件并一个一个的执行其实编译后只有一个可执行文件
for /f %%i in ('dir /b build\*.exe') do .\build\%%i
echo Stoped runing EXE files...
goto:eof
:remove_build_dir
if exist build (
rd /s /Q build
echo "The build folder has been removed."
) else (
echo "The build folder does not exist."
)
goto:eof