MakeSwig.sh 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. if ! type -P swig &>/dev/null
  2. then
  3. echo "Swig is not installed want this script to download,make, and install it? ( y/n )"
  4. read answer
  5. if [ "$answer" = "n" ] || [ "$answer" = "N" ]
  6. then
  7. echo "Aborting"
  8. exit
  9. fi
  10. if [ ! -d "swig-2.0.0" ]
  11. then
  12. wget http://prdownloads.sourceforge.net/swig/swig-2.0.0.tar.gz
  13. tar xzf swig-2.0.0.tar.gz
  14. cd swig-2.0.0
  15. ./configure
  16. make
  17. echo "Switching to root, enter root password"
  18. su root -c "make install" #Automatically switches back after this command
  19. echo "Exited root"
  20. cd ../
  21. else
  22. cd swig-2.0.0
  23. ./configure
  24. make
  25. echo "Switching to root, enter root password"
  26. su root -c "make install" #Automatically switches back after this command
  27. echo "Exited root"
  28. cd ../
  29. fi
  30. fi
  31. if [ "$1" == "" ]
  32. then
  33. echo "Invalid number of parameters, Usage: MakeSwig.sh directory"
  34. else
  35. echo "Performing Swig build"
  36. rm -f ./SwigOutput/SwigCSharpOutput/*
  37. if [ "$2" == "" ]
  38. then
  39. echo "without SQLiteClientLogger"
  40. swig -c++ -csharp -namespace RakNet -I"$1" -I"SwigInterfaceFiles" -outdir SwigOutput/SwigCSharpOutput -o SwigOutput/CplusDLLIncludes/RakNet_wrap.cxx SwigInterfaceFiles/RakNet.i
  41. swigReturn=$?
  42. else
  43. echo "with SQLiteClientLogger"
  44. swig -c++ -csharp -namespace RakNet -I"$1" -I"SwigInterfaceFiles" -I"$2" -DSWIG_ADDITIONAL_SQL_LITE -outdir SwigOutput/SwigCSharpOutput -o SwigOutput/CplusDLLIncludes/RakNet_wrap.cxx SwigInterfaceFiles/RakNet.i
  45. swigReturn=$?
  46. fi
  47. if [ $swigReturn == 0 ]
  48. then
  49. echo "Swig build complete"
  50. echo "Removing and replacing the sample cs files with fresh ones"
  51. mv ./SwigLinuxCSharpSample/TestMain.cs ./SwigLinuxCSharpSample/TestMain.txt
  52. rm ./SwigLinuxCSharpSample/*.cs
  53. mv ./SwigLinuxCSharpSample/TestMain.txt ./SwigLinuxCSharpSample/TestMain.cs
  54. cp ./SwigOutput/SwigCSharpOutput/*.cs ./SwigLinuxCSharpSample/
  55. echo "Building the Swig Dynamic Link"
  56. savedDir=`pwd`
  57. cd $1
  58. if [ "$2" == "" ]
  59. then
  60. echo "Building without SQLiteClientLogger"
  61. g++ *.cpp ../DependentExtensions/Swig/SwigOutput/CplusDLLIncludes/RakNet_wrap.cxx -l pthread -I./ -shared -o RakNet
  62. gccReturn=$?
  63. else
  64. echo "Building with SQLiteClientLogger"
  65. g++ *.cpp ../DependentExtensions/Swig/SwigOutput/CplusDLLIncludes/RakNet_wrap.cxx "$2/SQLite3ClientPlugin.cpp" "$2/SQLite3PluginCommon.cpp" "$2/Logger/ClientOnly/SQLiteClientLoggerPlugin.cpp" "$2/Logger/SQLiteLoggerCommon.cpp" -l pthread -I./ -I"$2/Logger/ClientOnly" -I"$2/Logger" -I"$2" -shared -o RakNet
  66. gccReturn=$?
  67. fi
  68. if [ $gccReturn == 0 ]
  69. then
  70. echo "Copying to /usr/lib/ will need root password"
  71. if su root -c "cp ./RakNet /usr/lib" #Automatically switches back after this command
  72. then
  73. echo "RakNet lib copied"
  74. else
  75. echo "RakNet lib copy failed"
  76. fi
  77. echo "Exited root"
  78. else
  79. echo "There was an error durion the DLL build"
  80. fi
  81. cd $savedDir
  82. else
  83. echo "Swig had an error during build"
  84. fi
  85. fi
粤ICP备19079148号