添加项目文件。
This commit is contained in:
+70
@@ -0,0 +1,70 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions
|
||||
rem ===========================================================================
|
||||
rem 用 MinGW (g++) 编译 ARIS 桥接 DLL:aris_bridge.dll
|
||||
rem
|
||||
rem 为什么要它:
|
||||
rem 厂商的 libaris.dll 是 GCC 编的 C++ 库(GCC 名字修饰 + std::string/vector
|
||||
rem 接口 + 要求继承 SpectrometerCallback),MSVC 程序无法直接调用。
|
||||
rem 本脚本把它包成纯 C 接口(见 src\aris_bridge.h),MSVC 主程序用
|
||||
rem LoadLibrary 调用即可。
|
||||
rem
|
||||
rem 依赖:Strawberry Perl 自带的 MinGW g++ 8.3(本机已具备)
|
||||
rem third_party\aris-bridge\vendor\libaris.dll(厂商原件)
|
||||
rem third_party\aris\include(SDK 头文件)
|
||||
rem third_party\libusb-1.0\include(libusb 头文件)
|
||||
rem
|
||||
rem 产物:third_party\aris-bridge\bin\aris_bridge.dll
|
||||
rem third_party\aris-bridge\lib\libaris.a(libaris.dll 的导入库)
|
||||
rem ===========================================================================
|
||||
|
||||
set "GPP=C:\Strawberry\c\bin\g++.exe"
|
||||
set "GENDEF=C:\Strawberry\c\bin\gendef.exe"
|
||||
set "DLLTOOL=C:\Strawberry\c\bin\dlltool.exe"
|
||||
|
||||
rem 工程根目录 = 本脚本所在目录的上一级的上一级
|
||||
pushd "%~dp0..\.."
|
||||
set "ROOT=%CD%"
|
||||
popd
|
||||
|
||||
set "BRIDGE=%ROOT%\third_party\aris-bridge"
|
||||
set "SRC=%BRIDGE%\src"
|
||||
set "OUT=%BRIDGE%\bin"
|
||||
set "IMPLIB=%BRIDGE%\lib"
|
||||
set "VENDOR=%BRIDGE%\vendor\libaris.dll"
|
||||
|
||||
if not exist "%GPP%" (
|
||||
echo [ERR] 找不到 MinGW g++: %GPP%
|
||||
echo 本机可用 Strawberry Perl 自带的 g++,或安装 MinGW-w64 后修改本脚本。
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%VENDOR%" (
|
||||
echo [ERR] 找不到厂商库: %VENDOR%
|
||||
echo 请把厂商提供的 libaris.dll 放到 third_party\aris-bridge\vendor\
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%SRC%\aris_bridge.cpp" (
|
||||
echo [ERR] 找不到桥接源码: %SRC%\aris_bridge.cpp
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "%OUT%" mkdir "%OUT%"
|
||||
if not exist "%IMPLIB%" mkdir "%IMPLIB%"
|
||||
|
||||
echo === 1/3 生成导入库 libaris.a ===
|
||||
pushd "%IMPLIB%"
|
||||
"%GENDEF%" "%VENDOR%" >nul
|
||||
if errorlevel 1 (echo [ERR] gendef 失败 & popd & exit /b 1)
|
||||
"%DLLTOOL%" -d libaris.def -l libaris.a -D libaris.dll
|
||||
if errorlevel 1 (echo [ERR] dlltool 失败 & popd & exit /b 1)
|
||||
popd
|
||||
|
||||
echo === 2/3 编译 aris_bridge.dll ===
|
||||
"%GPP%" -std=c++17 -O2 -shared -o "%OUT%\aris_bridge.dll" ^
|
||||
"%SRC%\aris_bridge.cpp" "%IMPLIB%\libaris.a" ^
|
||||
-I"%SRC%" -I"%ROOT%\third_party\aris\include" -I"%ROOT%\third_party\libusb-1.0\include"
|
||||
if errorlevel 1 (echo [ERR] 编译失败 & exit /b 1)
|
||||
|
||||
echo === 3/3 完成 ===
|
||||
dir /b "%OUT%"
|
||||
exit /b 0
|
||||
Reference in New Issue
Block a user