build.bat 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. @echo off
  2. chcp 65001 >nul 2>&1
  3. echo ========================================
  4. echo Network Topology Discovery System - Build Script
  5. echo ========================================
  6. echo.
  7. REM Check if go.mod exists
  8. if not exist go.mod (
  9. echo Error: go.mod not found!
  10. echo Please run this script from the project root directory.
  11. echo.
  12. echo Current directory: %CD%
  13. echo.
  14. pause
  15. exit /b 1
  16. )
  17. echo [1/3] Cleaning old files...
  18. if exist network-topology.exe del network-topology.exe
  19. echo.
  20. echo [2/3] Building program...
  21. set GOOS=windows
  22. set GOARCH=amd64
  23. set CGO_ENABLED=1
  24. set CXX=x86_64-w64-mingw32-g++
  25. go build -o network-topology.exe -ldflags="-s -w" ./cmd
  26. if %ERRORLEVEL% NEQ 0 (
  27. echo.
  28. echo Build failed!
  29. pause
  30. exit /b 1
  31. )
  32. echo.
  33. echo [3/3] Creating config file example...
  34. if not exist config.json (
  35. echo Creating default config file...
  36. echo {> config.json
  37. echo "scan_ranges": ["192.168.1.0/24"],>> config.json
  38. echo "devices": [],>> config.json
  39. echo "ssh": {>> config.json
  40. echo "timeout": 10,>> config.json
  41. echo "max_retries": 3,>> config.json
  42. echo "port": 22>> config.json
  43. echo },>> config.json
  44. echo "web": {>> config.json
  45. echo "port": 8080,>> config.json
  46. echo "host": "0.0.0.0">> config.json
  47. echo },>> config.json
  48. echo "scanner": {>> config.json
  49. echo "concurrency": 10,>> config.json
  50. echo "timeout": 2>> config.json
  51. echo }>> config.json
  52. echo }>> config.json
  53. )
  54. echo.
  55. echo ========================================
  56. echo Build Complete!
  57. echo ========================================
  58. echo.
  59. echo Usage:
  60. echo network-topology.exe (Use default config)
  61. echo network-topology.exe config.json (Use specified config)
  62. echo.
  63. echo Web UI: http://localhost:8080
  64. echo.
  65. pause