[ooo-build-commit] ooeclipse: Branch 'master'

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Thu Sep 10 13:02:21 PDT 2009


 core/source/org/openoffice/ide/eclipse/core/builders/RegmergeBuilder.java   |    5 
 core/source/org/openoffice/ide/eclipse/core/internal/model/AbstractOOo.java |    9 
 core/source/org/openoffice/ide/eclipse/core/internal/model/SDK.java         |   16 
 core/source/org/openoffice/ide/eclipse/core/model/config/ISdk.java          |   12 
 cpp/icons/uno_client.png                                                    |binary
 cpp/icons/uno_client_wiz.png                                                |binary
 cpp/plugin.xml                                                              |    4 
 cpp/source/org/openoffice/ide/eclipse/cpp/CDTHelper.java                    |   89 ++++
 cpp/source/org/openoffice/ide/eclipse/cpp/CppBuilder.java                   |    4 
 cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java            |  116 +----
 cpp/source/org/openoffice/ide/eclipse/cpp/OOoSdkProjectJob.java             |  200 ++++++++++
 cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java          |    7 
 cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx             |    4 
 dev/null                                                                    |binary
 14 files changed, 358 insertions(+), 108 deletions(-)

New commits:
commit cca671e9eb8009bbbf63ecefb7d420c45097f538
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Thu Sep 10 22:01:57 2009 +0200

    Cpp: the OOo includes and libs links in a project
    
    In order to factorize the includes and libraries links of OOo, an SDK
    project is created for each used OOo instance (for Cpp only).

diff --git a/core/source/org/openoffice/ide/eclipse/core/builders/RegmergeBuilder.java b/core/source/org/openoffice/ide/eclipse/core/builders/RegmergeBuilder.java
index ee5090a..61c95c9 100755
--- a/core/source/org/openoffice/ide/eclipse/core/builders/RegmergeBuilder.java
+++ b/core/source/org/openoffice/ide/eclipse/core/builders/RegmergeBuilder.java
@@ -132,7 +132,10 @@ public class RegmergeBuilder {
             }
             sPathValue += sPath;
         }
