blob: a4892173050abe60d4e329bcc330f9d100485b87 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*******************************************************************************
* Copyright (c) 2017 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.cdt.build.gcc.ui.internal;
import java.nio.file.Path;
import org.eclipse.cdt.build.gcc.core.ClangToolChain;
import org.eclipse.cdt.build.gcc.core.GCCToolChain;
import org.eclipse.cdt.build.gcc.core.GCCUserToolChainProvider;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.core.build.IUserToolChainProvider;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.ui.build.ToolChainWizard;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
public class NewClangToolChainWizard extends ToolChainWizard {
private GCCToolChainSettingsPage settingsPage;
private ToolChainEnvironmentPage envPage;
@Override
public boolean performFinish() {
Path path = settingsPage.getPath();
String os = settingsPage.getOS();
String arch = settingsPage.getArch();
IEnvironmentVariable[] envvars = envPage.getEnvVars();
new Job(Messages.NewGCCToolChainWizard_Add) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
IToolChainManager manager = Activator.getService(IToolChainManager.class);
IUserToolChainProvider provider = (IUserToolChainProvider) manager
.getProvider(GCCUserToolChainProvider.PROVIDER_ID);
if (toolChain != null) {
provider.removeToolChain(toolChain);
}
ClangToolChain gcc = new ClangToolChain(provider, path, arch, envvars);
gcc.setProperty(IToolChain.ATTR_OS, os);
provider.addToolChain(gcc);
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
}
}
}.schedule();
return true;
}
@Override
public void addPages() {
super.addPages();
settingsPage = new GCCToolChainSettingsPage((GCCToolChain) toolChain, true);
addPage(settingsPage);
envPage = new ToolChainEnvironmentPage(toolChain);
addPage(envPage);
setWindowTitle(Messages.NewClangToolChainWizard_Title);
}
}
|