Browse Source

Automate setup of Urho3D documentation integration for Eclipse IDE.
[ci skip]

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
af23b5075e
1 changed files with 69 additions and 64 deletions
  1. 69 64
      .bash_helpers.sh

+ 69 - 64
.bash_helpers.sh

@@ -26,80 +26,85 @@ msg() {
 }
 
 post_cmake() {
-    # Check if xmlstarlet software package is available for fixing the generated Eclipse project setting
-    if [ $HAS_XMLSTARLET ]; then
-        # Common fixes for all builds
-        #
-        # Remove build type from project name
-        # Replace deprecated GNU gmake Error Parser with newer version (6.0 -> 7.0) and add GCC Error Parser
-        #
-        xmlstarlet ed -P -L \
-            -u "/projectDescription/name/text()" -x "concat(substring-before(., '-Release'), substring-before(., '-Debug'), substring-before(., '-RelWithDebInfo'))" \
-            -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'))" \
-            $1/.project
-
-        # Build-specific fixes
-        if [ $1 == "android-Build" ]; then
-            # For Android build, add the Android and Java nature to the project setting as it would be done by Eclipse during project import
-            # This fix avoids the step to reimport the project everytime the Eclipse project setting is regenerated by cmake_gcc.sh invocation
-            echo -- Add Android and Java nature to Eclipse project setting files in $( pwd )/$1
+    if [ $GENERATOR == "Eclipse CDT4 - Unix Makefiles" ]; then
+        # Integrate Urho3D documentation into Eclipse IDE
+        ln -snf $(pwd)/Docs/html ~/.eclipse/$(ls -1t ~/.eclipse |grep org.eclipse.platform_ |head -1)/plugins
 
+        # Check if xmlstarlet software package is available for fixing the generated Eclipse project setting
+        if [ $HAS_XMLSTARLET ]; then
+            # Common fixes for all builds
             #
-            # Add natures (Android nature must be inserted as first nature)
+            # Remove build type from project name
+            # Replace deprecated GNU gmake Error Parser with newer version (6.0 -> 7.0) and add GCC Error Parser
             #
             xmlstarlet ed -P -L \
-                -i "/projectDescription/natures/nature[1]" -t elem -n nature -v "com.android.ide.eclipse.adt.AndroidNature" \
-                -s "/projectDescription/natures" -t elem -n nature -v "org.eclipse.jdt.core.javanature" \
+                -u "/projectDescription/name/text()" -x "concat(substring-before(., '-Release'), substring-before(., '-Debug'), substring-before(., '-RelWithDebInfo'))" \
+                -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'))" \
                 $1/.project
-            #
-            # Add build commands
-            #
-            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
+
+            # Build-specific fixes
+            if [ $1 == "android-Build" ]; then
+                # For Android build, add the Android and Java nature to the project setting as it would be done by Eclipse during project import
+                # This fix avoids the step to reimport the project everytime the Eclipse project setting is regenerated by cmake_gcc.sh invocation
+                echo -- Add Android and Java nature to Eclipse project setting files in $( pwd )/$1
+
+                #
+                # Add natures (Android nature must be inserted as first nature)
+                #
                 xmlstarlet ed -P -L \
-                    -s "/projectDescription/buildSpec" -t elem -n buildCommandNew -v "" \
-                    -s "/projectDescription/buildSpec/buildCommandNew" -t elem -n name -v $c \
-                    -s "/projectDescription/buildSpec/buildCommandNew" -t elem -n arguments -v "" \
-                    -r "/projectDescription/buildSpec/buildCommandNew" -v "buildCommand" \
+                    -i "/projectDescription/natures/nature[1]" -t elem -n nature -v "com.android.ide.eclipse.adt.AndroidNature" \
+                    -s "/projectDescription/natures" -t elem -n nature -v "org.eclipse.jdt.core.javanature" \
                     $1/.project
-            done
+                #
+                # Add build commands
+                #
+                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
+                    xmlstarlet ed -P -L \
+                        -s "/projectDescription/buildSpec" -t elem -n buildCommandNew -v "" \
+                        -s "/projectDescription/buildSpec/buildCommandNew" -t elem -n name -v $c \
+                        -s "/projectDescription/buildSpec/buildCommandNew" -t elem -n arguments -v "" \
+                        -r "/projectDescription/buildSpec/buildCommandNew" -v "buildCommand" \
+                        $1/.project
+                done
 
-        elif [ $1 == "raspi-Build" ]; then
-            # For Raspberry Pi build, add [Bin-CC] linked resource
-            #
-            # Replace [Subprojects]/Urho3D linked resource to [Targets]/[Bin-CC] instead
-            #
-            xmlstarlet ed -P -L \
-                -u "/projectDescription/linkedResources/link/name/text()[. = '[Subprojects]/Urho3D']" -v "[Targets]/[Bin-CC]" \
-                -u "/projectDescription/linkedResources/link/location[../name/text() = '[Targets]/[Bin-CC]']" -v "$( pwd )/Bin-CC" \
-                $1/.project
+            elif [ $1 == "raspi-Build" ]; then
+                # For Raspberry Pi build, add [Bin-CC] linked resource
+                #
+                # Replace [Subprojects]/Urho3D linked resource to [Targets]/[Bin-CC] instead
+                #
+                xmlstarlet ed -P -L \
+                    -u "/projectDescription/linkedResources/link/name/text()[. = '[Subprojects]/Urho3D']" -v "[Targets]/[Bin-CC]" \
+                    -u "/projectDescription/linkedResources/link/location[../name/text() = '[Targets]/[Bin-CC]']" -v "$( pwd )/Bin-CC" \
+                    $1/.project
 
-        else
-            # For native build, move the Eclipse project setting files back to Source folder to fix source code versioning
-            echo -- Eclipse project setting files have been relocated to: $( pwd )/Source
-            for f in .project .cproject; do mv $1/$f Source; done
+            else
+                # For native build, move the Eclipse project setting files back to Source folder to fix source code versioning
+                echo -- Eclipse project setting files have been relocated to: $( pwd )/Source
+                for f in .project .cproject; do mv $1/$f Source; done
 
-            #
-            # Replace [Source directory] linked resource to [Build] instead
-            # Modify build argument to first change directory to Build folder
-            # Replace [Subprojects]/Urho3D linked resource to [Build]/[Bin] instead
-            #
-            xmlstarlet ed -P -L \
-                -u "/projectDescription/linkedResources/link/name/text()[. = '[Source directory]']" -v "[Build]" \
-                -u "/projectDescription/linkedResources/link/location[../name/text() = '[Build]']" -v "$( pwd )/$1" \
-                -u "/projectDescription/buildSpec/buildCommand/arguments/dictionary/value[../key/text() = 'org.eclipse.cdt.make.core.build.arguments']" -x "concat('-C ../$1 ', .)" \
-                -u "/projectDescription/linkedResources/link/name/text()[. = '[Subprojects]/Urho3D']" -v "[Build]/[Bin]" \
-                -u "/projectDescription/linkedResources/link/location[../name/text() = '[Build]/[Bin]']" -v "$( pwd )/Bin" \
-                Source/.project
-            #
-            # Fix source path entry to Source folder and modify its filter condition
-            # Fix output path entry to [Build] linked resource and modify its filter condition
-            #
-            xmlstarlet ed -P -L \
-                -u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'src']/@path" -v "" \
-                -s "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'src']" -t attr -n "excluding" -v "[Subprojects]/|[Targets]/" \
-                -u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'out']/@path" -v "[Build]" \
-                -u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'out']/@excluding" -x "substring-after(., '[Source directory]/|')" \
-                Source/.cproject
+                #
+                # Replace [Source directory] linked resource to [Build] instead
+                # Modify build argument to first change directory to Build folder
+                # Replace [Subprojects]/Urho3D linked resource to [Build]/[Bin] instead
+                #
+                xmlstarlet ed -P -L \
+                    -u "/projectDescription/linkedResources/link/name/text()[. = '[Source directory]']" -v "[Build]" \
+                    -u "/projectDescription/linkedResources/link/location[../name/text() = '[Build]']" -v "$( pwd )/$1" \
+                    -u "/projectDescription/buildSpec/buildCommand/arguments/dictionary/value[../key/text() = 'org.eclipse.cdt.make.core.build.arguments']" -x "concat('-C ../$1 ', .)" \
+                    -u "/projectDescription/linkedResources/link/name/text()[. = '[Subprojects]/Urho3D']" -v "[Build]/[Bin]" \
+                    -u "/projectDescription/linkedResources/link/location[../name/text() = '[Build]/[Bin]']" -v "$( pwd )/Bin" \
+                    Source/.project
+                #
+                # Fix source path entry to Source folder and modify its filter condition
+                # Fix output path entry to [Build] linked resource and modify its filter condition
+                #
+                xmlstarlet ed -P -L \
+                    -u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'src']/@path" -v "" \
+                    -s "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'src']" -t attr -n "excluding" -v "[Subprojects]/|[Targets]/" \
+                    -u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'out']/@path" -v "[Build]" \
+                    -u "/cproject/storageModule/cconfiguration/storageModule/pathentry[@kind = 'out']/@excluding" -x "substring-after(., '[Source directory]/|')" \
+                    Source/.cproject
+            fi
         fi
     fi
 }