-        Process process = pUnoprj.getSdk().runToolWithEnv(pUnoprj, command, new String[]{ sPathValue }, pMonitor);
+        
+        IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( pUnoprj.getName() );
+        Process process = pUnoprj.getSdk().runToolWithEnv( prj, 
+                pUnoprj.getOOo(), command, new String[]{ sPathValue }, pMonitor);
         
         // Just wait for the process to end before destroying it
         try {
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/AbstractOOo.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/AbstractOOo.java
index 218cf04..2c13d96 100644
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/AbstractOOo.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/AbstractOOo.java
@@ -48,6 +48,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
 
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
@@ -333,8 +335,11 @@ public abstract class AbstractOOo implements IOOo, ITableElement {
         
         String[] env = pPrj.getLanguage().getLanguageBuidler().getBuildEnv(pPrj);
         
+        IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( pPrj.getName() );
+        
         if (getJavaldxPath() != null) {
-            Process p = pPrj.getSdk().runToolWithEnv(pPrj, getJavaldxPath(), env, pMonitor);
+            Process p = pPrj.getSdk().runToolWithEnv(prj, 
+                    pPrj.getOOo(), getJavaldxPath(), env, pMonitor);
             InputStream out = p.getInputStream();
             StringWriter writer = new StringWriter();
             
@@ -352,7 +357,7 @@ public abstract class AbstractOOo implements IOOo, ITableElement {
                     System.getProperty("path.separator")); //$NON-NLS-1$
         }
         
-        Process p = pPrj.getSdk().runToolWithEnv(pPrj, command, env, pMonitor);
+        Process p = pPrj.getSdk().runToolWithEnv(prj, pPrj.getOOo(), command, env, pMonitor);
         DebugPlugin.newProcess(pLaunch, p, Messages.getString("AbstractOOo.UreProcessName")  + pMain); //$NON-NLS-1$
     }
     
diff --git a/core/source/org/openoffice/ide/eclipse/core/internal/model/SDK.java b/core/source/org/openoffice/ide/eclipse/core/internal/model/SDK.java
index 6151b97..26a338e 100755
--- a/core/source/org/openoffice/ide/eclipse/core/internal/model/SDK.java
+++ b/core/source/org/openoffice/ide/eclipse/core/internal/model/SDK.java
@@ -51,6 +51,8 @@ import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Path;
@@ -309,33 +311,31 @@ public class SDK implements ISdk, ITableElement {
      */
     public Process runTool(IUnoidlProject pProject, 
             String pShellCommand, IProgressMonitor pMonitor) {
-        return runToolWithEnv(pProject, pShellCommand, new String[0], pMonitor);
+        IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( pProject.getName() );
+        return runToolWithEnv(prj, pProject.getOOo(), pShellCommand, new String[0], pMonitor);
     }
     
     /**
      * {@inheritDoc}
      */
-    public Process runToolWithEnv(IUnoidlProject pProject, 
+    public Process runToolWithEnv(IProject pProject, IOOo pOOo, 
             String pShellCommand, String[] pEnv, IProgressMonitor pMonitor) {
         
         Process process = null;
         
         try {
-            ISdk sdk = pProject.getSdk();
-            IOOo ooo = pProject.getOOo();
-            
-            if (null != sdk && null != ooo) {
+            if ( null != pOOo ) {
                 
                 // Get the environment variables and copy them. Needs Java 1.5
                 String[] sysEnv = SystemHelper.getSystemEnvironement();
                 
                 String[] vars = mergeVariables(sysEnv, pEnv);
                
-                vars = updateEnvironment(vars, ooo);
+                vars = updateEnvironment(vars, pOOo);
                 
                 // Run only if the OS and ARCH are valid for the SDK
                 if (null != vars) {
-                    File projectFile = pProject.getProjectPath().toFile();
+                    File projectFile = pProject.getLocation().toFile();
                     process = SystemHelper.runTool(pShellCommand, vars, projectFile);
                 }
             }
diff --git a/core/source/org/openoffice/ide/eclipse/core/model/config/ISdk.java b/core/source/org/openoffice/ide/eclipse/core/model/config/ISdk.java
index 577e520..7d1b2ff 100644
--- a/core/source/org/openoffice/ide/eclipse/core/model/config/ISdk.java
+++ b/core/source/org/openoffice/ide/eclipse/core/model/config/ISdk.java
@@ -43,6 +43,7 @@
  ************************************************************************/
 package org.openoffice.ide.eclipse.core.model.config;
 
+import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.openoffice.ide.eclipse.core.model.IUnoidlProject;
@@ -112,13 +113,13 @@ public interface ISdk {
      * be created with the project parameters such as it's SDK and 
      * location path
      * 
-     * @param pProject the UNO-IDL project on which to run the tool
+     * @param pProject the UNO project on which to run the tool
      * @param pShellCommand the shell command to execute the tool
      * @param pMonitor a process monitor to watch the tool launching
      * 
      * @return the process executing the tool
      */
-    public Process runTool(IUnoidlProject pProject, 
+    public Process runTool(IUnoidlProject pProject,   
             String pShellCommand, IProgressMonitor pMonitor);
     
     /**
@@ -126,14 +127,15 @@ public interface ISdk {
      * be created with the project parameters such as it's SDK and 
      * location path
      * 
-     * @param pProject the UNO-IDL project on which to run the tool
+     * @param pProject the folder from which to run the command
+     * @param pOOo the ooo instance to run the tool
      * @param pShellCommand the shell command to execute the tool
-     * @param pEnv tool environement variable
+     * @param pEnv tool environment variable
      * @param pMonitor a process monitor to watch the tool launching
      * 
      * @return the process executing the tool
      */
-    public Process runToolWithEnv(IUnoidlProject pProject, 
+    public Process runToolWithEnv(IProject pProject, IOOo pOOo, 
             String pShellCommand, String[] pEnv, IProgressMonitor pMonitor);
 
 }
diff --git a/cpp/icons/uno_client.gif b/cpp/icons/uno_client.gif
deleted file mode 100644
index f794b29..0000000
Binary files a/cpp/icons/uno_client.gif and /dev/null differ
diff --git a/cpp/icons/uno_client.png b/cpp/icons/uno_client.png
new file mode 100644
index 0000000..d58ec3e
Binary files /dev/null and b/cpp/icons/uno_client.png differ
diff --git a/cpp/icons/uno_client_wiz.png b/cpp/icons/uno_client_wiz.png
index 1d1ef9b..ae74ced 100644
Binary files a/cpp/icons/uno_client_wiz.png and b/cpp/icons/uno_client_wiz.png differ
diff --git a/cpp/plugin.xml b/cpp/plugin.xml
index 8cce159..2f7ac45 100644
--- a/cpp/plugin.xml
+++ b/cpp/plugin.xml
@@ -11,11 +11,11 @@
    <extension
          point="org.eclipse.ui.newWizards">
       <wizard
-            canFinishEarly="true"
+            canFinishEarly="false"
             category="org.openoffice.ide.eclipse.core"
             class="org.openoffice.ide.eclipse.cpp.client.ClientWizard"
             hasPages="true"
-            icon="icons/uno_client.gif"
+            icon="icons/uno_client.png"
             id="org.openoffice.ide.eclipse.cpp.client"
             name="C++ UNO client application">
       </wizard>
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/CDTHelper.java b/cpp/source/org/openoffice/ide/eclipse/cpp/CDTHelper.java
new file mode 100644
index 0000000..f5ca7a3
--- /dev/null
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/CDTHelper.java
@@ -0,0 +1,89 @@
+package org.openoffice.ide.eclipse.cpp;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.openoffice.ide.eclipse.core.PluginLogger;
+
+public class CDTHelper {
+
+    public static void addCDTNature( IProject pProject, IProgressMonitor pMonitor ) throws CoreException {
+            if (!pProject.exists()) {
+                pProject.create( pMonitor );
+                PluginLogger.debug(
+                        "Project created during language specific operation"); //$NON-NLS-1$
+            }
+            
+            if (!pProject.isOpen()) {
+                pProject.open( pMonitor );
+                PluginLogger.debug("Project opened"); //$NON-NLS-1$
+            }
+            
+            CProjectNature.addCNature(pProject, pMonitor );
+            CCProjectNature.addCCNature( pProject, pMonitor );
+            ManagedCProjectNature.addManagedNature( pProject, pMonitor );
+    }
+    
+    public static void addEntries( IProject pProject, ICLanguageSettingEntry[] pNewEntries, int pEntriesType ) {
+        ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription( pProject );
+        ICConfigurationDescription[] configs = prjDesc.getConfigurations();
+        
+        // Set them on all the languages of all the configurations
+        for (ICConfigurationDescription config : configs) {
+            ICFolderDescription folder = config.getRootFolderDescription();
+            ICLanguageSetting[] languages = folder.getLanguageSettings();
+            for (ICLanguageSetting lang : languages) {
+                List<ICLanguageSettingEntry> entries = lang.getSettingEntriesList( pEntriesType );
+                for ( ICLanguageSettingEntry newEntry : pNewEntries ) {
+                    if ( !entries.contains( newEntry ) ) {
+                        entries.add( newEntry );
+                    }
+                }
+                lang.setSettingEntries( pEntriesType, entries );
+            }
+        }
+        
+        try {
+            CoreModel.getDefault().setProjectDescription( pProject, prjDesc );
+        } catch ( CoreException e ) {
+            PluginLogger.error( "Error setting the includes and libraries", e );
+        }
+    }
+    
+    public static void removeEntries( IProject pProject, ICLanguageSettingEntry[] pOldEntries, int pEntriesType ) {
+        ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription( pProject );
+        ICConfigurationDescription[] configs = prjDesc.getConfigurations();
+        
+        // Set them on all the languages of all the configurations
+        for (ICConfigurationDescription config : configs) {
+            ICFolderDescription folder = config.getRootFolderDescription();
+            ICLanguageSetting[] languages = folder.getLanguageSettings();
+            for (ICLanguageSetting lang : languages) {
+                List<ICLanguageSettingEntry> entries = lang.getSettingEntriesList( pEntriesType );
+                for ( ICLanguageSettingEntry oldEntry : pOldEntries ) {
+                    if ( entries.contains( oldEntry ) ) {
+                        entries.remove( oldEntry );
+                    }
+                }
+                lang.setSettingEntries( pEntriesType, entries );
+            }
+        }
+        
+        try {
+            CoreModel.getDefault().setProjectDescription( pProject, prjDesc );
+        } catch ( CoreException e ) {
+            PluginLogger.error( "Error setting the includes and libaries", e );
+        }
+    }
+}
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/CppBuilder.java b/cpp/source/org/openoffice/ide/eclipse/cpp/CppBuilder.java
index 57201f3..10a8545 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/CppBuilder.java
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/CppBuilder.java
@@ -87,7 +87,7 @@ public class CppBuilder implements ILanguageBuilder {
                     String oooTypesArgs = ""; //$NON-NLS-1$
                     for (String path : paths) {
                         IPath ooTypesPath = new Path (path);
-                        oooTypesArgs += " \"" + ooTypesPath.toOSString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+                        oooTypesArgs += " -X\"" + ooTypesPath.toOSString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
                     }
 
                     String command = "cppumaker -T\"*\"" +  //$NON-NLS-1$
@@ -118,7 +118,7 @@ public class CppBuilder implements ILanguageBuilder {
                     IPath includePath = pPrj.getFolder( 
                             unoprj.getBuildPath().append( CppBuilder.INCLUDE ) ).getProjectRelativePath();
                     
-                    CppProjectHandler.addEntries( pPrj, 
+                    CDTHelper.addEntries( pPrj, 
                             new CIncludePathEntry[]{ new CIncludePathEntry( includePath, ICSettingEntry.VALUE_WORKSPACE_PATH ) }, 
                             ICSettingEntry.INCLUDE_PATH );
                     
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java b/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java
index c32734d..f2064de 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/CppProjectHandler.java
@@ -32,10 +32,7 @@ package org.openoffice.ide.eclipse.cpp;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.core.CProjectNature;
 import org.eclipse.cdt.core.model.CoreModel;
 import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.cdt.core.model.IPathEntry;
@@ -44,18 +41,14 @@ import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
 import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
 import org.eclipse.cdt.core.settings.model.CMacroEntry;
 import org.eclipse.cdt.core.settings.model.CSourceEntry;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICFolderDescription;
-import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
 import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
 import org.eclipse.cdt.core.settings.model.ICSettingEntry;
 import org.eclipse.cdt.core.settings.model.ICSourceEntry;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.cdt.managedbuilder.core.IManagedProject;
 import org.eclipse.cdt.managedbuilder.core.IProjectType;
 import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
+import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
@@ -74,6 +67,13 @@ import org.openoffice.ide.eclipse.core.model.language.IProjectHandler;
 
 public class CppProjectHandler implements IProjectHandler {
 
+    public static final String[] LIBS = {
+        "uno_sal", //$NON-NLS-1$
+        "uno_cppu", //$NON-NLS-1$
+        "uno_cppuhelpergcc3", //$NON-NLS-1$
+        "uno_salhelpergcc3" //$NON-NLS-1$
+    };
+    
     @Override
     public void addLanguageDependencies(IUnoidlProject unoproject,
             IProgressMonitor monitor) throws CoreException {
@@ -89,23 +89,8 @@ public class CppProjectHandler implements IProjectHandler {
     @Override
     public void addProjectNature(IProject pProject) {
         try {
-            if (!pProject.exists()) {
-                pProject.create(null);
-                PluginLogger.debug(
-                        "Project created during language specific operation"); //$NON-NLS-1$
-            }
-            
-            if (!pProject.isOpen()) {
-                pProject.open(null);
-                PluginLogger.debug("Project opened"); //$NON-NLS-1$
-            }
-            
-            CProjectNature.addCNature(pProject, null);
-            CCProjectNature.addCCNature( pProject, null );
-            ManagedCProjectNature.addManagedNature( pProject, null );
-            
+            CDTHelper.addCDTNature( pProject, null );
             PluginLogger.debug( "C++ project nature set" );
-            
         } catch (CoreException e) {
             PluginLogger.error( "Failed to set C++ project nature" );
         }
@@ -213,7 +198,7 @@ public class CppProjectHandler implements IProjectHandler {
         removeOOoDependencies( ooo, unoprj.getSdk(), project );
     }
     
-    private static ICLanguageSettingEntry[] getMacrosForPlatform(String pOs ) {
+    private static ICLanguageSettingEntry[] getMacrosForPlatform( String pOs ) {
         
         HashMap<String, String> macrosList = new HashMap<String, String>();
         macrosList.put( Platform.OS_LINUX, "UNX GCC LINUX CPPU_ENV=gcc3" ); //$NON-NLS-1$
@@ -237,80 +222,45 @@ public class CppProjectHandler implements IProjectHandler {
         return results.toArray( new ICLanguageSettingEntry[ results.size() ]);
     }
     
-    static public void addEntries( IProject pProject, ICLanguageSettingEntry[] pNewEntries, int pEntriesType ) {
-        ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription( pProject );
-        ICConfigurationDescription[] configs = prjDesc.getConfigurations();
-        
-        // Set them on all the languages of all the configurations
-        for (ICConfigurationDescription config : configs) {
-            ICFolderDescription folder = config.getRootFolderDescription();
-            ICLanguageSetting[] languages = folder.getLanguageSettings();
-            for (ICLanguageSetting lang : languages) {
-                List<ICLanguageSettingEntry> entries = lang.getSettingEntriesList( pEntriesType );
-                for ( ICLanguageSettingEntry newEntry : pNewEntries ) {
-                    if ( !entries.contains( newEntry ) ) {
-                        entries.add( newEntry );
-                    }
-                }
-                lang.setSettingEntries( pEntriesType, entries );
-            }
-        }
-        
-        try {
-            CoreModel.getDefault().setProjectDescription( pProject, prjDesc );
-        } catch ( CoreException e ) {
-            PluginLogger.error( "Error setting the includes and libraries", e );
-        }
-    }
-    
-    static public void removeEntries( IProject pProject, ICLanguageSettingEntry[] pOldEntries, int pEntriesType ) {
-        ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription( pProject );
-        ICConfigurationDescription[] configs = prjDesc.getConfigurations();
-        
-        // Set them on all the languages of all the configurations
-        for (ICConfigurationDescription config : configs) {
-            ICFolderDescription folder = config.getRootFolderDescription();
-            ICLanguageSetting[] languages = folder.getLanguageSettings();
-            for (ICLanguageSetting lang : languages) {
-                List<ICLanguageSettingEntry> entries = lang.getSettingEntriesList( pEntriesType );
-                for ( ICLanguageSettingEntry oldEntry : pOldEntries ) {
-                    if ( entries.contains( oldEntry ) ) {
-                        entries.remove( oldEntry );
-                    }
-                }
-                lang.setSettingEntries( pEntriesType, entries );
-            }
-        }
-        
-        try {
-            CoreModel.getDefault().setProjectDescription( pProject, prjDesc );
-        } catch ( CoreException e ) {
-            PluginLogger.error( "Error setting the includes and libaries", e );
-        }
-    }
-    
     static public void addOOoDependencies(IOOo ooo, ISdk sdk, IProject project) {
         CIncludePathEntry sdkIncludes = new CIncludePathEntry( sdk.getIncludePath(), 0 );
+        CIncludePathEntry includes = new CIncludePathEntry( OOoSdkProjectJob.getIncludes( ooo ), 0 );
+        
         ArrayList< CLibraryPathEntry > libs = new ArrayList<CLibraryPathEntry>();
         String[] oooLibs = ooo.getLibsPath();
         for (String libPath : oooLibs) {
             libs.add( new CLibraryPathEntry( new Path( libPath ), 0 ) );   
         }
+        IFolder oooSdkLibs = OOoSdkProjectJob.getLibraries( ooo ); 
+        libs.add( new CLibraryPathEntry( oooSdkLibs, ICSettingEntry.VALUE_WORKSPACE_PATH ) );
+        
+        
+        CDTHelper.addEntries( project, new CIncludePathEntry[] { sdkIncludes, includes }, ICSettingEntry.INCLUDE_PATH );
+        CDTHelper.addEntries( project, libs.toArray( new CLibraryPathEntry[libs.size()]), ICSettingEntry.LIBRARY_PATH );
+        CDTHelper.addEntries( project, getMacrosForPlatform( Platform.getOS() ), ICSettingEntry.MACRO );
         
-        addEntries( project, new CIncludePathEntry[] { sdkIncludes }, ICSettingEntry.INCLUDE_PATH );
-        addEntries( project, libs.toArray( new CLibraryPathEntry[libs.size()]), ICSettingEntry.LIBRARY_PATH );
-        addEntries( project, getMacrosForPlatform( Platform.getOS() ), ICSettingEntry.MACRO );
-         
+        // Run the cppumaker on the ooo types ( asynchronous )
+        OOoSdkProjectJob job = new OOoSdkProjectJob(ooo, sdk );
+        job.schedule();
+        
+        CDTHelper.addEntries( project, new ICLanguageSettingEntry[]{ includes }, ICSettingEntry.INCLUDE_PATH );
     }
     
     static public void removeOOoDependencies(IOOo ooo, ISdk sdk, IProject project) {
         CIncludePathEntry sdkIncludes = new CIncludePathEntry( sdk.getIncludePath(), 0 );
+        CIncludePathEntry includes = new CIncludePathEntry( OOoSdkProjectJob.getIncludes( ooo ), 0 );
+        
         ArrayList< CLibraryPathEntry > libs = new ArrayList<CLibraryPathEntry>();
         String[] oooLibs = ooo.getLibsPath();
         for (String libPath : oooLibs) {
             libs.add( new CLibraryPathEntry( new Path( libPath ), 0 ) );   
         }
-        removeEntries( project, new CIncludePathEntry[] { sdkIncludes }, ICSettingEntry.INCLUDE_PATH );
-        removeEntries( project, libs.toArray( new CLibraryPathEntry[libs.size()]), ICSettingEntry.LIBRARY_PATH );
+        IFolder oooSdkLibs = OOoSdkProjectJob.getLibraries( ooo ); 
+        libs.add( new CLibraryPathEntry( oooSdkLibs, ICSettingEntry.VALUE_WORKSPACE_PATH ) );
+        
+        CDTHelper.removeEntries( project, new CIncludePathEntry[] { sdkIncludes, includes }, ICSettingEntry.INCLUDE_PATH );
+        CDTHelper.removeEntries( project, libs.toArray( new CLibraryPathEntry[libs.size()]), ICSettingEntry.LIBRARY_PATH );
+        CDTHelper.removeEntries( project, getMacrosForPlatform( Platform.getOS() ), ICSettingEntry.MACRO );
+
     }
 }
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/OOoSdkProjectJob.java b/cpp/source/org/openoffice/ide/eclipse/cpp/OOoSdkProjectJob.java
new file mode 100644
index 0000000..ef24b8c
--- /dev/null
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/OOoSdkProjectJob.java
@@ -0,0 +1,200 @@
+package org.openoffice.ide.eclipse.cpp;
+
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.text.MessageFormat;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.openoffice.ide.eclipse.core.LogLevels;
+import org.openoffice.ide.eclipse.core.PluginLogger;
+import org.openoffice.ide.eclipse.core.model.config.IOOo;
+import org.openoffice.ide.eclipse.core.model.config.ISdk;
+
+public class OOoSdkProjectJob extends Job {
+    
+    private static final String INCLUDES_DIR = "includes"; //$NON-NLS-1$
+    private static final String PRJ_NAME_PATTERN = "{0} Cpp SDK"; //$NON-NLS-1$
+    private static final String LIBS_DIR = "libs"; //$NON-NLS-1$
+    
+    private IOOo mOOo;
+    private ISdk mSdk;
+    
+    public OOoSdkProjectJob( IOOo pOOo, ISdk pSdk ) {
+        super( "Generating the OOo includes project for " + pOOo.getName() );
+        mOOo = pOOo;
+        mSdk = pSdk;
+    }
+
+    public static IFolder getIncludes( IOOo pOOo ) {
+        
+        String prjName = MessageFormat.format( PRJ_NAME_PATTERN, pOOo.getName() );
+        IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( prjName );
+        
+        return prj.getFolder( INCLUDES_DIR );
+    }
+    
+    public static IFolder getLibraries( IOOo pOOo ) {
+        
+        String prjName = MessageFormat.format( PRJ_NAME_PATTERN, pOOo.getName() );
+        IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( prjName );
+        
+        return prj.getFolder( LIBS_DIR );
+    }
+    
+    @Override
+    protected IStatus run( IProgressMonitor pMonitor ) {
+        
+        IStatus status = new Status( IStatus.OK, Activator.PLUGIN_ID, "UNO includes generated" );
+        
+        try {
+            // Create the OOo SDK project
+            String prjName = MessageFormat.format( PRJ_NAME_PATTERN, mOOo.getName() );
+            IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( prjName );
+            if ( !prj.exists() ) {
+                prj.create( pMonitor );   
+            }
+            
+            // Open the project if not opened
+            if (!prj.isOpen()) {
+                prj.open( pMonitor );
+                PluginLogger.debug("Project opened"); //$NON-NLS-1$
+            }
+            
+            // Link the URE libs here
+            createLibLinks( prj, pMonitor );
+            
+            // Create the includes
+            createIncludes( prj, pMonitor );
+            
+        } catch ( Exception e ) {
+            status = new Status( IStatus.ERROR, Activator.PLUGIN_ID, "Failed to generate the includes", e );
+        }
+        
+        return status;
+    }
+
+    private void createLibLinks(IProject prj, IProgressMonitor pMonitor) throws CoreException {
+        
+        String os = Platform.getOS();
+        if ( os.equals( Platform.OS_LINUX ) || os.equals( Platform.OS_SOLARIS ) 
+                || os.equals( Platform.OS_MACOSX ) ) {
+            // Create the link folder
+            IFolder folder = prj.getFolder( LIBS_DIR );
+
+            if ( !folder.exists() ) {
+                folder.create( true, true, pMonitor );
+            }
+            
+            String ext = "so"; //$NON-NLS-1$
+            if ( os.equals( Platform.OS_MACOSX ) ) {
+                ext = "dylib"; //$NON-NLS-1$
+            }
+             
+            String[] paths = mOOo.getLibsPath();
+            for (String path : paths) {
+                Path dirPath = new Path( path );
+                // Check for the libs to link
+                for ( String lib : CppProjectHandler.LIBS ) {
+                    String pattern = "lib{0}.{1}"; //$NON-NLS-1$
+                    String libname = MessageFormat.format( pattern, lib, ext );
+                    String syslibname = libname + ".3"; //$NON-NLS-1$
+                    
+                    File libFile = new File( dirPath.toFile(), syslibname );
+                    if ( libFile.exists() ) {
+                        String dest = folder.getFile( libname ).getLocation().toOSString();
+                        String orig = libFile.getAbsolutePath();
+                        
+                        // Run ln to link the files: present on all *NIX platforms
+                        String[] command = { 
+                                "ln", "-s", //$NON-NLS-1$ //$NON-NLS-2$
+                                orig, dest
+                        };
+                        try {
+                            Process proc = Runtime.getRuntime().exec( command );
+                            
+                            StringBuffer buf = getErrorString( proc );
+                            if ( !buf.toString().trim().equals( new String( ) ) ) {
+                                String msg = "Cannot link library " + libname + "\n";
+                                msg += buf.toString();
+                                PluginLogger. error( msg );
+                            }
+                            
+                            proc.waitFor();
+                            
+                        } catch ( Exception e ) {
+                            PluginLogger.error( "Cannot link library " + libname, e );
+                        }
+                    }
+                }
+            }
+            folder.refreshLocal( IResource.DEPTH_ONE, pMonitor );
+        }
+    }
+
+    private void createIncludes( IProject pProject, IProgressMonitor pMonitor) throws Exception {
+        // Create the destination folder if needed 
+        IFolder folder = pProject.getFolder( INCLUDES_DIR );
+        if ( !folder.exists() ) {
+            folder.create( true, true, pMonitor );
+        }
+
+        // Generate the include into the new project 
+        String[] paths = mOOo.getTypesPath();
+        String oooTypesArgs = ""; //$NON-NLS-1$
+        for (String path : paths) {
+            IPath ooTypesPath = new Path (path);
+            oooTypesArgs += " \"" + ooTypesPath.toOSString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
+        String cmdPattern = "cppumaker -T\"*\" -Gc -BUCR -O \"{0}\" {1}"; //$NON-NLS-1$
+        String command = MessageFormat.format( cmdPattern, 
+                folder.getLocation().toFile().getAbsolutePath() , oooTypesArgs ); 
+        Process process = mSdk.runToolWithEnv( pProject, mOOo, command, new String[0], pMonitor );
+
+        StringBuffer buf = getErrorString( process );
+        if ( !buf.toString().trim().equals( new String( ) ) ) {
+            String msg = "Error generating the includes\n";
+            msg += buf.toString();
+            PluginLogger. error( msg );
+        }
+
+        process.waitFor();
+        
+        // Refresh the folder
+        folder.refreshLocal( IResource.DEPTH_INFINITE, pMonitor );
+    }
+
+    private StringBuffer getErrorString(Process process) {
+        StringBuffer buf = new StringBuffer();
+        
+        LineNumberReader lineReader = new LineNumberReader(
+                new InputStreamReader(process.getErrorStream()));
+
+        try {
+            // Only for debugging purpose
+            if (PluginLogger.isLevel(LogLevels.DEBUG)) {
+                String line = lineReader.readLine();
+                while (null != line) {
+                    buf.append( line + "\n" ); //$NON-NLS-1$
+                    line = lineReader.readLine();
+                }
+            }
+        } catch ( Exception e ) {
+            // Not reporting errors in error reader
+        }
+        return buf;
+    }
+
+}
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java b/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
index abadc54..380a579 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/ClientWizard.java
@@ -50,7 +50,7 @@ import org.openoffice.ide.eclipse.cpp.CppProjectHandler;
 
 public class ClientWizard extends CCProjectWizard {
 
-    private static final String HELPER_DIR_NAME = "helper";
+    private static final String HELPER_DIR_NAME = "helper"; //$NON-NLS-1$
     private UnoConnectionPage mCnxPage;
 
     public ClientWizard() {
@@ -86,9 +86,6 @@ public class ClientWizard extends CCProjectWizard {
         IOOo ooo = mCnxPage.getOoo();
         ISdk sdk = mCnxPage.getSdk();
         
-        // Add the necessary includes/libs/macros
-        CppProjectHandler.addOOoDependencies( ooo, sdk, newProject );
-        
         // Copy the helper files in the helper source dir
         IFolder srcDir = newProject.getFolder( HELPER_DIR_NAME );
         srcDir.create( true, true, null );
@@ -106,7 +103,7 @@ public class ClientWizard extends CCProjectWizard {
         newEntries[ newEntries.length - 1 ] = CoreModel.newSourceEntry( srcDir.getFullPath() );
         CoreModel.setRawPathEntries( cprj, newEntries, null );
         
-        // TODO Run the cppumaker on the ooo types ( asynchronous )
+        CppProjectHandler.addOOoDependencies( ooo, sdk, newProject );
         
         // TODO Setup the launch config
         
diff --git a/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx b/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx
index 0f9b421..7c3a9d8 100644
--- a/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx
+++ b/cpp/source/org/openoffice/ide/eclipse/cpp/client/connection.cxx
@@ -127,10 +127,14 @@ bool AbstractConnection::connect( )
 	}
 	catch ( NoConnectException e )
 	{
+#if DEBUG
 		fprintf( stderr, "connection failed: %s : %s\n",
 				OUSTRING_TO_C( m_sConnectionString ),
 				OUSTRING_TO_C( e.Message ) );
+#endif
+		m_bConnected = false;
 	}
+	return m_bConnected;
 }
 
 void AbstractConnection::disconnect()


More information about the ooo-build-commit mailing list