-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
87 lines (73 loc) · 2.06 KB
/
Copy pathbuild.bat
File metadata and controls
87 lines (73 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@echo off
REM T2-Cap构建脚本 - Windows版本
echo ========================================
echo T2-Cap Agent Build Script
echo ========================================
REM 设置变量
set BUILD_DIR=build
set NATIVE_DIR=src\native
REM 检查Maven
where mvn >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Maven not found in PATH
exit /b 1
)
REM 检查CMake
where cmake >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
echo [WARNING] CMake not found, skipping native build
set SKIP_NATIVE=1
) else (
set SKIP_NATIVE=0
)
REM 清理旧的构建
echo [STEP 1] Cleaning old builds...
if exist target rmdir /s /q target
if exist %NATIVE_DIR%\%BUILD_DIR% rmdir /s /q %NATIVE_DIR%\%BUILD_DIR%
REM 编译Native库
if %SKIP_NATIVE% EQU 0 (
echo [STEP 2] Building native library...
cd %NATIVE_DIR%
mkdir %BUILD_DIR%
cd %BUILD_DIR%
cmake -G "Visual Studio 16 2019" -A x64 ..
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] CMake configuration failed
cd ..\..\..
exit /b 1
)
cmake --build . --config Release
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Native build failed
cd ..\..\..
exit /b 1
)
cd ..\..\..
REM 复制生成的DLL到资源目录
if not exist src\main\resources\native mkdir src\main\resources\native
copy %NATIVE_DIR%\%BUILD_DIR%\Release\t2core.dll src\main\resources\native\
echo [INFO] Native library built successfully
) else (
echo [INFO] Skipping native build
)
REM 编译Java代码
echo [STEP 3] Building Java Agent...
call mvn clean package -DskipTests
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Maven build failed
exit /b 1
)
REM 显示构建结果
echo.
echo ========================================
echo Build Complete!
echo ========================================
echo Agent JAR: target\jvm-t2-agent-1.0.0-SNAPSHOT.jar
if %SKIP_NATIVE% EQU 0 (
echo Native DLL: src\main\resources\native\t2core.dll
)
echo.
echo Usage:
echo java -javaagent:target\jvm-t2-agent-1.0.0-SNAPSHOT.jar YourApp
echo ========================================
exit /b 0