.bash_helpers.sh 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #
  2. # Copyright (c) 2008-2014 the Urho3D project.
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. #
  22. # Define helpers
  23. msg() {
  24. echo -e "\n$1\n================================================================================"
  25. }
  26. post_cmake() {
  27. if [ $GENERATOR == "Eclipse CDT4 - Unix Makefiles" ]; then
  28. # Integrate Urho3D documentation into Eclipse IDE
  29. ln -snf $(pwd)/Docs/html ~/.eclipse/$(ls -1t ~/.eclipse |grep org.eclipse.platform_ |head -1)/plugins
  30. # Check if xmlstarlet software package is available for fixing the generated Eclipse project setting
  31. if [ $HAS_XMLSTARLET ]; then
  32. # Common fixes for all builds
  33. #
  34. # Remove build type from project name
  35. # Replace deprecated GNU gmake Error Parser with newer version (6.0 -> 7.0) and add GCC Error Parser
  36. #
  37. xmlstarlet ed -P -L \
  38. -u "/projectDescription/name/text()" -x "concat(substring-before(., '-Release'), substring-before(., '-Debug'), substring-before(., '-RelWithDebInfo'))" \
  39. -u "/projectDescription/buildSpec/buildCommand/arguments/dictionary/value[../key/text() = 'org.eclipse.cdt.core.errorOutputParser']" -x "concat('org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;', substring-after(., 'org.eclipse.cdt.core.MakeErrorParser'))" \
  40. $1/.project
  41. # Build-specific fixes
  42. if [ $1 == "android-Build" ]; then
  43. # For Android build, add the Android and Java nature to the project setting as it would be done by Eclipse during project import
  44. # This fix avoids the step to reimport the project everytime the Eclipse project setting is regenerated by cmake_gcc.sh invocation
  45. echo -- Add Android and Java nature to Eclipse project setting files in $( pwd )/$1
  46. #
  47. # Add natures (Android nature must be inserted as first nature)
  48. #
  49. xmlstarlet ed -P -L \
  50. -i "/projectDescription/natures/nature[1]" -t elem -n nature -v "com.android.ide.eclipse.adt.AndroidNature" \
  51. -s "/projectDescription/natures" -t elem -n nature -v "org.eclipse.jdt.core.javanature" \
  52. $1/.project
  53. #
  54. # Add build commands
  55. #
  56. for c in com.android.ide.eclipse.adt.ResourceManagerBuilder com.android.ide.eclipse.adt.PreCompilerBuilder org.eclipse.jdt.core.javabuilder com.android.ide.eclipse.adt.ApkBuilder; do
  57. xmlstarlet ed -P -L \
  58. -s "/projectDescription/buildSpec" -t elem -n buildCommandNew -v "" \
  59. -s "/projectDescription/buildSpec/buildCommandNew" -t elem -n name -v $c \
  60. -s "/projectDescription/buildSpec/buildCommandNew" -t elem -n arguments -v "" \
  61. -r "/projectDescription/buildSpec/buildCommandNew" -v "buildCommand" \
  62. $1/.project
  63. done
  64. elif [ $1 == "raspi-Build" ]; then
  65. # For Raspberry Pi build, add [Bin-CC] linked resource
  66. #
  67. # Replace [Subprojects]/Urho3D linked resource to [Targets]/[Bin-CC] instead
  68. #
  69. xmlstarlet ed -P -L \
  70. -u "/projectDescription/linkedResources/link/name/text()[. = '[Subprojects]/Urho3D']" -v "[Targets]/[Bin-CC]" \
  71. -u "/projectDescription/linkedResources/link/location[../name/text() = '[Targets]/[Bin-CC]']" -v "$( pwd )/Bin-CC" \
  72. $1/.project
  73. else
  74. # For native build, move the Eclipse project setting files back to Source folder to fix source code versioning
  75. echo -- Eclipse project setting files have been relocated to: $( pwd )/Source
  76. for f in .project .cproject; do mv $1/$f Source; done
  77. #
  78. # Replace [Source directory] linked resource to [Build] instead
  79. # Modify build argument to first change directory to Build folder
  80. # Replace [Subprojects]/Urho3D linked resource to [Build]/[Bin] instead
  81. #
  82. xmlstarlet ed -P -L \
  83. -u "/projectDescription/linkedResources/link/name/text()[. = '[Source directory]']" -v "[Build]" \
  84. -u "/projectDescription/linkedResources/link/location[../name/text() = '[Build]']" -v "$( pwd )/$1" \
  85. -u "/projectDescription/buildSpec/buildCommand/arguments/dictionary/value[../key/text() = 'org.eclipse.cdt.make.core.build.arguments']" -x "concat('-C ../$1 ', .)" \
  86. -u "/projectDescription/linkedResources/link/name/text()[. = '[Subprojects]/Urho3D']" -v "[Build]/[Bin]" \
  87. -u "/projectDescription/linkedResources/link/location[../name/text() = '[Build]/[Bin]']" -v "$( pwd )/Bin" \
  88. Source/.project
  89. #
  90. # Fix source path entry to Source folder and modify its filter condition
  91. # Fix output path entry to [Build] linked resource and modify its filter condition
  92. #
  93. xmlstarlet ed -P -L \
  94. -u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'src']/@path" -v "" \
  95. -s "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'src']" -t attr -n "excluding" -v "[Subprojects]/|[Targets]/" \
  96. -u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'out']/@path" -v "[Build]" \
  97. -u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'out']/@excluding" -x "substring-after(., '[Source directory]/|')" \
  98. Source/.cproject
  99. fi
  100. fi
  101. fi
  102. }
  103. # vi: set ts=4 sw=4 expandtab: