Instantly share code, notes, and snippets.

Embed
What would you like to do?
Overhaul Xamarin Studio C/C++ Addin
diff --git a/cbindingreport/cbinding/cbinding/cbinding.csproj b/caddin/cbinding/cbinding/cbinding.csproj
index 69217e2..3e891db 100644
--- a/cbindingreport/cbinding/cbinding/cbinding.csproj
+++ b/caddin/cbinding/cbinding/cbinding.csproj
@@ -1,6 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
- <Import Project="..\packages\MonoDevelop.Addins.0.3.10\build\net40\MonoDevelop.Addins.props" Condition="Exists('..\packages\MonoDevelop.Addins.0.3.10\build\net40\MonoDevelop.Addins.props')" />
+ <Import Project="..\packages\MonoDevelop.Addins.0.3.16\build\net45\MonoDevelop.Addins.props" Condition="Exists('..\packages\MonoDevelop.Addins.0.3.16\build\net45\MonoDevelop.Addins.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,7 +8,7 @@
<OutputType>Library</OutputType>
<AssemblyName>MonoDevelop.CBinding</AssemblyName>
<RootNamespace>CBinding</RootNamespace>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<AdjacentMD>..\..\monodevelop\main\build\bin</AdjacentMD>
<MDBinDir Condition="Exists('$(AdjacentMD)')">$(AdjacentMD)</MDBinDir>
</PropertyGroup>
@@ -30,15 +29,9 @@
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Manifest.addin.xml" />
- <EmbeddedResource Include="templates\EmptyCProject.xpt.xml">
- <LogicalName>EmptyCProject.xpt.xml</LogicalName>
- </EmbeddedResource>
<EmbeddedResource Include="templates\EmptyCSourceFile.xft.xml">
<LogicalName>EmptyCSourceFile.xft.xml</LogicalName>
</EmbeddedResource>
- <EmbeddedResource Include="templates\EmptyCppProject.xpt.xml">
- <LogicalName>EmptyCppProject.xpt.xml</LogicalName>
- </EmbeddedResource>
<EmbeddedResource Include="gtk-gui\gui.stetic">
<LogicalName>gui.stetic</LogicalName>
</EmbeddedResource>
@@ -63,12 +56,6 @@
<EmbeddedResource Include="templates\StaticLibraryCppProject.xpt.xml">
<LogicalName>StaticLibraryCppProject.xpt.xml</LogicalName>
</EmbeddedResource>
- <EmbeddedResource Include="templates\ConsoleCProject.xpt.xml">
- <LogicalName>ConsoleCProject.xpt.xml</LogicalName>
- </EmbeddedResource>
- <EmbeddedResource Include="templates\ConsoleCppProject.xpt.xml">
- <LogicalName>ConsoleCppProject.xpt.xml</LogicalName>
- </EmbeddedResource>
<EmbeddedResource Include="templates\ConsoleObjCProject.xpt.xml">
<LogicalName>ConsoleObjCProject.xpt.xml</LogicalName>
</EmbeddedResource>
@@ -78,7 +65,7 @@
<EmbeddedResource Include="templates\EmptyObjCppSourceFile.xft.xml">
<LogicalName>EmptyObjCppSourceFile.xft.xml</LogicalName>
</EmbeddedResource>
- <EmbeddedResource Include="templates\EmptyCMakeListsFile.xft.xml">
+ <EmbeddedResource Include="templates\EmptyCMakeListsFile.xft.xml">
<LogicalName>EmptyCMakeListsFile.xft.xml</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="icons\union-private-16.png">
@@ -126,6 +113,8 @@
</None>
<None Include="app.config" />
<None Include="packages.config" />
+ <None Include="templates\ConsoleCppProject.xpt.xml" />
+ <None Include="templates\ConsoleCProject.xpt.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="templates\" />
@@ -143,54 +132,43 @@
<Reference Include="Mono.Posix" />
<Reference Include="System" />
<Reference Include="System.Xml" />
- <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- </Reference>
- <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"></Reference>
+ <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"></Reference>
+ <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"></Reference>
+ <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"></Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.ComponentModel.DataAnnotations" />
+ <Reference Include="Mono.Data.Sqlite">
+ <HintPath>..\packages\Mono.Data.Sqlite.Portable.1.0.3.5\lib\net4\Mono.Data.Sqlite.dll</HintPath>
+ <Private>False</Private>
</Reference>
- <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Reference Include="System.Data.Portable">
+ <HintPath>..\packages\Mono.Data.Sqlite.Portable.1.0.3.5\lib\net4\System.Data.Portable.dll</HintPath>
</Reference>
- <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Reference Include="System.Transactions.Portable">
+ <HintPath>..\packages\Mono.Data.Sqlite.Portable.1.0.3.5\lib\net4\System.Transactions.Portable.dll</HintPath>
</Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.ComponentModel.DataAnnotations" />
- <Reference Include="Mono.Data.Sqlite" />
+ <Reference Include="System.Transactions" />
+ <Reference Include="mscorlib" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.IO.Compression.FileSystem" />
+ <Reference Include="System.ComponentModel.Composition" />
+ <Reference Include="System.Numerics" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
- <Compile Include="Project\CProject.cs" />
- <Compile Include="Project\CProjectConfiguration.cs" />
<Compile Include="gtk-gui\generated.cs" />
- <Compile Include="Gui\CodeGenerationPanel.cs" />
- <Compile Include="Compiler\CCompiler.cs" />
- <Compile Include="Compiler\GccCompiler.cs" />
- <Compile Include="Compiler\GppCompiler.cs" />
- <Compile Include="Compiler\GNUCompiler.cs" />
- <Compile Include="Gui\CompilerPanel.cs" />
- <Compile Include="gtk-gui\CBinding.CodeGenerationPanel.cs" />
- <Compile Include="gtk-gui\CBinding.CompilerPanel.cs" />
- <Compile Include="Compiler\ICompiler.cs" />
- <Compile Include="Project\ProjectPackageCollection.cs" />
- <Compile Include="Gui\EditPackagesDialog.cs" />
- <Compile Include="gtk-gui\CBinding.EditPackagesDialog.cs" />
- <Compile Include="Project\Package.cs" />
- <Compile Include="Project\ProjectPackageEventArgs.cs" />
- <Compile Include="Gui\OutputOptionsPanel.cs" />
- <Compile Include="gtk-gui\CBinding.OutputOptionsPanel.cs" />
<Compile Include="ProjectPad\ProjectReferencesExtension.cs" />
- <Compile Include="ProjectPad\ProjectPackagesFolderNodeBuilder.cs" />
- <Compile Include="ProjectPad\ProjectPackageNodeBuilder.cs" />
<Compile Include="ProjectPad\ProjectNodeExtension.cs" />
<Compile Include="ProjectPad\FolderBasedProjectNodeBuilder.cs" />
<Compile Include="ProjectPad\CMakeTargetNodeBuilder.cs" />
<Compile Include="Gui\CTextEditorExtension.cs" />
<Compile Include="Gui\GeneralOptionsPanel.cs" />
<Compile Include="gtk-gui\CBinding.GeneralOptionsPanel.cs" />
- <Compile Include="Gui\PackageDetails.cs" />
- <Compile Include="gtk-gui\CBinding.PackageDetails.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\AddinInfo.cs" />
<Compile Include="CLang\CLangManager.cs" />
- <Compile Include="Compiler\ClangCCompiler.cs" />
- <Compile Include="Compiler\ClangCXXCompiler.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="Generated.cs" />
<Compile Include="Parser\ClangCompletionUnit.cs" />
@@ -206,22 +184,20 @@
<Compile Include="Refactoring\GotoDefinitionHandler.cs" />
<Compile Include="Refactoring\RefactoryCommands.cs" />
<Compile Include="Refactoring\GotoDeclarationHandler.cs" />
- <Compile Include="Parser\CDocumentParser.cs" />
<Compile Include="Gui\RenameHandlerDialog.cs" />
<Compile Include="gtk-gui\CBinding.RenameHandlerDialog.cs" />
<Compile Include="Parser\OverloadCandidate.cs" />
- <Compile Include="Parser\CParsedDocument.cs" />
<Compile Include="Project\UnsavedFilesManager.cs" />
<Compile Include="Project\UnsavedFile.cs" />
<Compile Include="Parser\SymbolDatabaseMediator.cs" />
<Compile Include="CLang\SerializationManager.cs" />
<Compile Include="CMake\CMakeCompletionDataLists.cs" />
<Compile Include="CMake\CMakeTextEditorExtension.cs" />
+ <Compile Include="CMake\CMakeProject.cs" />
<Compile Include="CMake\CMakeFileFormat.cs" />
<Compile Include="CMake\CMakeTarget.cs" />
<Compile Include="CMake\CMakeCommand.cs" />
<Compile Include="CMake\CMakeArgument.cs" />
- <Compile Include="CMake\CMakeProject.cs" />
<Compile Include="CMake\CMakeWorkspaceObjectReader.cs" />
<Compile Include="CMake\CMakeVariableManager.cs" />
<Compile Include="ProjectPad\SystemFolder.cs" />
@@ -233,11 +209,38 @@
<Compile Include="gtk-gui\CBinding.TargetPickerDialog.cs" />
<Compile Include="gtk-gui\CBinding.NewTargetDialog.cs" />
<Compile Include="Gui\NewTargetDialog.cs" />
+ <Compile Include="Project\ProjectPackageEventArgs.cs" />
+ <Compile Include="Compiler\VS15MSBuildToolchain.cs" />
+ <Compile Include="Compiler\CMakeToolchain.cs" />
+ <Compile Include="Compiler\VisualStudioToolchain.cs" />
+ <Compile Include="Compiler\VS14MSBuildToolchain.cs" />
+ <Compile Include="Compiler\VS12MSBuildToolchain.cs" />
+ <Compile Include="Compiler\MinGW32Toolchain.cs" />
+ <Compile Include="Compiler\ClangToolchain.cs" />
+ <Compile Include="Compiler\UnixMakeToolchain.cs" />
+ <Compile Include="Compiler\MacMakeToolchain.cs" />
+ <Compile Include="Parser\CDocumentParser.cs" />
+ <Compile Include="Parser\CParsedDocument.cs" />
+ <Compile Include="Parser\Class.cs" />
+ <Compile Include="Parser\ClassTemplate.cs" />
+ <Compile Include="Parser\ClassTemplatePartial.cs" />
+ <Compile Include="Parser\Enumeration.cs" />
+ <Compile Include="Parser\Enumerator.cs" />
+ <Compile Include="Parser\Field.cs" />
+ <Compile Include="Parser\Function.cs" />
+ <Compile Include="Parser\FunctionTemplate.cs" />
+ <Compile Include="Parser\Macro.cs" />
+ <Compile Include="Parser\MemberFunction.cs" />
+ <Compile Include="Parser\Namespace.cs" />
+ <Compile Include="Parser\Struct.cs" />
+ <Compile Include="Parser\Typedef.cs" />
+ <Compile Include="Parser\Union.cs" />
+ <Compile Include="Parser\Variable.cs" />
</ItemGroup>
<ItemGroup>
<AddinReference Include="MonoDevelop.Refactoring" />
<AddinReference Include="MonoDevelop.DesignerSupport" />
<AddinReference Include="MonoDevelop.Xml" />
</ItemGroup>
- <Import Project="..\packages\MonoDevelop.Addins.0.3.10\build\net40\MonoDevelop.Addins.targets" Condition="Exists('..\packages\MonoDevelop.Addins.0.3.10\build\net40\MonoDevelop.Addins.targets')" />
-</Project>
+ <Import Project="..\packages\MonoDevelop.Addins.0.3.16\build\net45\MonoDevelop.Addins.targets" Condition="Exists('..\packages\MonoDevelop.Addins.0.3.16\build\net45\MonoDevelop.Addins.targets')" />
+</Project>
\ No newline at end of file
diff --git a/cbindingreport/cbinding/cbinding/compiler/ccompiler.cs b/ccompiler.cs
index 019daeb..e69de29 100644
--- a/cbindingreport/cbinding/cbinding/compiler/ccompiler.cs
+++ b/ccompiler.cs
@@ -1,137 +0,0 @@
-//
-// CCompiler.cs: asbtract class that provides some basic implementation for ICompiler
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin@gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.IO;
-using System.Text;
-using System.CodeDom.Compiler;
-
-using MonoDevelop.Core;
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Projects;
-using MonoDevelop.Ide;
-
-namespace CBinding
-{
- public abstract class CCompiler : ICompiler
- {
- protected string compilerCommand;
- protected string linkerCommand;
-
- public abstract string Name {
- get;
- }
-
- public abstract Language Language {
- get;
- }
-
- public string CompilerCommand {
- get { return compilerCommand; }
- }
-
- public abstract bool SupportsCcache {
- get;
- }
-
- public abstract bool SupportsPrecompiledHeaders {
- get;
- }
-
- public abstract string GetCompilerFlags (Project project, CProjectConfiguration configuration);
-
- public abstract string GetDefineFlags (Project project, CProjectConfiguration configuration);
-
- public abstract BuildResult Compile (
- Project project,
- ProjectFileCollection projectFiles,
- ProjectPackageCollection packages,
- CProjectConfiguration configuration,
- ProgressMonitor monitor);
-
- public abstract void Clean (ProjectFileCollection projectFiles, CProjectConfiguration configuration, ProgressMonitor monitor);
-
- protected abstract void ParseCompilerOutput (string errorString, CompilerResults cr);
-
- protected abstract void ParseLinkerOutput (string errorString, CompilerResults cr);
-
- protected string GeneratePkgLinkerArgs (ProjectPackageCollection packages)
- {
- return GeneratePkgConfigArgs (packages, "--libs");
- }
-
- protected string GeneratePkgCompilerArgs (ProjectPackageCollection packages)
- {
- return GeneratePkgConfigArgs (packages, "--cflags");
- }
-
- protected static string GeneratePkgConfigArgs (ProjectPackageCollection packages, string pkgConfigArg)
- {
- if (packages == null || packages.Count < 1)
- return string.Empty;
- string originalPkgConfigPath = Environment.GetEnvironmentVariable ("PKG_CONFIG_PATH");
- string pkgConfigPath = originalPkgConfigPath;
-
- StringBuilder libs = new StringBuilder ();
-
- foreach (Package p in packages) {
- if (Path.IsPathRooted (p.File)) {
- pkgConfigPath = string.Format ("{0}{1}{2}", pkgConfigPath, Path.PathSeparator, Path.GetDirectoryName (p.File));
- libs.Append (Path.GetFileNameWithoutExtension (p.File) + " ");
- } else {
- libs.Append (p.File + " ");
- }
- }
-
- string args = string.Format ("{0} \"{1}\"", pkgConfigArg, libs.ToString ().Trim ());
-
- StringWriter output = new StringWriter ();
- ProcessWrapper proc = new ProcessWrapper ();
-
- try {
- Environment.SetEnvironmentVariable ("PKG_CONFIG_PATH", pkgConfigPath);
- proc = Runtime.ProcessService.StartProcess ("pkg-config", args, null, null);
- proc.WaitForExit ();
-
- string line;
- while ((line = proc.StandardOutput.ReadLine ()) != null)
- output.WriteLine (line);
- } catch (Exception ex) {
- MessageService.ShowError ("You need to have pkg-config installed");
- } finally {
- proc.Close ();
- Environment.SetEnvironmentVariable ("PKG_CONFIG_PATH", originalPkgConfigPath);
- }
-
- return output.ToString ();
- }
- }
-}
diff --git a/cbindingreport/cbinding/cbinding/parser/cdocumentparser.cs b/caddin/cbinding/cbinding/parser/cdocumentparser.cs
index ba64f1c..a036a94 100644
--- a/cbindingreport/cbinding/cbinding/parser/cdocumentparser.cs
+++ b/caddin/cbinding/cbinding/parser/cdocumentparser.cs
@@ -26,6 +26,7 @@
using System;
using MonoDevelop.Ide.TypeSystem;
+using MonoDevelop.Projects;
using System.Threading;
using System.Threading.Tasks;
@@ -38,11 +39,10 @@ namespace CBinding.Parser
/// </summary>
public class CDocumentParser: TypeSystemParser
{
-
public override Task<ParsedDocument> Parse(ParseOptions options, CancellationToken cancellationToken)
{
var fileName = options.FileName;
- var project = (CProject)options.Project;
+ var project = (CMakeProject)(options.Project as SolutionItem);
if (project == null || !project.HasLibClang)
return Task.FromResult ((ParsedDocument)new DefaultParsedDocument (fileName));
diff --git a/cbindingreport/cbinding/cbinding/compiler/clangccompiler.cs b/clangccompiler.cs
index 22dc5e4..e69de29 100644
--- a/cbindingreport/cbinding/cbinding/compiler/clangccompiler.cs
+++ b/clangccompiler.cs
@@ -1,55 +0,0 @@
-//
-// ClangCCompiler.cs: Provides functionality to compile using clang
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin@gmail.com>
-// Guba Dániel Olivér <gudaol@gmx.com>
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using Mono.Addins;
-
-
-namespace CBinding
-{
- [Extension ("/CBinding/Compilers")]
- public class ClangCCompiler : GNUCompiler
- {
- public override string Name {
- get { return "clang"; }
- }
-
- public override Language Language {
- get { return Language.C; }
- }
-
- public ClangCCompiler ()
- {
- compilerCommand = "clang";
- linkerCommand = "clang";
- }
- }
-}
diff --git a/cbindingreport/cbinding/cbinding/compiler/clangcxxcompiler.cs b/clangcxxcompiler.cs
index 2535421..e69de29 100644
--- a/cbindingreport/cbinding/cbinding/compiler/clangcxxcompiler.cs
+++ b/clangcxxcompiler.cs
@@ -1,55 +0,0 @@
-//
-// ClangCXXCompiler.cs: Provides functionality to compile using clang++
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin@gmail.com>
-// Guba Dániel Olivér <gudaol@gmx.com>
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-
-using Mono.Addins;
-
-
-namespace CBinding
-{
- [Extension ("/CBinding/Compilers")]
- public class ClangCXXCompiler : GNUCompiler
- {
- public override string Name {
- get { return "clang++"; }
- }
-
- public override Language Language {
- get { return Language.CPP; }
- }
-
- public ClangCXXCompiler ()
- {
- compilerCommand = "clang++";
- linkerCommand = "clang++";
- }
- }
-}
diff --git a/cbindingreport/cbinding/cbinding/clang/clangmanager.cs b/caddin/cbinding/cbinding/clang/clangmanager.cs
index bdcac3b..705e5e2 100644
--- a/cbindingreport/cbinding/cbinding/clang/clangmanager.cs
+++ b/caddin/cbinding/cbinding/clang/clangmanager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -21,7 +21,7 @@ namespace CBinding
/// and the translation units itself are not.
/// For more information see the field SyncRoot
/// </summary>
- public class CLangManager : IDisposable
+ public class CLangManager : CMakeProject, IDisposable
{
/// <summary>
/// The sync root.
@@ -33,32 +33,23 @@ namespace CBinding
/// while reparsing is in progress in an other file could result in a fault.
/// </summary>
public readonly object SyncRoot = new object ();
- CProject project;
+ CMakeProject project;
CXIndex index;
Dictionary<string, CXTranslationUnit> translationUnits { get; }
SerializationManager SerManager { get; }
-
Dictionary<string, bool> Loaded { get; }
+ CMakeToolchain cmakeToolchain;
/// <summary>
/// Gets the command line arguments. Use with caution, when the project is not fully loaded and there are no active configuration yet, it will fail with nullrefexception.
/// </summary>
/// <value>The arguments.</value>
- public string [] CmdArguments (string name) {
- var compiler = new ClangCCompiler ();
+ public string [] CmdArguments (string name)
+ {
+ cmakeToolchain = CMakeToolchain.GetToolchain ();
var active_configuration =
- (CProjectConfiguration)project.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
- var args = new List<string> (compiler.GetCompilerFlagsAsArray (project, active_configuration));
- if (CProject.SourceExtensions.Any(o => o.Equals (new FilePath(name).Extension.ToUpper ()))) {
- foreach (var f in project.Files) {
- if (CProject.HeaderExtensions.Any (o => o.Equals (f.FilePath.Extension.ToUpper ()))) {
- if (File.Exists (f.Name + ".pch")) {
- args.Add ("-include-pch");
- args.Add (f.Name + ".pch");
- }
- }
- }
- }
+ project.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
+ var args = new List<string> (cmakeToolchain.GetCompilerFlagsAsArray ());
return args.ToArray ();
}
@@ -66,12 +57,12 @@ namespace CBinding
/// Constructor
/// </summary>
/// <param name="proj">
- /// A <see cref="CProject"/> reference: project which the manager manages
+ /// A <see cref="CMakeProject"/> reference: project which the manager manages
/// </param>
- public CLangManager (CProject proj)
+ public CLangManager (CMakeProject proj)
{
project = proj;
- index = clang.createIndex (0, 0);
+ index = clang.createIndex (0, 0); // FIXME:- This is always giving DLLNOTFOUNDEXCEPTION during initialization of CMakeProject.
SerManager = new SerializationManager (project, this, index);
translationUnits = new Dictionary<string, CXTranslationUnit> ();
Loaded = new Dictionary<string, bool> ();
@@ -127,7 +118,7 @@ namespace CBinding
if (!SerializationManager.SerFormIsUpToDate (fileName)) {
SerManager.Update (fileName, CmdArguments (fileName));
}
- translationUnits.Add (fileName, clang.createTranslationUnit (index, fileName + ".pch"));
+ translationUnits.Add (fileName, clang.createTranslationUnit (index, fileName));
Loaded [fileName] = true;
} else {
translationUnits.Add (fileName, clang.parseTranslationUnit (
@@ -175,14 +166,14 @@ namespace CBinding
}
}
- void ReparseFilesWithExtension (string [] extensions)
+ void ReparseFilesWithExtension ()
{
var unsavedFiles = project.UnsavedFiles.Get ();
- foreach (var f in project.Files) {
- if (extensions.Any (o => o.Equals (f.FilePath.Extension.ToUpper ()))) {
- if (translationUnits.ContainsKey (f.Name))
- RemoveTranslationUnit (f.Name);
- CreateTranslationUnit (f.Name, unsavedFiles.ToArray ());
+ foreach (var f in OnGetItemFiles (false)) {
+ if(IsCFile (f.Extension.ToUpper ())) {
+ if (translationUnits.ContainsKey (f.FileName))
+ RemoveTranslationUnit (f.FileName);
+ CreateTranslationUnit (f.FileName, unsavedFiles.ToArray ());
}
}
}
@@ -194,8 +185,7 @@ namespace CBinding
{
lock (SyncRoot) {
//to precompile headers before parsing CPP files
- ReparseFilesWithExtension (CProject.HeaderExtensions);
- ReparseFilesWithExtension (CProject.SourceExtensions);
+ ReparseFilesWithExtension ();
}
}
@@ -505,7 +495,7 @@ namespace CBinding
/// <param name="fileName"></param>
public void CheckForBom (string fileName)
{
- if (project.Files.Any (arg => arg.Name.Equals (fileName))) {
+ if (OnGetItemFiles (false).Any (arg => arg.FileName.Equals (fileName))) {
using (var s = new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
var BOM = new byte [3];
s.Read (BOM, 0, 3);
@@ -520,30 +510,15 @@ namespace CBinding
void HandleAddition (object sender, ProjectFileEventArgs args)
{
foreach (var e in args) {
-
CheckForBom (e.ProjectFile.Name);
-
- if (!project.Loading && !project.IsCompileable (e.ProjectFile.Name) &&
- e.ProjectFile.BuildAction == BuildAction.Compile) {
- e.ProjectFile.BuildAction = BuildAction.None;
- }
-
- if (!project.Loading && e.ProjectFile.BuildAction == BuildAction.Compile)
- TypeSystemService.ParseFile (project, e.ProjectFile.Name);
+ SerManager.Add (e.ProjectFile.Name, CmdArguments (e.ProjectFile.Name));
}
}
void HandleChange (object sender, ProjectFileEventArgs args)
{
foreach (var e in args) {
-
CheckForBom (e.ProjectFile.Name);
-
- if (!project.Loading && !project.IsCompileable (e.ProjectFile.Name) &&
- e.ProjectFile.BuildAction == BuildAction.Compile) {
- e.ProjectFile.BuildAction = BuildAction.None;
- }
-
SerManager.Update (e.ProjectFile.Name, CmdArguments (e.ProjectFile.Name));
}
}
@@ -551,13 +526,7 @@ namespace CBinding
void HandleRemoval (object sender, ProjectFileEventArgs args)
{
foreach (var e in args) {
- if (!project.Loading && !project.IsCompileable (e.ProjectFile.Name) &&
- e.ProjectFile.BuildAction == BuildAction.Compile) {
- e.ProjectFile.BuildAction = BuildAction.None;
- }
- if (e.ProjectFile.BuildAction == BuildAction.Compile)
RemoveTranslationUnit (e.ProjectFile.Name);
-
SerManager.Remove (e.ProjectFile.Name);
}
}
diff --git a/clangtoolchain.cs b/caddin/cbinding/cbinding/compiler/ClangToolchain.cs
index e69de29..8840dbd 100644
--- a/clangtoolchain.cs
+++ b/caddin/cbinding/cbinding/compiler/ClangToolchain.cs
@@ -0,0 +1,67 @@
+//
+// ClangToolchain.cs: Provides functionality to compile using Clang Toolchain.
+//
+// Authors:
+// Anubhav Singh <mailtoanubhav02@gmail.com>
+// Copyright (C) 2017 Anubhav Singh
+//
+//
+// This source code is licenced under The MIT License:
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Threading.Tasks;
+using System.IO;
+
+using Mono.Addins;
+
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+
+namespace CBinding
+{
+ [Extension ("/CBinding/Toolchains")]
+ public class ClangToolchain : VisualStudioToolchain
+ {
+
+ /// <summary>
+ /// The name of this Toolchain.
+ /// </summary>
+ /// <value>The name.</value>
+ public override string ToolchainName {
+ get {
+ return "Clang Toolchain";
+ }
+ }
+
+ public override string GeneratorID {
+ get {
+ return "Visual Studio 15 2017";
+ }
+ }
+
+ public override string ToolchainID {
+ get {
+ return "LLVM-vs2014";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/cbindingreport/cbinding/cbinding/parser/class.cs b/caddin/cbinding/cbinding/parser/class.cs
index d65528d..9843c1d 100644
--- a/cbindingreport/cbinding/cbinding/parser/class.cs
+++ b/caddin/cbinding/cbinding/parser/class.cs
@@ -4,7 +4,7 @@ namespace CBinding.Parser
{
public class Class : Symbol
{
- public Class (CProject proj, CXCursor cursor) : base (proj, cursor)
+ public Class (CMakeProject proj, CXCursor cursor) : base (proj, cursor)
{
}
}
diff --git a/cbindingreport/cbinding/cbinding/parser/classtemplate.cs b/caddin/cbinding/cbinding/parser/classtemplate.cs
index 56b1258..0a118f1 100644
--- a/cbindingreport/cbinding/cbinding/parser/classtemplate.cs
+++ b/caddin/cbinding/cbinding/parser/classtemplate.cs
@@ -4,7 +4,7 @@ namespace CBinding.Parser
{
public class ClassTemplate : Class
{
- public ClassTemplate (CProject proj, CXCursor cursor ) : base (proj , cursor)
+ public ClassTemplate (CMakeProject proj, CXCursor cursor ) : base (proj , cursor)
{
}
}
diff --git a/cbindingreport/cbinding/cbinding/parser/classtemplatepartial.cs b/caddin/cbinding/cbinding/parser/classtemplatepartial.cs
index 4a099ff..220ac8a 100644
--- a/cbindingreport/cbinding/cbinding/parser/classtemplatepartial.cs
+++ b/caddin/cbinding/cbinding/parser/classtemplatepartial.cs
@@ -4,7 +4,7 @@ namespace CBinding.Parser
{
public class ClassTemplatePartial : ClassTemplate
{
- public ClassTemplatePartial (CProject proj, CXCursor cursor) : base (proj, cursor)
+ public ClassTemplatePartial (CMakeProject proj, CXCursor cursor) : base (proj, cursor)
{
}
}
diff --git a/cbindingreport/cbinding/cbinding/cmake/cmakeproject.cs b/caddin/cbinding/cbinding/cmake/cmakeproject.cs
index 5a2e129..65b9442 100644
--- a/cbindingreport/cbinding/cbinding/cmake/cmakeproject.cs
+++ b/caddin/cbinding/cbinding/cmake/cmakeproject.cs
@@ -1,4 +1,4 @@
-//
+//
// CMakeProject.cs
//
// Author:
@@ -43,12 +43,48 @@ namespace CBinding
string name;
FilePath outputDirectory = new FilePath ("./bin");
CMakeFileFormat fileFormat;
+ CMakeToolchain cmakeToolchain;
+
+ /// <summary>
+ /// Occurs when a file is removed from this project.
+ /// </summary>
+ public event ProjectFileEventHandler FileRemovedFromProject;
+
+ /// <summary>
+ /// Occurs when a file is added to this project.
+ /// </summary>
+ public event ProjectFileEventHandler FileAddedToProject;
+
+ /// <summary>
+ /// Occurs when a file of this project has been modified
+ /// </summary>
+ public event ProjectFileEventHandler FileChangedInProject;
+
+ /// <summary>
+ /// Occurs when a file of this project has been renamed
+ /// </summary>
+ public event ProjectFileRenamedEventHandler FileRenamedInProject;
+
+
+ public bool HasLibClang { get; private set; }
+
+ public CLangManager ClangManager { get; private set; }
+
+ public SymbolDatabaseMediator DB { get; private set; }
+
+ public UnsavedFilesManager UnsavedFiles { get; private set; }
static readonly string [] supportedLanguages = { "C", "C++", "Objective-C", "Objective-C++" };
- Regex extensions = new Regex (@"(\.c|\.c\+\+|\.cc|\.cpp|\.cxx|\.m|\.mm|\.h|\.hh|\.h\+\+|\.hm|\.hpp|\.hxx|\.in|\.txx)$",
+ static Regex extensions = new Regex (@"(\.c|\.c\+\+|\.cc|\.cpp|\.cxx|\.m|\.mm|\.h|\.hh|\.h\+\+|\.hm|\.hpp|\.hxx|\.in|\.txx)$",
RegexOptions.IgnoreCase);
+ public static bool IsCFile (string file) {
+ if (extensions.IsMatch (file))
+ return true;
+ return false;
+ }
+
public override FilePath FileName {
get {
return file;
@@ -58,18 +94,6 @@ namespace CBinding
}
}
- Stream ExecuteCommand (string command, string args, string workingDir, ProgressMonitor monitor)
- {
- var stream = new MemoryStream ();
- var streamWriter = new StreamWriter (stream);
- FilePath path = file.ParentDirectory.Combine (workingDir);
- ProcessWrapper p = Runtime.ProcessService.StartProcess (command, args, path, monitor.Log, streamWriter, null);
- p.WaitForExit ();
- streamWriter.Flush ();
- stream.Position = 0;
- return stream;
- }
-
bool CheckCMake ()
{
try {
@@ -81,103 +105,6 @@ namespace CBinding
}
}
- Tuple<int, string> GetFileAndLine (string line, string separator)
- {
- int lineNumber = 0;
- string fileName = "";
- string s = line.Split (new string [] { separator }, StringSplitOptions.RemoveEmptyEntries) [1].Trim ();
- string [] args = s.Split (':');
- if (args [0].Length > 0) fileName = args [0];
- if (args.Length > 1 && args [1].Length > 0) {
- if (args [1].Contains ("("))
- int.TryParse (args [1].Split ('(') [0], out lineNumber);
- else
- int.TryParse (args [1], out lineNumber);
- }
-
- return Tuple.Create (lineNumber, fileName);
- }
-
- BuildResult ParseGenerationResult (Stream result, ProgressMonitor monitor)
- {
- var results = new BuildResult ();
- result.Position = 0;
- var sr = new StreamReader (result);
- var sb = new StringBuilder ();
- string line;
- string fileName = "";
- int lineNumber = 0;
- bool isWarning = false;
-
- while ((line = sr.ReadLine ()) != null) {
- //e.g. CMake Warning in/at CMakeLists.txt:10 (COMMAND):
- //or: CMake Warning:
- if (line.StartsWith ("CMake Warning", StringComparison.OrdinalIgnoreCase)) {
- //reset everything and add last error or warning.
- if (sb.Length > 0) {
- if (isWarning)
- results.AddWarning (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- else
- results.AddError (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- }
-
- sb.Clear ();
- fileName = "";
- lineNumber = 0;
- isWarning = true;
-
- // in/at CMakeLists.txt:10 (COMMAND):
- if (line.Contains (" in ")) {
- Tuple<int, string> t = GetFileAndLine (line, " in ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else if (line.Contains (" at ")) {
- Tuple<int, string> t = GetFileAndLine (line, " at ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else {
- string [] warning = line.Split (':');
- if (!string.IsNullOrEmpty (warning.ElementAtOrDefault (1))) {
- sb.Append (warning [1]);
- }
- }
- } else if (line.StartsWith ("CMake Error", StringComparison.OrdinalIgnoreCase)) {
- //reset everything and add last error or warning.
- if (sb.Length > 0) {
- if (isWarning)
- results.AddWarning (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- else
- results.AddError (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- }
-
- sb.Clear ();
- fileName = "";
- lineNumber = 0;
- isWarning = false;
-
- // in/at CMakeLists.txt:10 (COMMAND):
- if (line.Contains (" in ")) {
- Tuple<int, string> t = GetFileAndLine (line, " in ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else if (line.Contains (" at ")) {
- Tuple<int, string> t = GetFileAndLine (line, " at ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else {
- string [] error = line.Split (':');
- if (!string.IsNullOrEmpty (error.ElementAtOrDefault (1))) {
- sb.Append (error [1]);
- }
- }
- } else {
- sb.Append (line);
- }
- }
-
- return results;
- }
-
public void RemoveTarget (string targetName)
{
fileFormat.RemoveTarget (targetName);
@@ -193,6 +120,31 @@ namespace CBinding
return name;
}
+ public string MatchingFile (string sourceFile)
+ {
+ string filenameStub = Path.GetFileNameWithoutExtension (sourceFile);
+ bool wantHeader = !CMakeProject.IsHeaderFile (sourceFile);
+
+ foreach (FilePath file in OnGetItemFiles (false)) {
+ if (filenameStub == Path.GetFileNameWithoutExtension (file.FileName)
+ && (wantHeader == IsHeaderFile (file.FileName))) {
+ return file.FileName;
+ }
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// Determines if a header file is specified by filename.
+ /// </summary>
+ /// <returns><c>true</c> if a header file is specified by filename; otherwise, <c>false</c>.</returns>
+ /// <param name="filename">Filename.</param>
+ public static bool IsHeaderFile (string filename)
+ {
+ return (0 <= Array.IndexOf (extensions.Split ("|").ToArray (), Path.GetExtension (filename.ToUpper ())));
+ }
+
public void LoadFrom (FilePath file)
{
this.file = file;
@@ -247,10 +199,9 @@ namespace CBinding
}
}
- protected override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration,
+ protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration,
OperationContext operationContext)
{
- return Task.Factory.StartNew (() => {
BuildResult results;
if (!CheckCMake ()) {
@@ -261,33 +212,19 @@ namespace CBinding
FileService.CreateDirectory (file.ParentDirectory.Combine (outputDirectory));
- monitor.BeginStep ("Generating build files.");
- Stream generationResult = ExecuteCommand ("cmake", "../", outputDirectory, monitor);
- results = ParseGenerationResult (generationResult, monitor);
- monitor.EndStep ();
-
- monitor.BeginStep ("Building...");
- Stream buildResult = ExecuteCommand ("cmake", "--build ./ --clean-first", outputDirectory, monitor);
- //TODO: Parse results.
- monitor.EndStep ();
+ cmakeToolchain = CMakeToolchain.GetToolchain ();
+ cmakeToolchain.setFileLocation (file);
+ results = await cmakeToolchain.GenerateMakefiles (fileFormat.ProjectName, outputDirectory, monitor);
return results;
- });
+
}
- protected override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration,
+ protected async override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration,
OperationContext buildSession)
{
- return Task.Factory.StartNew (() => {
- var results = new BuildResult ();
-
- FilePath path = BaseDirectory.Combine (outputDirectory);
- if (Directory.Exists (path)) {
- FileService.DeleteDirectory (path);
- }
-
+ BuildResult results = await cmakeToolchain.Clean (fileFormat.ProjectName, outputDirectory, monitor);
return results;
- });
}
protected override Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
@@ -306,7 +243,6 @@ namespace CBinding
monitor.ReportError ("Can't find an executable target.");
return;
}
-
FilePath f = BaseDirectory.Combine (outputDirectory);
NativeExecutionCommand cmd;
if (File.Exists (f.Combine (targetName)))
@@ -355,6 +291,8 @@ namespace CBinding
{
base.OnFileRemoved (file);
+ FileRemovedFromProject?.Invoke (this, new ProjectFileEventArgs ());
+
foreach (var target in fileFormat.Targets.Values.ToList ()) {
target.RemoveFile (file);
}
@@ -377,6 +315,8 @@ namespace CBinding
{
base.OnFileRenamed (oldFile, newFile);
+ // FileRenamedInProject?.Invoke (this, new ProjectFileRenamedEventArgs ()); FIXME:- Need a fix
+
var oldFiles = new List<FilePath> () { oldFile };
var newFiles = new List<FilePath> () { newFile };
@@ -423,13 +363,25 @@ namespace CBinding
fileFormat.SaveAll ();
}
+ public override void OnFileChanged (FilePath file)
+ {
+ base.OnFileChanged (file);
+
+ if (!IsCFile (file))
+ return;
+
+ FileChangedInProject?.Invoke (this, new ProjectFileEventArgs ());
+ }
+
public override void OnFileAdded (FilePath file)
{
base.OnFileAdded (file);
- if (!extensions.IsMatch (file))
+ if (!IsCFile (file))
return;
+ FileAddedToProject?.Invoke (this, new ProjectFileEventArgs ());
+
using (var dlg = new TargetPickerDialog ("Pick a target", fileFormat)) {
if (MessageService.ShowCustomDialog (dlg) != (int)ResponseType.Ok)
return;
@@ -448,7 +400,7 @@ namespace CBinding
var filesToAdd = new List<FilePath> ();
foreach (var file in files) {
- if (extensions.IsMatch (file))
+ if (IsCFile (file))
filesToAdd.Add (file);
}
@@ -496,5 +448,22 @@ namespace CBinding
{
Initialize (this);
}
+
+ /// <summary>
+ /// Initialize this instance.
+ /// </summary>
+ protected override void OnInitialize ()
+ {
+ base.OnInitialize ();
+ try {
+ ClangManager = new CLangManager (this);
+ DB = new SymbolDatabaseMediator (this, ClangManager);
+ UnsavedFiles = new UnsavedFilesManager (this);
+ HasLibClang = true;
+ } catch (DllNotFoundException ex) {
+ LoggingService.LogError ("Could not load libclang", ex);
+ HasLibClang = false;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/cbindingreport/cbinding/cbinding/cmake/cmaketexteditorextension.cs b/caddin/cbinding/cbinding/cmake/cmaketexteditorextension.cs
index b50762c..5e83aab 100644
--- a/cbindingreport/cbinding/cbinding/cmake/cmaketexteditorextension.cs
+++ b/caddin/cbinding/cbinding/cmake/cmaketexteditorextension.cs
@@ -94,10 +94,10 @@ namespace CBinding
}
public override Task<ICompletionDataList> HandleCodeCompletionAsync (CodeCompletionContext completionContext,
- char completionChar,
+ CompletionTriggerInfo triggerInfo,
CancellationToken token = default (CancellationToken))
{
- if (!char.IsLetter (completionChar))
+ if (triggerInfo.TriggerCharacter == null)
return null;
if (completionContext.TriggerOffset > 1 &&
diff --git a/cmaketoolchain.cs b/caddin/cbinding/cbinding/compiler/CMakeToolchain.cs
index e69de29..58835dc 100644
--- a/cmaketoolchain.cs
+++ b/caddin/cbinding/cbinding/compiler/CMakeToolchain.cs
@@ -0,0 +1,296 @@
+//
+// CMakeToolchain.cs: Abstract class that provides functionality to compile using various CMake Toolchains
+//
+// Authors:
+// Anubhav Singh <mailtoanubhav02@gmail.com>
+// Copyright (C) 2017 Anubhav Singh
+//
+//
+// This source code is licenced under The MIT License:
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Threading.Tasks;
+using System.IO;
+using System.Text;
+using System.Linq;
+
+using Mono.Addins;
+
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using MonoDevelop.Core.Execution;
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace CBinding
+{
+ [TypeExtensionPoint ("/CBinding/Toolchains")]
+ public class CMakeToolchain
+ {
+ FilePath file;
+
+ /// <summary>
+ /// Name of the toolchain.
+ /// </summary>
+ public virtual string ToolchainName {
+ get;
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether this Toolchain is supported for the Platform or not.
+ /// </summary>
+ public virtual bool IsSupported {
+ get;
+ }
+
+ /// <summary>
+ /// CMake generator id for this toolchain.
+ /// </summary>
+ public virtual string GeneratorID => "";
+
+ /// <summary>
+ /// CMake toolchain id for this toolchain.
+ /// </summary>
+ public virtual string ToolchainID => "";
+
+ /// <summary>
+ /// Creates the CMake cache entry.
+ /// </summary>
+ public virtual string CMakeCacheEntry => "";
+
+ public virtual string ProjectToBuild {
+ get;
+ set;
+ }
+
+ public string [] GetCompilerFlagsAsArray ()
+ {
+ FilePath outputDirectory = new FilePath ("./bin");
+ List<string> compileCommands = new List<string> ();
+ FilePath f = (file.ParentDirectory.Combine (outputDirectory)).Combine ("compile_commands.json");
+ if (File.Exists (f))
+ {
+ using (StreamReader r = new StreamReader ("compile_commands.json"))
+ {
+ string json = r.ReadToEnd ();
+ dynamic compilationDatabase = JsonConvert.DeserializeObject (json);
+ foreach (var commandObject in compilationDatabase) {
+ if (commandObject.command.Contains ("-o")) //FIXME:- changes needed - Only two flags added..
+ compileCommands.Add ("-o");
+ if (commandObject.command.Contains ("-c"))
+ compileCommands.Add ("-c");
+ }
+ }
+ }
+ return compileCommands.ToArray ();
+ }
+
+ Tuple<int, string> GetFileAndLine (string line, string separator)
+ {
+ int lineNumber = 0;
+ string fileName = "";
+ string s = line.Split (new string [] { separator }, StringSplitOptions.RemoveEmptyEntries) [1].Trim ();
+ string [] args = s.Split (':');
+ if (args [0].Length > 0) fileName = args [0];
+ if (args.Length > 1 && args [1].Length > 0) {
+ if (args [1].Contains ("("))
+ int.TryParse (args [1].Split ('(') [0], out lineNumber);
+ else
+ int.TryParse (args [1], out lineNumber);
+ }
+
+ return Tuple.Create (lineNumber, fileName);
+ }
+
+ public void setFileLocation (string file)
+ {
+ this.file = file;
+ }
+
+ protected Stream ExecuteCommand (string command, string args, string workingDir, ProgressMonitor monitor)
+ {
+ var stream = new MemoryStream ();
+ var streamWriter = new StreamWriter (stream);
+ FilePath path = file.ParentDirectory.Combine (workingDir);
+ ProcessWrapper p = Runtime.ProcessService.StartProcess (command, args, path, monitor.Log, streamWriter, null);
+ p.WaitForExit ();
+ streamWriter.Flush ();
+ stream.Position = 0;
+ return stream;
+ }
+
+ protected BuildResult ParseGenerationResult (Stream result, ProgressMonitor monitor)
+ {
+ var results = new BuildResult ();
+ result.Position = 0;
+ var sr = new StreamReader (result);
+ var sb = new StringBuilder ();
+ string line;
+ string fileName = "";
+ int lineNumber = 0;
+ bool isWarning = false;
+
+ while ((line = sr.ReadLine ()) != null) {
+ //e.g. CMake Warning in/at CMakeLists.txt:10 (COMMAND):
+ //or: CMake Warning:
+ if (line.StartsWith ("CMake Warning", StringComparison.OrdinalIgnoreCase)) {
+ //reset everything and add last error or warning.
+ if (sb.Length > 0) {
+ if (isWarning)
+ results.AddWarning (fileName, lineNumber, 0, "", sb.ToString ());
+ else
+ results.AddError (fileName, lineNumber, 0, "", sb.ToString ());
+ }
+
+ sb.Clear ();
+ fileName = "";
+ lineNumber = 0;
+ isWarning = true;
+
+ // in/at CMakeLists.txt:10 (COMMAND):
+ if (line.Contains (" in ")) {
+ Tuple<int, string> t = GetFileAndLine (line, " in ");
+ lineNumber = t.Item1;
+ fileName = t.Item2;
+ } else if (line.Contains (" at ")) {
+ Tuple<int, string> t = GetFileAndLine (line, " at ");
+ lineNumber = t.Item1;
+ fileName = t.Item2;
+ } else {
+ string [] warning = line.Split (':');
+ if (!string.IsNullOrEmpty (warning.ElementAtOrDefault (1))) {
+ sb.Append (warning [1]);
+ }
+ }
+ } else if (line.StartsWith ("CMake Error", StringComparison.OrdinalIgnoreCase)) {
+ //reset everything and add last error or warning.
+ if (sb.Length > 0) {
+ if (isWarning)
+ results.AddWarning (fileName, lineNumber, 0, "", sb.ToString ());
+ else
+ results.AddError (fileName, lineNumber, 0, "", sb.ToString ());
+ }
+
+ sb.Clear ();
+ fileName = "";
+ lineNumber = 0;
+ isWarning = false;
+
+ // in/at CMakeLists.txt:10 (COMMAND):
+ if (line.Contains (" in ")) {
+ Tuple<int, string> t = GetFileAndLine (line, " in ");
+ lineNumber = t.Item1;
+ fileName = t.Item2;
+ } else if (line.Contains (" at ")) {
+ Tuple<int, string> t = GetFileAndLine (line, " at ");
+ lineNumber = t.Item1;
+ fileName = t.Item2;
+ } else {
+ string [] error = line.Split (':');
+ if (!string.IsNullOrEmpty (error.ElementAtOrDefault (1))) {
+ sb.Append (error [1]);
+ }
+ }
+ } else {
+ sb.Append (line);
+ }
+ }
+
+ return results;
+ }
+
+ public static CMakeToolchain GetToolchain ()
+ {
+ string toolchainName;
+ toolchainName = PropertyService.Get<string> ("CBinding.DefaultToolchain", null);
+ return AddinManager.GetExtensionObjects<CMakeToolchain> ("/CBinding/Toolchains")
+ .FirstOrDefault<CMakeToolchain> (toolchain => toolchain.ToolchainName == toolchainName)
+ ?? GetDefaultToolchain ();
+ }
+
+ public static CMakeToolchain GetDefaultToolchain ()
+ {
+ if (Platform.IsWindows)
+ return new MinGW32Toolchain ();
+ else if (Platform.IsLinux)
+ return new UnixMakeToolchain ();
+ else if (Platform.IsMac)
+ return new MacMakeToolchain ();
+ else return new MinGW32Toolchain ();
+ }
+
+ /// <summary>
+ /// Use cmake to generate makefiles for this toolchain.
+ /// </summary>
+ /// <returns>The makefiles.</returns>
+ /// <param name="projectName">Project name.</param>
+ /// <param name="outputDirectory">Output directory.</param>
+ /// <param name="monitor">Monitor.</param>
+ public virtual Task<BuildResult> GenerateMakefiles (string projectName, FilePath outputDirectory, ProgressMonitor monitor)
+ {
+ string arguments = "../";
+ if(!string.IsNullOrEmpty (GeneratorID)) {
+ arguments += $" -G\"{GeneratorID}\"";
+ }
+ if(!string.IsNullOrEmpty (ToolchainID)) {
+ arguments += $" -T\"{ToolchainID}\"";
+ }
+ if(!string.IsNullOrEmpty (CMakeCacheEntry)) {
+ arguments += $" -D{CMakeCacheEntry}";
+ }
+
+ monitor.BeginStep ("Generating build files...");
+ Stream generationResult = ExecuteCommand ("cmake", arguments, outputDirectory, monitor);
+ BuildResult results = ParseGenerationResult (generationResult, monitor);
+ monitor.EndStep ();
+
+ Task<Stream> buildResult = Build (projectName, outputDirectory, monitor);
+
+ return Task.FromResult (results);
+ }
+
+ public virtual Task<Stream> Build (string projectName, FilePath outputDirectory, ProgressMonitor monitor)
+ {
+ monitor.BeginStep ("Building...");
+ Stream buildResult = ExecuteCommand ("cmake", "--build ./", outputDirectory, monitor);
+ monitor.EndStep ();
+ return Task.FromResult (buildResult);
+ }
+
+ public virtual Task<BuildResult> Clean (string projectName, FilePath outputDirectory, ProgressMonitor monitor)
+ {
+ monitor.BeginStep ("Cleaning...");
+ Stream buildResult = ExecuteCommand ("cmake", "--build ./ --target clean", outputDirectory, monitor);
+ monitor.EndStep ();
+ BuildResult results = ParseGenerationResult (buildResult, monitor);
+ return Task.FromResult (results);
+ }
+
+ public virtual Task<Stream> Rebuild (string projectName, FilePath outputDirectory, ProgressMonitor monitor)
+ {
+ monitor.BeginStep ("Rebuilding...");
+ Stream buildResult = ExecuteCommand ("cmake", "--build ./ --clean-first", outputDirectory, monitor);
+ monitor.EndStep ();
+ return Task.FromResult (buildResult);
+ }
+ }
+}
\ No newline at end of file
diff --git a/cbindingreport/cbinding/cbinding/gui/codegenerationpanel.cs b/codegenerationpanel.cs
index 3940f30..e69de29 100644
--- a/cbindingreport/cbinding/cbinding/gui/codegenerationpanel.cs
+++ b/codegenerationpanel.cs
@@ -1,418 +0,0 @@
-//
-// CodeGenerationPanel.cs: Code generation panel to configure project
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin@gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui.Dialogs;
-using MonoDevelop.Components;
-using MonoDevelop.Ide;
-using MonoDevelop.Projects;
-
-namespace CBinding
-{
- public partial class CodeGenerationPanel : Gtk.Bin
- {
- private CProjectConfiguration configuration;
- private Gtk.ListStore libStore = new Gtk.ListStore (typeof(string));
- private Gtk.ListStore libPathStore = new Gtk.ListStore (typeof(string));
- private Gtk.ListStore includePathStore = new Gtk.ListStore (typeof(string));
-
- static string[,] quickPathInsertMenu = new string[,] {
- { GettextCatalog.GetString ("_Project Directory"), "${ProjectDir}" },
- { GettextCatalog.GetString ("_Root Solution Directory"), "${CombineDir}" },
- };
-
- public CodeGenerationPanel ()
- {
- this.Build ();
-
- Gtk.CellRendererText textRenderer = new Gtk.CellRendererText ();
-
- libTreeView.Model = libStore;
- libTreeView.HeadersVisible = false;
- libTreeView.AppendColumn ("Library", textRenderer, "text", 0);
-
- libPathTreeView.Model = libPathStore;
- libPathTreeView.HeadersVisible = false;
- libPathTreeView.AppendColumn ("Library", textRenderer, "text", 0);
-
- includePathTreeView.Model = includePathStore;
- includePathTreeView.HeadersVisible = false;
- includePathTreeView.AppendColumn ("Include", textRenderer, "text", 0);
-
- new MenuButtonEntry (libPathEntry, quickInsertLibButton, quickPathInsertMenu);
- new MenuButtonEntry (includePathEntry, quickInsertIncludeButton, quickPathInsertMenu);
- }
-
- public void Load (CProjectConfiguration config)
- {
- configuration = config;
-
- switch (configuration.CVersion) {
- case CVersion.CustomVersionString:
- CVersionComboBox.Active = 0;
- customVersionStringTextEntry.Text = configuration.CustomVersionString;
- break;
- case CVersion.ISOC:
- CVersionComboBox.Active = 1;
- break;
- case CVersion.C99:
- CVersionComboBox.Active = 2;
- break;
- case CVersion.C11:
- CVersionComboBox.Active = 3;
- break;
- case CVersion.ISOCPP:
- CVersionComboBox.Active = 4;
- break;
- case CVersion.CPP03:
- CVersionComboBox.Active = 5;
- break;
- case CVersion.CPP11:
- CVersionComboBox.Active = 6;
- break;
- }
-
- switch (configuration.WarningLevel) {
- case WarningLevel.None:
- noWarningRadio.Active = true;
- break;
- case WarningLevel.Normal:
- normalWarningRadio.Active = true;
- break;
- case WarningLevel.All:
- allWarningRadio.Active = true;
- break;
- }
-
- warningsAsErrorsCheckBox.Active = configuration.WarningsAsErrors;
-
- optimizationSpinButton.Value = configuration.OptimizationLevel;
-
- switch (configuration.CompileTarget) {
- case CompileTarget.Exe:
- targetComboBox.Active = 0;
- break;
- case CompileTarget.Library:
- targetComboBox.Active = 1;
- break;
- case CompileTarget.Module:
- targetComboBox.Active = 2;
- break;
- }
-
- extraCompilerTextView.Buffer.Text = configuration.ExtraCompilerArguments;
-
- extraLinkerTextView.Buffer.Text = configuration.ExtraLinkerArguments;
-
- defineSymbolsTextEntry.Text = configuration.DefineSymbols;
-
- libStore.Clear ();
- foreach (string lib in configuration.Libs)
- libStore.AppendValues (lib);
-
- libPathStore.Clear ();
- foreach (string libPath in configuration.LibPaths)
- libPathStore.AppendValues (libPath);
-
- includePathStore.Clear ();
- foreach (string includePath in configuration.Includes)
- includePathStore.AppendValues (includePath);
- }
-
- private void OnIncludePathAdded (object sender, EventArgs e)
- {
- if (includePathEntry.Text.Length > 0) {
- includePathStore.AppendValues (includePathEntry.Text);
- includePathEntry.Text = string.Empty;
- }
- }
-
- private void OnIncludePathRemoved (object sender, EventArgs e)
- {
- Gtk.TreeIter iter;
- includePathTreeView.Selection.GetSelected (out iter);
- includePathStore.Remove (ref iter);
- }
-
- private void OnLibPathAdded (object sender, EventArgs e)
- {
- if (libPathEntry.Text.Length > 0) {
- libPathStore.AppendValues (libPathEntry.Text);
- libPathEntry.Text = string.Empty;
- }
- }
-
- private void OnLibPathRemoved (object sender, EventArgs e)
- {
- Gtk.TreeIter iter;
- libPathTreeView.Selection.GetSelected (out iter);
- libPathStore.Remove (ref iter);
- }
-
- private void OnLibAdded (object sender, EventArgs e)
- {
- if (libAddEntry.Text.Length > 0) {
- libStore.AppendValues (libAddEntry.Text);
- libAddEntry.Text = string.Empty;
- }
- }
-
- private void OnLibRemoved (object sender, EventArgs e)
- {
- Gtk.TreeIter iter;
- libTreeView.Selection.GetSelected (out iter);
- libStore.Remove (ref iter);
- }
-
- // TODO: This is platform specific... the C Binding should have a global list of 'standard' library dirs...
- internal const string DEFAULT_LIB_DIR = "/usr/lib";
- internal const string DEFAULT_INCLUDE_DIR = "/usr/lib";
- internal const string STATIC_LIB_FILTER = "*.a";
- internal const string DYNAMIC_LIB_FILTER = "*.so";
-
- private void OnBrowseButtonClick (object sender, EventArgs e)
- {
- var dialog = new MonoDevelop.Components.SelectFileDialog (GettextCatalog.GetString ("Add Library")) {
- TransientFor = (Gtk.Window)Toplevel,
- CurrentFolder = DEFAULT_LIB_DIR,
- };
-
- dialog.AddFilter (GettextCatalog.GetString ("Static Library"), STATIC_LIB_FILTER);
- dialog.AddFilter (GettextCatalog.GetString ("Dynamic Library"), DYNAMIC_LIB_FILTER);
- dialog.AddAllFilesFilter ();
-
- if (dialog.Run ())
- libAddEntry.Text = dialog.SelectedFile;
- }
-
- private void OnIncludePathBrowseButtonClick (object sender, EventArgs e)
- {
- var dialog = new MonoDevelop.Components.SelectFolderDialog (GettextCatalog.GetString ("Add Path")) {
- TransientFor = (Gtk.Window)Toplevel,
- CurrentFolder = DEFAULT_INCLUDE_DIR,
- };
-
- if (dialog.Run ())
- includePathEntry.Text = dialog.SelectedFile;
- }
-
- private void OnLibPathBrowseButtonClick (object sender, EventArgs e)
- {
- var dialog = new MonoDevelop.Components.SelectFolderDialog (GettextCatalog.GetString ("Add Path")) {
- TransientFor = (Gtk.Window)Toplevel,
- CurrentFolder = DEFAULT_LIB_DIR,
- };
-
- if (dialog.Run ())
- libPathEntry.Text = dialog.SelectedFile;
- }
-
- public bool Store ()
- {
- if (configuration == null)
- return false;
-
- string line;
-
- Gtk.TreeIter iter;
- switch (CVersionComboBox.Active) {
- case 0:
- configuration.CVersion = CVersion.CustomVersionString;
- configuration.CustomVersionString = customVersionStringTextEntry.Text;
- break;
- case 1:
- configuration.CVersion = CVersion.ISOC;
- break;
- case 2:
- configuration.CVersion = CVersion.C99;
- break;
- case 3:
- configuration.CVersion = CVersion.C11;
- break;
- case 4:
- configuration.CVersion = CVersion.ISOCPP;
- break;
- case 5:
- configuration.CVersion = CVersion.CPP03;
- break;
- case 6:
- configuration.CVersion = CVersion.CPP11;
- break;
- }
-
-
- if (noWarningRadio.Active)
- configuration.WarningLevel = WarningLevel.None;
- else if (normalWarningRadio.Active)
- configuration.WarningLevel = WarningLevel.Normal;
- else
- configuration.WarningLevel = WarningLevel.All;
-
- configuration.WarningsAsErrors = warningsAsErrorsCheckBox.Active;
-
- configuration.OptimizationLevel = (int)optimizationSpinButton.Value;
-
- switch (targetComboBox.ActiveText) {
- case "Executable":
- configuration.CompileTarget = CompileTarget.Exe;
- break;
- case "Static Library":
- configuration.CompileTarget = CompileTarget.Library;
- break;
- case "Shared Object":
- configuration.CompileTarget = CompileTarget.Module;
- break;
- }
-
- configuration.ExtraCompilerArguments = extraCompilerTextView.Buffer.Text;
-
- configuration.ExtraLinkerArguments = extraLinkerTextView.Buffer.Text;
-
- configuration.DefineSymbols = defineSymbolsTextEntry.Text;
-
- libStore.GetIterFirst (out iter);
- configuration.Libs.Clear ();
- while (libStore.IterIsValid (iter)) {
- line = (string)libStore.GetValue (iter, 0);
- configuration.Libs.Add (line);
- libStore.IterNext (ref iter);
- }
-
- libPathStore.GetIterFirst (out iter);
- configuration.LibPaths.Clear ();
- while (libPathStore.IterIsValid (iter)) {
- line = (string)libPathStore.GetValue (iter, 0);
- configuration.LibPaths.Add (line);
- libPathStore.IterNext (ref iter);
- }
-
- includePathStore.GetIterFirst (out iter);
- configuration.Includes.Clear ();
- while (includePathStore.IterIsValid (iter)) {
- line = (string)includePathStore.GetValue (iter, 0);
- configuration.Includes.Add (line);
- includePathStore.IterNext (ref iter);
- }
-
- return true;
- }
-
- protected virtual void OnLibAddEntryChanged (object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty (libAddEntry.Text))
- addLibButton.Sensitive = false;
- else
- addLibButton.Sensitive = true;
- }
-
- protected virtual void OnLibTreeViewCursorChanged (object sender, System.EventArgs e)
- {
- removeLibButton.Sensitive = true;
- }
-
- protected virtual void OnRemoveLibButtonClicked (object sender, System.EventArgs e)
- {
- removeLibButton.Sensitive = false;
- }
-
- protected virtual void OnIncludePathEntryChanged (object sender, System.EventArgs e)
- {
- if (string.IsNullOrEmpty (includePathEntry.Text))
- includePathAddButton.Sensitive = false;
- else
- includePathAddButton.Sensitive = true;
- }
-
- protected virtual void OnLibPathEntryChanged (object sender, System.EventArgs e)
- {
- if (string.IsNullOrEmpty (libPathEntry.Text))
- libPathAddButton.Sensitive = false;
- else
- libPathAddButton.Sensitive = true;
- }
-
- protected virtual void OnIncludePathTreeViewCursorChanged (object sender, System.EventArgs e)
- {
- includePathRemoveButton.Sensitive = true;
- }
-
- protected virtual void OnIncludePathRemoveButtonClicked (object sender, System.EventArgs e)
- {
- includePathRemoveButton.Sensitive = false;
- }
-
- protected virtual void OnLibPathTreeViewCursorChanged (object sender, System.EventArgs e)
- {
- libPathRemoveButton.Sensitive = true;
- }
-
- protected virtual void OnLibPathRemoveButtonClicked (object sender, System.EventArgs e)
- {
- libPathRemoveButton.Sensitive = false;
- }
-
- protected virtual void OnLibAddEntryActivated (object sender, System.EventArgs e)
- {
- OnLibAdded (this, new EventArgs ());
- }
-
- protected virtual void OnIncludePathEntryActivated (object sender, System.EventArgs e)
- {
- OnIncludePathAdded (this, new EventArgs ());
- }
-
- protected virtual void OnLibPathEntryActivated (object sender, System.EventArgs e)
- {
- OnLibPathAdded (this, new EventArgs ());
- }
- }
-
- public class CodeGenerationPanelBinding : MultiConfigItemOptionsPanel
- {
- private CodeGenerationPanel panel;
-
- public override Control CreatePanelWidget ()
- {
- return panel = new CodeGenerationPanel ();
- }
-
- public override void LoadConfigData ()
- {
- panel.Load ((CProjectConfiguration)CurrentConfiguration);
- }
-
- public override void ApplyChanges ()
- {
- panel.Store ();
- }
- }
-}
diff --git a/cbindingreport/cbinding/cbinding/gui/compilerpanel.cs b/compilerpanel.cs
index 1cbd7f4..e69de29 100644
--- a/cbindingreport/cbinding/cbinding/gui/compilerpanel.cs
+++ b/compilerpanel.cs
@@ -1,128 +0,0 @@
-//
-// CompilerPanel.cs: Allows the user to select what compiler to use for their project
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin@gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using Mono.Addins;
-
-using MonoDevelop.Components;
-using MonoDevelop.Ide.Gui.Dialogs;
-using MonoDevelop.Ide;
-
-namespace CBinding
-{
- public partial class CompilerPanel : Gtk.Bin
- {
- private CProject project;
- private object[] compilers;
- private ICompiler active_compiler;
-
- public CompilerPanel (CProject project)
- {
- this.Build ();
-
- this.project = project;
-
- compilers = AddinManager.GetExtensionObjects ("/CBinding/Compilers");
-
- foreach (ICompiler compiler in compilers) {
- compilerComboBox.AppendText (compiler.Name);
- }
-
- int active = 0;
- Gtk.TreeIter iter;
- Gtk.ListStore store = (Gtk.ListStore)compilerComboBox.Model;
- store.GetIterFirst (out iter);
- while (store.IterIsValid (iter)) {
- if ((string)store.GetValue (iter, 0) == project.Compiler.Name) {
- break;
- }
- store.IterNext (ref iter);
- active++;
- }
-
- compilerComboBox.Active = active;
-
- useCcacheCheckBox.Active = ((CProjectConfiguration)project.GetConfiguration (IdeApp.Workspace.ActiveConfiguration)).UseCcache;
-
- Update ();
- }
-
- public void Store ()
- {
- if (project == null)
- return;
-
- if (!active_compiler.Equals (project.Compiler)) {
- project.Compiler = active_compiler;
- project.Language = active_compiler.Language;
- }
-
- // Update use_ccache for all configurations
- foreach (CProjectConfiguration conf in project.Configurations)
- conf.UseCcache = useCcacheCheckBox.Active;
- }
-
- protected virtual void OnCompilerComboBoxChanged (object sender, EventArgs e)
- {
- Update ();
- }
-
- private void Update ()
- {
- foreach (ICompiler compiler in compilers) {
- if (compilerComboBox.ActiveText == compiler.Name) {
- active_compiler = compiler;
- break;
- }
- }
-
- if (active_compiler.SupportsCcache)
- useCcacheCheckBox.Sensitive = true;
- else
- useCcacheCheckBox.Sensitive = false;
- }
- }
-
- public class CompilerPanelBinding : ItemOptionsPanel
- {
- CompilerPanel panel;
-
- public override Control CreatePanelWidget ()
- {
- return panel = new CompilerPanel ((CProject)ConfiguredProject);
- }
-
- public override void ApplyChanges ()
- {
- panel.Store ();
- }
- }
-}
diff --git a/cbindingreport/cbinding/cbinding/parser/cparseddocument.cs b/caddin/cbinding/cbinding/parser/cparseddocument.cs
index d703e53..74107fa 100644
--- a/cbindingreport/cbinding/cbinding/parser/cparseddocument.cs
+++ b/caddin/cbinding/cbinding/parser/cparseddocument.cs
@@ -37,17 +37,17 @@ namespace CBinding.Parser
public class CParsedDocument : DefaultParsedDocument {
public CXTranslationUnit TU;
public CLangManager Manager { get; private set;}
- public CProject Project { get; set;}
+ public CMakeProject Project { get; set; }
List<CXUnsavedFile> unsavedFiles;
- void Initialize (CProject proj)
+ void Initialize (CMakeProject proj)
{
Project = proj;
Manager = proj.ClangManager;
unsavedFiles = new List<CXUnsavedFile> ();
}
- public CParsedDocument(CProject proj, string fileName) : base(fileName)
+ public CParsedDocument (CMakeProject proj, string fileName) : base (fileName)
{
Initialize (proj);
unsavedFiles = Project.UnsavedFiles.Get ();
diff --git a/cbindingreport/cbinding/cbinding/project/cproject.cs b/cproject.cs
index 48ff5c6..e69de29 100644
--- a/cbindingreport/cbinding/cbinding/project/cproject.cs
+++ b/cproject.cs
@@ -1,550 +0,0 @@
-//
-// CProject.cs: C/C++ Project
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin@gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Xml;
-using Mono.Addins;
-using MonoDevelop.Core;
-using MonoDevelop.Core.Execution;
-using MonoDevelop.Core.Serialization;
-using MonoDevelop.Ide;
-using MonoDevelop.Projects;
-
-namespace CBinding
-{
- public enum Language {
- C,
- CPP,
- OBJC,
- OBJCPP
- }
-
- public enum CProjectCommands {
- AddPackage,
- UpdateClassPad,
- ShowPackageDetails,
- GotoDeclaration,
- }
-
- [ExportProjectType ("{2857B73E-F847-4B02-9238-064979017E93}", Extension="cproj", Alias="C/C++")]
- public class CProject : Project
- {
- [ItemProperty ("Compiler", ValueType = typeof(CCompiler))]
- public ICompiler CompilerManager { get; set; }
-
- [ItemProperty ("Language")]
- public Language Language { get; set; }
-
- [ItemProperty ("OutputType", DefaultValue = CompileTarget.Exe)]
- public CompileTarget target { get; set; }
-
- public bool HasLibClang { get; private set; }
-
- public CLangManager ClangManager { get; private set; }
-
- public SymbolDatabaseMediator DB { get; private set; }
-
- public UnsavedFilesManager UnsavedFiles { get; private set; }
-
- ProjectPackageCollection packages = new ProjectPackageCollection ();
-
- public event ProjectPackageEventHandler PackageAddedToProject;
- public event ProjectPackageEventHandler PackageRemovedFromProject;
-
- /// <summary>
- /// Extensions for C/C++ source files
- /// </summary>
- public static string[] SourceExtensions = { ".C", ".CC", ".CPP", ".CXX", ".M", ".MM" };
-
- /// <summary>
- /// Extensions for C/C++ header files
- /// </summary>
- public static string[] HeaderExtensions = { ".H", ".HH", ".HPP", ".HXX" };
-
- /// <summary>
- /// Initialize this instance.
- /// </summary>
- protected override void OnInitialize ()
- {
- base.OnInitialize ();
- packages.Project = this;
- try {
- ClangManager = new CLangManager (this);
- DB = new SymbolDatabaseMediator (this, ClangManager);
- UnsavedFiles = new UnsavedFilesManager (this);
- HasLibClang = true;
- } catch (DllNotFoundException ex) {
- LoggingService.LogError ("Could not load libclang", ex);
- HasLibClang = false;
- }
- }
-
- /// <summary>
- /// Initializes from template.
- /// </summary>
- /// <param name="projectCreateInfo">Project create info.</param>
- /// <param name="template">Template.</param>
- protected override void OnInitializeFromTemplate (ProjectCreateInformation projectCreateInfo, XmlElement template)
- {
- base.OnInitializeFromTemplate (projectCreateInfo, template);
- string binPath = ".";
- if (projectCreateInfo != null) {
- Name = projectCreateInfo.ProjectName;
- binPath = projectCreateInfo.BinPath;
- }
- Compiler = null; // use default compiler depending on language
- var configuration =
- (CProjectConfiguration)CreateConfiguration ("Debug");
- configuration.DefineSymbols = "DEBUG MONODEVELOP";
- configuration.DebugSymbols = true;
- Configurations.Add (configuration);
-
- configuration =
- (CProjectConfiguration)CreateConfiguration ("Release");
- configuration.DebugSymbols = false;
- configuration.OptimizationLevel = 3;
- configuration.DefineSymbols = "MONODEVELOP";
- Configurations.Add (configuration);
-
- foreach (CProjectConfiguration c in Configurations) {
- c.OutputDirectory = Path.Combine (binPath, c.Id);
- c.SourceDirectory = projectCreateInfo.ProjectBasePath;
- c.Output = Name;
-
- if (template != null) {
- if (template.Attributes ["LanguageName"] != null) {
- string languageName = template.Attributes ["LanguageName"].InnerText;
- switch (languageName) {
- case "C":
- this.Language = Language.C;
- break;
- case "C++":
- this.Language = Language.CPP;
- break;
- case "Objective-C":
- this.Language = Language.OBJC;
- break;
- case "Objective-C++":
- this.Language = Language.OBJCPP;
- break;
- }
- }
- if (template.Attributes ["Target"] != null) {
- c.CompileTarget = (CompileTarget)Enum.Parse (
- typeof(CompileTarget),
- template.Attributes ["Target"].InnerText);
- }
- if (template.GetAttribute ("ExternalConsole") == "True") {
- c.ExternalConsole = true;
- c.PauseConsoleOutput = true;
- }
- if (template.Attributes ["PauseConsoleOutput"] != null) {
- c.PauseConsoleOutput = bool.Parse (
- template.Attributes ["PauseConsoleOutput"].InnerText);
- }
- if (template.Attributes ["CompilerArgs"].InnerText != null) {
- c.ExtraCompilerArguments = template.Attributes ["CompilerArgs"].InnerText;
- }
- if (template.Attributes ["LinkerArgs"].InnerText != null) {
- c.ExtraLinkerArguments = template.Attributes ["LinkerArgs"].InnerText;
- }
- }
- }
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="CBinding.CProject"/> class.
- /// Must call Initialize* after.
- /// </summary>
- public CProject ()
- {
- }
-
- /// <summary>
- /// Returns with the languages supported by the project
- /// </summary>
- protected override string[] OnGetSupportedLanguages ()
- {
- return new string[] { "C", "C++", "Objective-C", "Objective-C++" };
- }
-
- /// <summary>
- /// Gets or sets the compile target.
- /// </summary>
- /// <value>The compile target.</value>
- public CompileTarget CompileTarget {
- get { return target; }
- set { target = value; }
- }
-
- /// <summary>
- /// Returns if the file represented by fileName is a compileable file.
- /// </summary>
- /// <param name="fileName">File name.</param>
- protected override bool OnGetIsCompileable (string fileName)
- {
- string ext = Path.GetExtension (fileName.ToUpper ());
- return (-1 != Array.IndexOf (SourceExtensions, ext) || -1 != Array.IndexOf (HeaderExtensions, ext) );
- }
-
- /// <summary>
- /// Returns with the referenced items of the project.
- /// </summary>
- /// <param name="configuration">Configuration.</param>
- protected override IEnumerable<SolutionItem> OnGetReferencedItems (ConfigurationSelector configuration)
- {
- foreach (var p in base.OnGetReferencedItems (configuration))
- yield return p;
-
- if (ParentSolution == null)
- yield break;
-
- foreach (Package p in Packages) {
- if (p.IsProject && p.Name != Name) {
- var cp = ParentSolution.FindProjectByName (p.Name) as CProject;
- if (cp != null)
- yield return cp;
- }
- }
- }
-
- /// <summary>
- /// Determines if a header file is specified by filename.
- /// </summary>
- /// <returns><c>true</c> if a header file is specified by filename; otherwise, <c>false</c>.</returns>
- /// <param name="filename">Filename.</param>
- public static bool IsHeaderFile (string filename)
- {
- return (0 <= Array.IndexOf (HeaderExtensions, Path.GetExtension (filename.ToUpper ())));
- }
-
- /// <summary>
- /// Ths pkg-config package is for internal MonoDevelop use only, it is not deployed.
- /// </summary>
- public void WriteMDPkgPackage (ConfigurationSelector configuration)
- {
- string pkgfile = Path.Combine (BaseDirectory, Name + ".md.pc");
-
- CProjectConfiguration config = (CProjectConfiguration)GetConfiguration (configuration);
- while (config == null) {
- Thread.Sleep (20);
- config = (CProjectConfiguration)GetConfiguration (configuration);
- }
-
- List<string> headerDirectories = new List<string> ();
-
- foreach (ProjectFile f in Files) {
- if (IsHeaderFile (f.Name)) {
- string dir = Path.GetDirectoryName (f.FilePath);
-
- if (!headerDirectories.Contains (dir)) {
- headerDirectories.Add (dir);
- }
- }
- }
-
- using (StreamWriter writer = new StreamWriter (pkgfile)) {
- writer.WriteLine ("Name: {0}", Name);
- writer.WriteLine ("Description: {0}", Description);
- writer.WriteLine ("Version: {0}", Version);
- writer.WriteLine ("Libs: -L\"{0}\" -l{1}", config.OutputDirectory, config.Output.StartsWith ("lib", StringComparison.OrdinalIgnoreCase)?
- config.Output.Substring (3):
- config.Output);
-// writer.WriteLine ("Cflags: -I{0}", BaseDirectory);
- writer.WriteLine ("Cflags: -I\"{0}\"", string.Join ("\" -I\"", headerDirectories.ToArray ()));
- }
-
- // If this project compiles into a shared object we need to
- // export the output path to the LD_LIBRARY_PATH
- string literal = "LD_LIBRARY_PATH";
- string ld_library_path = Environment.GetEnvironmentVariable (literal);
-
- if (string.IsNullOrEmpty (ld_library_path)) {
- Environment.SetEnvironmentVariable (literal, config.OutputDirectory);
- } else if (!ld_library_path.Contains (config.OutputDirectory)) {
- ld_library_path = string.Format ("{0}:{1}", config.OutputDirectory, ld_library_path);
- Environment.SetEnvironmentVariable (literal, ld_library_path);
- }
- }
-
- /// <summary>
- /// This is the pkg-config package that gets deployed.
- /// <returns>The pkg-config package's filename</returns>
- /// </summary>
- string WriteDeployablePgkPackage (Project project, CProjectConfiguration config)
- {
- // FIXME: This should probably be grabed from somewhere.
- string prefix = "/usr/local";
- string pkgfile = Path.Combine (BaseDirectory, Name + ".pc");
-
- using (StreamWriter writer = new StreamWriter (pkgfile)) {
- writer.WriteLine ("prefix={0}", prefix);
- writer.WriteLine ("exec_prefix=${prefix}");
- writer.WriteLine ("libdir=${exec_prefix}/lib");
- writer.WriteLine ("includedir=${prefix}/include");
- writer.WriteLine ();
- writer.WriteLine ("Name: {0}", Name);
- writer.WriteLine ("Description: {0}", Description);
- writer.WriteLine ("Version: {0}", Version);
- writer.WriteLine ("Requires: {0}", string.Join (" ", Packages.ToStringArray ()));
- // TODO: How should I get this?
- writer.WriteLine ("Conflicts: {0}", string.Empty);
- writer.Write ("Libs: -L${libdir} ");
- writer.WriteLine ("-l{0}", config.Output.StartsWith ("lib", StringComparison.OrdinalIgnoreCase)?
- config.Output.Substring (3):
- config.Output);
- writer.Write ("Cflags: -I${includedir}/");
- writer.WriteLine ("{0} {1}", Name, Compiler.GetDefineFlags (project, config));
- }
-
- return pkgfile;
- }
-
- /// <summary>
- /// Builds the project.
- /// </summary>
- /// <returns>The build result.</returns>
- /// <param name="monitor">Progress monitor.</param>
- /// <param name="configuration">Configuration to build.</param>
- /// <remarks>This method is invoked to build the project. Support files such as files with the Copy to Output flag will
- /// be copied before calling this method.</remarks>
- protected override Task<BuildResult> DoBuild (ProgressMonitor monitor, ConfigurationSelector configuration)
- {
- var pc = (CProjectConfiguration) GetConfiguration (configuration);
- pc.SourceDirectory = BaseDirectory;
-
- return Task<BuildResult>.Factory.StartNew (delegate {
- return CompilerManager.Compile (this,
- Files, packages,
- pc,
- monitor);
- });
- }
-
- /// <summary>
- /// Cleans the files produced by this solution item
- /// </summary>
- /// <param name="monitor">A progress monitor</param>
- /// <param name="configuration">Configuration to use to clean the project</param>
- /// <param name="operationContext">Operation context.</param>
- protected async override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
- {
- var conf = (CProjectConfiguration) GetConfiguration (configuration);
-
- var res = await base.OnClean (monitor, configuration, operationContext);
- if (res.HasErrors)
- return res;
-
- await Task.Run (() => Compiler.Clean (Files, conf, monitor));
-
- return res;
- }
-
- /// <summary>
- /// Creates the execution command for the project.
- /// </summary>
- /// <returns>The execution command.</returns>
- /// <param name="conf">Conf.</param>
- protected virtual ExecutionCommand CreateExecutionCommand (CProjectConfiguration conf)
- {
- string app = Path.Combine (conf.OutputDirectory, conf.Output);
- var cmd = new NativeExecutionCommand (app);
- cmd.Arguments = conf.CommandLineParameters;
- cmd.WorkingDirectory = Path.GetFullPath (conf.OutputDirectory);
- cmd.EnvironmentVariables = conf.EnvironmentVariables;
- return cmd;
- }
-
- /// <summary>
- /// Determines whether this solution item can be executed using the specified context and configuration.
- /// </summary>
- /// <param name="context">Context.</param>
- /// <param name="solutionConfiguration">Solution configuration.</param>
- protected override bool OnGetCanExecute (MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector solutionConfiguration)
- {
- var conf = (CProjectConfiguration) GetConfiguration (solutionConfiguration);
- ExecutionCommand cmd = CreateExecutionCommand (conf);
- return (target == CompileTarget.Exe) && context.ExecutionHandler.CanExecute (cmd);
- }
-
- /// <summary>
- /// Executes the project
- /// </summary>
- /// <param name="monitor">Progress monitor.</param>
- /// <param name="context">Execution context.</param>
- /// <param name="configuration">Configuration to execute.</param>
- /// <returns>The execute.</returns>
- protected async override Task DoExecute (ProgressMonitor monitor, MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration)
- {
- var conf = (CProjectConfiguration) GetConfiguration (configuration);
- bool pause = conf.PauseConsoleOutput;
- OperationConsole console;
-
- if (conf.CompileTarget != CompileTarget.Exe) {
- MessageService.ShowMessage ("Compile target is not an executable!");
- return;
- }
-
- monitor.Log.WriteLine ("Running project...");
-
- if (conf.ExternalConsole)
- console = context.ExternalConsoleFactory.CreateConsole (!pause, monitor.CancellationToken);
- else
- console = context.ConsoleFactory.CreateConsole (monitor.CancellationToken);
-
- try {
- ExecutionCommand cmd = CreateExecutionCommand (conf);
- if (!context.ExecutionHandler.CanExecute (cmd)) {
- monitor.ReportError ("Cannot execute \"" + conf.Output + "\". The selected execution mode is not supported for C projects.", null);
- return;
- }
-
- ProcessAsyncOperation op = context.ExecutionHandler.Execute (cmd, console);
- using (var t = monitor.CancellationToken.Register (op.Cancel))
- await op.Task;
-
- monitor.Log.WriteLine ("The operation exited with code: {0}", op.ExitCode);
- } catch (Exception ex) {
- LoggingService.LogError (string.Format ("Cannot execute \"{0}\"", conf.Output), ex);
- monitor.ReportError ("Cannot execute \"" + conf.Output + "\"", ex);
- } finally {
- console.Dispose ();
- }
- }
-
- /// <summary>
- /// Returns with output bomPresentInFile </summary>
- /// <param name="configuration">Configuration.</param>
- protected override FilePath OnGetOutputFileName (ConfigurationSelector configuration)
- {
- var conf = (CProjectConfiguration) GetConfiguration (configuration);
- return conf.OutputDirectory.Combine (conf.CompiledOutputName);
- }
-
- /// <summary>
- /// Create an empty configuration for project. Must fill configuration after.
- /// </summary>
- /// <param name="id">Name.</param>
- /// <param name="kind">Kind.</param>
- protected override SolutionItemConfiguration OnCreateConfiguration (string id, ConfigurationKind kind)
- {
- return new CProjectConfiguration (id);
- }
-
- /// <summary>
- /// Returns with supported languages as tags. Obligatory for Add files dialog.
- /// </summary>
- /// <param name="types">Types.</param>
- protected override void OnGetTypeTags (HashSet<string> types)
- {
- base.OnGetTypeTags (types);
- types.Add ("C/C++");
- types.Add ("Native");
- }
-
- public ICompiler Compiler {
- get { return CompilerManager; }
- set {
- if (value != null) {
- CompilerManager = value;
- } else {
- object[] compilers = AddinManager.GetExtensionObjects ("/CBinding/Compilers");
- string compiler;
-
- // TODO: This should depend on platform (eg: windows would be mingw or msvc)
- if (Language == Language.C)
- compiler = PropertyService.Get ("CBinding.DefaultCCompiler", new GccCompiler ().Name);
- else
- compiler = PropertyService.Get ("CBinding.DefaultCppCompiler", new GppCompiler ().Name);
-
- foreach (ICompiler c in compilers) {
- if (compiler == c.Name) {
- CompilerManager = c;
- }
- }
- }
- }
- }
-
- // TODO NPM: not supported
- [Browsable(false)]
- [ItemProperty ("Packages")]
- public ProjectPackageCollection Packages {
- get { return packages; }
- set {
- packages = value;
- packages.Project = this;
- }
- }
-
- internal void NotifyPackageRemovedFromProject (Package package)
- {
- Runtime.AssertMainThread ();
- PackageRemovedFromProject (this, new ProjectPackageEventArgs (this, package));
- }
-
- internal void NotifyPackageAddedToProject (Package package)
- {
- Runtime.AssertMainThread ();
- PackageAddedToProject (this, new ProjectPackageEventArgs (this, package));
- }
-
- /// <summary>
- /// Finds the corresponding source or header file
- /// </summary>
- /// <param name="sourceFile">
- /// The name of the file to be matched
- /// <see cref="System.String"/>
- /// </param>
- /// <returns>
- /// The corresponding file, or null if not found
- /// <see cref="System.String"/>
- /// </returns>
- public string MatchingFile (string sourceFile) {
- string filenameStub = Path.GetFileNameWithoutExtension (sourceFile);
- bool wantHeader = !CProject.IsHeaderFile (sourceFile);
-
- foreach (ProjectFile file in this.Files) {
- if (filenameStub == Path.GetFileNameWithoutExtension (file.Name)
- && (wantHeader == IsHeaderFile (file.Name))) {
- return file.Name;
- }
- }
-
- return null;
- }
- }
-}
diff --git a/cbindingreport/cbinding/cbinding/project/cprojectconfiguration.cs b/cprojectconfiguration.cs
index a5cde38..e69de29 100644
--- a/cbindingreport/cbinding/cbinding/project/cprojectconfiguration.cs
+++ b/cprojectconfiguration.cs
@@ -1,232 +0,0 @@
-//
-// CProjectConfiguration.cs: Configuration for C/C++ projects
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin@gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-
-using Mono.Addins;
-
-using MonoDevelop.Projects;
-using MonoDevelop.Core.Serialization;
-
-namespace CBinding
-{
- /// <summary>
- /// C/C++ standard version to use in configuration.
- /// </summary>
- public enum CVersion {
- CustomVersionString,
- ISOC,
- C99,
- C11,
- ISOCPP,
- CPP03,
- CPP11
- }
-
- // TODO: Warning levels should be compiler specific...
- /// <summary>
- /// Warning level.
- /// </summary>
- public enum WarningLevel {
- None,
- Normal,
- All
- }
-
- // I believe it would be in the C/C++ binding's best interest to let the configuration determine
- // which compiler to use... currently the project as a whole does this - which isn't necessarily as flexible
- // as some may require...
- public class CProjectConfiguration : ProjectConfiguration
- {
- public CProjectConfiguration (string id) :base (id)
- {
- }
-
- /// <summary>
- /// The output name.
- /// </summary>
- [ItemProperty("OutputName", DefaultValue = "")]
- public string Output { get; set; }
-
- /// <summary>
- /// The compile target.
- /// </summary>
- [ItemProperty("OutputType", DefaultValue = CompileTarget.Exe)]
- public CompileTarget CompileTarget { get; set; }
-
- [ItemProperty ("Includes")]
- [ItemProperty ("Include", Scope = "*", ValueType = typeof(string))]
- ArrayList includes = new ArrayList ();
-
- [ItemProperty ("LibPaths")]
- [ItemProperty ("LibPath", Scope = "*", ValueType = typeof(string))]
- ArrayList libpaths = new ArrayList ();
-
- [ItemProperty ("Libs")]
- [ItemProperty ("Lib", Scope = "*", ValueType = typeof(string))]
- ArrayList libs = new ArrayList ();
-
- /// <summary>
- /// The C/C++ standard version in use.
- /// </summary>
- [ItemProperty ("CVersion", DefaultValue = CVersion.CustomVersionString)]
- public CVersion CVersion{ get; set; }
-
- /// <summary>
- /// The custom version string.
- /// </summary>
- [ItemProperty ("CustomCVersionString", DefaultValue = "")]
- public string CustomVersionString { get; set; }
-
- /// <summary>
- /// The warning level.
- /// </summary>
- [ItemProperty ("WarningLevel", DefaultValue = WarningLevel.Normal)]
- public WarningLevel WarningLevel { get; set; }
-
- /// <summary>
- /// Specifies if warnings should be treated as errors or not.
- /// </summary>
- [ItemProperty ("WarningsAsErrors", DefaultValue = false)]
- public bool WarningsAsErrors { get; set; }
-
- /// <summary>
- /// The optimization level.
- /// </summary>
- [ItemProperty ("OptimizationLevel", DefaultValue = 0)]
- int optimization;
-
- /// <summary>
- /// Extra compiler arguments given by user.
- /// </summary>
- [ItemProperty ("ExtraCompilerArguments", DefaultValue = "")]
- public string ExtraCompilerArguments { get; set; }
-
- /// <summary>
- /// Extra linker arguments given by user.
- /// </summary>
- [ItemProperty ("ExtraLinkerArguments", DefaultValue = "")]
- public string ExtraLinkerArguments { get; set; }
-
- [ItemProperty ("DefineSymbols", DefaultValue = "")]
- public string DefineSymbols { get; set; }
-
- [ProjectPathItemProperty ("SourceDirectory", DefaultValue = "")]
- public string SourceDirectory { get; set; }
-
- [ItemProperty ("UseCcache", DefaultValue = false)]
- public bool UseCcache { get; set; }
-
- [ItemProperty ("PrecompileHeaders", DefaultValue = true)]
- public bool PrecompileHeaders { get; set; }
-
- public ArrayList Includes {
- get { return includes; }
- set { includes = value; }
- }
-
- public ArrayList LibPaths {
- get { return libpaths; }
- set { libpaths = value; }
- }
-
- public ArrayList Libs {
- get { return libs; }
- set { libs = value; }
- }
-
- // TODO: This should be revised to use the naming conventions depending on OS & compiler...
- /// <summary>
- /// Determines the name of the compiled output.
- /// </summary>
- /// <value>The name of the compiled output.</value>
- public string CompiledOutputName {
- get {
- string suffix = string.Empty;
- string prefix = string.Empty;
-
- //TODO Win&Mac naming
- switch (CompileTarget) {
- case CompileTarget.Exe:
- break;
- case CompileTarget.Module:
- if (!Output.StartsWith ("lib"))
- prefix = "lib";
- if (!Output.EndsWith (".a"))
- suffix = ".a";
- break;
- case CompileTarget.Library:
- if (!Output.StartsWith ("lib"))
- prefix = "lib";
- if (!Output.EndsWith (".so"))
- suffix = ".so";
- break;
- }
-
- return string.Format("{0}{1}{2}", prefix, Output, suffix);
- }
- }
-
- public int OptimizationLevel {
- get { return optimization; }
- set {
- if (value >= 0 && value <= 3)
- optimization = value;
- else
- optimization = 0;
- }
- }
-
- protected override void OnCopyFrom (ItemConfiguration configuration, bool isRename)
- {
- base.OnCopyFrom (configuration, isRename);
-
- var conf = (CProjectConfiguration)configuration;
-
- Output = conf.Output;
- CompileTarget = conf.CompileTarget;
- Includes = conf.Includes;
- LibPaths = conf.LibPaths;
- Libs = conf.Libs;
- SourceDirectory = conf.SourceDirectory;
- UseCcache = conf.UseCcache;
- CVersion = conf.CVersion;
- CustomVersionString = conf.CustomVersionString;
- WarningLevel = conf.WarningLevel;
- WarningsAsErrors = conf.WarningsAsErrors;
- OptimizationLevel = conf.OptimizationLevel;
- ExtraCompilerArguments = conf.ExtraCompilerArguments;
- ExtraLinkerArguments = conf.ExtraLinkerArguments;
- DefineSymbols = conf.DefineSymbols;
- }
- }
-}
diff --git a/cbindingreport/cbinding/cbinding/gui/ctexteditorextension.cs b/caddin/cbinding/cbinding/gui/ctexteditorextension.cs
index 050ecd7..01856f2 100644
--- a/cbindingreport/cbinding/cbinding/gui/ctexteditorextension.cs
+++ b/caddin/cbinding/cbinding/gui/ctexteditorextension.cs
@@ -48,6 +48,7 @@ using MonoDevelop.Ide.Editor.Extension;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Gui.Content;
using MonoDevelop.Ide.TypeSystem;
+using MonoDevelop.Projects;
using ClangSharp;
using CBinding.Parser;
using CBinding.Refactoring;
@@ -283,7 +284,7 @@ namespace CBinding
public override Task<ICompletionDataList> HandleCodeCompletionAsync (CodeCompletionContext completionContext, CompletionTriggerInfo triggerInfo, CancellationToken token = default (CancellationToken))
{
- var project = (CProject)DocumentContext.Project;
+ var project = (CMakeProject)DocumentContext.Owner;
if (project == null || !project.HasLibClang) {
return Task.FromResult ((ICompletionDataList)null);
}
@@ -396,7 +397,7 @@ namespace CBinding
if (completionChar != '(' && completionChar != ',')
return Task.FromResult ((ParameterHintingResult) null);
- var project = (CProject)DocumentContext.Project;
+ var project = (CMakeProject)(DocumentContext.Owner);
if (project == null || !project.HasLibClang)
return Task.FromResult ((ParameterHintingResult) null);
@@ -535,11 +536,11 @@ namespace CBinding
[CommandHandler (MonoDevelop.DesignerSupport.Commands.SwitchBetweenRelatedFiles)]
protected void Run ()
{
- var cp = (CProject)DocumentContext.Project;
+ var cp = (CMakeProject)(DocumentContext.Owner);
if (cp != null) {
string match = cp.MatchingFile (this.DocumentContext.Name);
if (match != null)
- IdeApp.Workbench.OpenDocument (match, cp, true);
+ IdeApp.Workbench.OpenDocument (match, DocumentContext.Owner, true);
}
}
@@ -550,7 +551,7 @@ namespace CBinding
[CommandUpdateHandler (MonoDevelop.DesignerSupport.Commands.SwitchBetweenRelatedFiles)]
protected void Update (CommandInfo info)
{
- var cp = (CProject)DocumentContext.Project;
+ var cp = (CMakeProject)(DocumentContext.Owner);
info.Visible = info.Visible = cp != null && cp.MatchingFile (this.DocumentContext.Name) != null;
}
@@ -629,7 +630,7 @@ namespace CBinding
if (doc == null || doc.FileName == FilePath.Null)
return;
var findReferencesHandler = new FindReferencesHandler (
- (CProject)DocumentContext.Project,
+ (CMakeProject)(DocumentContext.Owner),
doc
);
findReferencesHandler.Update (ci);
@@ -645,7 +646,7 @@ namespace CBinding
if (doc == null || doc.FileName == FilePath.Null)
return;
var findReferencesHandler = new FindReferencesHandler (
- (CProject)DocumentContext.Project,
+ (CMakeProject)(DocumentContext.Owner),
doc
);
findReferencesHandler.Run ();
@@ -674,7 +675,7 @@ namespace CBinding
var doc = IdeApp.Workbench.ActiveDocument;
if (doc == null || doc.FileName == FilePath.Null)
return;
- var renameHandler = new RenameHandlerDialog ((CProject)DocumentContext.Project, doc);
+ var renameHandler = new RenameHandlerDialog ((CMakeProject)(DocumentContext.Owner), doc);
renameHandler.Update (ci);
}
@@ -687,7 +688,7 @@ namespace CBinding
var doc = IdeApp.Workbench.ActiveDocument;
if (doc == null || doc.FileName == FilePath.Null)
return;
- var renameHandler = new RenameHandlerDialog ((CProject)DocumentContext.Project, doc);
+ var renameHandler = new RenameHandlerDialog ((CMakeProject)(DocumentContext.Owner), doc);
renameHandler.RunRename ();
}
diff --git a/cbindingreport/cbinding/cbinding/gui/editpackagesdialog.cs b/editpackagesdialog.cs
index 823fe57..e69de29 100644
--- a/cbindingreport/cbinding/cbinding/gui/editpackagesdialog.cs
+++ b/editpackagesdialog.cs
@@ -1,569 +0,0 @@
-//
-// EditPackagesDialog.cs: Allows you to add and remove pkg-config packages to the project
-//
-// Authors:
-// Marcos David Marin Amador <MarcosMarin@gmail.com>
-//
-// Copyright (C) 2007 Marcos David Marin Amador
-//
-//
-// This source code is licenced under The MIT License:
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.IO;
-using System.Collections.Generic;
-
-using MonoDevelop.Projects;
-using MonoDevelop.Ide;
-using MonoDevelop.Components;
-
-namespace CBinding
-{
- public partial class EditPackagesDialog : Gtk.Dialog
- {
- private Gtk.ListStore normalPackageListStore = new Gtk.ListStore (typeof(bool), typeof(string), typeof(string));
- private Gtk.ListStore projectPackageListStore = new Gtk.ListStore (typeof(bool), typeof(string), typeof(string));
- private Gtk.ListStore selectedPackageListStore = new Gtk.ListStore (typeof(string), typeof(string));
- private CProject project;
- private ProjectPackageCollection selectedPackages = new ProjectPackageCollection ();
- private List<Package> packagesOfProjects;
- private List<Package> packages = new List<Package> ();
-
- // Column IDs
- const int NormalPackageToggleID = 0;
- const int NormalPackageNameID = 1;
- const int NormalPackageVersionID = 2;
-
- const int ProjectPackageToggleID = 0;
- const int ProjectPackageNameID = 1;
- const int ProjectPackageVersionID = 2;
-
- const int SelectedPackageNameID = 0;
- const int SelectedPackageVersionID = 1;
-
- public EditPackagesDialog(CProject project)
- {
- this.Build();
-
- this.project = project;
-
- selectedPackages.Project = project;
- selectedPackages.AddRange (project.Packages);
-
- Gtk.CellRendererText textRenderer = new Gtk.CellRendererText ();
-
- CellRendererImage pixbufRenderer = new CellRendererImage ();
- pixbufRenderer.StockId = "md-package";
-
- normalPackageListStore.DefaultSortFunc = NormalPackageCompareNodes;
- projectPackageListStore.DefaultSortFunc = ProjectPackageCompareNodes;
- selectedPackageListStore.DefaultSortFunc = SelectedPackageCompareNodes;
-
- normalPackageListStore.SetSortColumnId (NormalPackageNameID, Gtk.SortType.Ascending);
- projectPackageListStore.SetSortColumnId (ProjectPackageNameID, Gtk.SortType.Ascending);
- selectedPackageListStore.SetSortColumnId (SelectedPackageNameID, Gtk.SortType.Ascending);
-
- normalPackageTreeView.SearchColumn = NormalPackageNameID;
- projectPackageTreeView.SearchColumn = ProjectPackageNameID;
- selectedPackageTreeView.SearchColumn = SelectedPackageNameID;
-
- // <!-- Normal packages -->
-
- Gtk.CellRendererToggle normalPackageToggleRenderer = new Gtk.CellRendererToggle ();
- normalPackageToggleRenderer.Activatable = true;
- normalPackageToggleRenderer.Toggled += OnNormalPackageToggled;
- normalPackageToggleRenderer.Xalign = 0;
-
- Gtk.TreeViewColumn normalPackageColumn = new Gtk.TreeViewColumn ();
- normalPackageColumn.Title = "Package";
- normalPackageColumn.PackStart (pixbufRenderer, false);
- normalPackageColumn.PackStart (textRenderer, true);
- normalPackageColumn.AddAttribute (textRenderer, "text", NormalPackageNameID);
-
- normalPackageTreeView.Model = normalPackageListStore;
- normalPackageTreeView.HeadersVisible = true;
- normalPackageTreeView.AppendColumn ("", normalPackageToggleRenderer, "active", NormalPackageToggleID);
- normalPackageTreeView.AppendColumn (normalPackageColumn);
- normalPackageTreeView.AppendColumn ("Version", textRenderer, "text", NormalPackageVersionID);
-
- // <!-- Project packages -->
-
- Gtk.CellRendererToggle projectPackageToggleRenderer = new Gtk.CellRendererToggle ();
- projectPackageToggleRenderer.Activatable = true;
- projectPackageToggleRenderer.Toggled += OnProjectPackageToggled;
- projectPackageToggleRenderer.Xalign = 0;
-
- Gtk.TreeViewColumn projectPackageColumn = new Gtk.TreeViewColumn ();
- projectPackageColumn.Title = "Package";
- projectPackageColumn.PackStart (pixbufRenderer, false);
- projectPackageColumn.PackStart (textRenderer, true);
- projectPackageColumn.AddAttribute (textRenderer, "text", ProjectPackageNameID);
-
- projectPackageTreeView.Model = projectPackageListStore;
- projectPackageTreeView.HeadersVisible = true;
- projectPackageTreeView.AppendColumn ("", projectPackageToggleRenderer, "active", ProjectPackageToggleID);
- projectPackageTreeView.AppendColumn (projectPackageColumn);
- projectPackageTreeView.AppendColumn ("Version", textRenderer, "text", ProjectPackageVersionID);
-
-
- // <!-- Selected packages -->
-
- Gtk.TreeViewColumn selectedPackageColumn = new Gtk.TreeViewColumn ();
- selectedPackageColumn.Title = "Package";
- selectedPackageColumn.PackStart (pixbufRenderer, false);
- selectedPackageColumn.PackStart (textRenderer, true);
- selectedPackageColumn.AddAttribute (textRenderer, "text", SelectedPackageNameID);
-
- selectedPackageTreeView.Model = selectedPackageListStore;
- selectedPackageTreeView.HeadersVisible = true;
- selectedPackageTreeView.AppendColumn (selectedPackageColumn);
- selectedPackageTreeView.AppendColumn ("Version", textRenderer, "text", SelectedPackageVersionID);
-
- // Fill up the project tree view
- packagesOfProjects = GetPackagesOfProjects (project);
-
- foreach (Package p in packagesOfProjects) {
- if (p.Name == project.Name) continue;
-
- packages.Add (p);
- string version = p.Version;
- bool inProject = selectedPackages.Contains (p);
-
- if (!IsPackageInStore (projectPackageListStore, p.Name, version, ProjectPackageNameID, ProjectPackageVersionID)) {
- projectPackageListStore.AppendValues (inProject, p.Name, version);
-
- if (inProject)
- selectedPackageListStore.AppendValues (p.Name, version);
- }
- }
-
- // Fill up the normal tree view
- foreach (string dir in ScanDirs ()) {
- if (Directory.Exists (dir)) {
- DirectoryInfo di = new DirectoryInfo (dir);
- FileInfo[] availablePackages = di.GetFiles ("*.pc");
-
- foreach (FileInfo f in availablePackages) {
- if (!IsValidPackage (f.FullName)) {
- continue;
- }
-
- Package package = new Package (f.FullName);
-
- packages.Add (package);
-
- string name = package.Name;
- string version = package.Version;
- bool inProject = selectedPackages.Contains (package);
-
- if (!IsPackageInStore (normalPackageListStore, name, version, NormalPackageNameID, NormalPackageVersionID)) {
- normalPackageListStore.AppendValues (inProject, name, version);
-
- if (inProject)
- selectedPackageListStore.AppendValues (name, version);
- }
- }
- }
- }
- }
-
- private List<Package> GetPackagesOfProjects (Project project)
- {
- List<Package> packages = new List<Package>();
- Package package;
-
- foreach (SolutionFolderItem c in project.ParentFolder.Items) {
- if (null != c && c is CProject) {
- CProject cproj = (CProject)c;
- CProjectConfiguration conf = (CProjectConfiguration)cproj.GetConfiguration (IdeApp.Workspace.ActiveConfiguration);
- if (conf.CompileTarget != CompileTarget.Exe) {
- cproj.WriteMDPkgPackage (conf.Selector);
- package = new Package (cproj);
- packages.Add (package);
- }
- }
- }
-