~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CBuildSettingCache.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2007, 2009 Intel Corporation and others.
 
3
 * All rights reserved. This program and the accompanying materials
 
4
 * are made available under the terms of the Eclipse Public License v1.0
 
5
 * which accompanies this distribution, and is available at
 
6
 * http://www.eclipse.org/legal/epl-v10.html
 
7
 *
 
8
 * Contributors:
 
9
 * Intel Corporation - Initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.cdt.internal.core.settings.model;
 
12
 
 
13
import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
 
14
import org.eclipse.cdt.core.settings.model.ICBuildSetting;
 
15
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
 
16
import org.eclipse.cdt.core.settings.model.ICOutputEntry;
 
17
import org.eclipse.cdt.core.settings.model.ICSettingContainer;
 
18
import org.eclipse.cdt.core.settings.model.extension.CBuildData;
 
19
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultBuildData;
 
20
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
 
21
import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
 
22
import org.eclipse.cdt.utils.envvar.StorableEnvironment;
 
23
import org.eclipse.core.resources.IProject;
 
24
import org.eclipse.core.runtime.IPath;
 
25
 
 
26
public class CBuildSettingCache extends CDefaultBuildData implements
 
27
                ICBuildSetting, ICachedData {
 
28
        private CConfigurationDescriptionCache fCfgCache;
 
29
        private StorableEnvironment fEnvironment;
 
30
        private StorableEnvironment fResolvedEnvironment;
 
31
        private ICOutputEntry[] fProjOutputEntries;
 
32
        private ICOutputEntry[] fResolvedOutputEntries;
 
33
 
 
34
        CBuildSettingCache(CBuildData base, CConfigurationDescriptionCache cfgCache){
 
35
                super(/*base.getId(), base*/);
 
36
                
 
37
                fId = base.getId();
 
38
                
 
39
                fCfgCache = cfgCache;
 
40
                
 
41
                fCfgCache.addBuildSetting(this);
 
42
                
 
43
                copySettingsFrom(base);
 
44
        }
 
45
        
 
46
        void initEnvironmentCache(){
 
47
                fEnvironment = new StorableEnvironment(
 
48
                                EnvironmentVariableManager.getDefault().getVariables(fCfgCache, false),
 
49
                                true);
 
50
        }
 
51
        
 
52
        public StorableEnvironment getCachedEnvironment(){
 
53
                return fEnvironment;
 
54
        }
 
55
        
 
56
        public StorableEnvironment getResolvedEnvironment(){
 
57
                if(fResolvedEnvironment == null){
 
58
                        fResolvedEnvironment = new StorableEnvironment(
 
59
                                        EnvironmentVariableManager.getDefault().getVariables(fCfgCache, true),
 
60
                                        true);
 
61
                }
 
62
                return fResolvedEnvironment;
 
63
        }
 
64
 
 
65
        public ICConfigurationDescription getConfiguration() {
 
66
                return fCfgCache;
 
67
        }
 
68
 
 
69
        public ICSettingContainer getParent() {
 
70
                return fCfgCache;
 
71
        }
 
72
 
 
73
        public boolean isReadOnly() {
 
74
                return true;
 
75
        }
 
76
 
 
77
        @Override
 
78
        public void setBuilderCWD(IPath path) {
 
79
                throw ExceptionFactory.createIsReadOnlyException();
 
80
        }
 
81
 
 
82
        @Override
 
83
        public void setErrorParserIDs(String[] ids) {
 
84
                throw ExceptionFactory.createIsReadOnlyException();
 
85
        }
 
86
 
 
87
        public void setName(String name) {
 
88
                throw ExceptionFactory.createIsReadOnlyException();
 
89
        }
 
90
 
 
91
        @Override
 
92
        public void setOutputDirectories(ICOutputEntry[] entries) {
 
93
                throw ExceptionFactory.createIsReadOnlyException();
 
94
        }
 
95
 
 
96
        @Override
 
97
        public IEnvironmentContributor getBuildEnvironmentContributor() {
 
98
                return fCfgCache.getConfigurationData().getBuildData().getBuildEnvironmentContributor();
 
99
        }
 
100
 
 
101
        public ICOutputEntry[] getResolvedOutputDirectories() {
 
102
                if(fResolvedOutputEntries == null){
 
103
                        ICOutputEntry[] entries = getOutputDirectories();
 
104
                        return CDataUtil.resolveEntries(entries, getConfiguration());
 
105
                }
 
106
                return fResolvedOutputEntries;
 
107
        }
 
108
        
 
109
        @Override
 
110
        public ICOutputEntry[] getOutputDirectories() {
 
111
                initOutputEntries();
 
112
                return fProjOutputEntries.clone();
 
113
        }
 
114
        
 
115
        private void initOutputEntries(){
 
116
                if(fProjOutputEntries == null){
 
117
                        IProject project = getProject(); 
 
118
                        fProjOutputEntries = CDataUtil.adjustEntries(fOutputEntries, true, project);
 
119
                }
 
120
        }
 
121
        
 
122
        private IProject getProject(){
 
123
                ICConfigurationDescription cfg = getConfiguration();
 
124
                return cfg.isPreferenceConfiguration() ? null : cfg.getProjectDescription().getProject();
 
125
        }
 
126
 
 
127
        
 
128
}