WIP CAKE + .Net Core

This commit is contained in:
cra0zy 2017-10-23 01:25:13 +02:00
parent 604742fa16
commit 6926c9cbf2
2596 changed files with 1067 additions and 19343 deletions

View file

@ -1,13 +1,4 @@
#!/bin/bash #!/bin/bash
set -e set -e
./build.sh
export BUILD_DIR="/${SOURCE_DIR}/build"
cd "${SOURCE_DIR}"
rm -Rf "${BUILD_DIR}"
meson "${BUILD_DIR}"
cd "${BUILD_DIR}"
ninja
ninja -C "${BUILD_DIR}" test

0
.gitattributes vendored Normal file → Executable file
View file

6
.gitignore vendored Normal file → Executable file
View file

@ -1,4 +1,8 @@
build/ ## Add custom content for this repo bellow this
BuildOutput/
Generated/
tools/
## Ignore Visual Studio temporary files, build results, and ## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons. ## files generated by popular Visual Studio add-ons.

0
.travis.yml Normal file → Executable file
View file

3
.vscode/settings.json vendored Executable file
View file

@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}

0
AUTHORS Normal file → Executable file
View file

79
CakeScripts/GAssembly.cs Executable file
View file

@ -0,0 +1,79 @@
using System;
using P = System.IO.Path;
public class GAssembly
{
public static ICakeContext Cake;
public bool Init { get; private set; }
public string Name { get; private set; }
public string Dir { get; private set; }
public string GDir { get; private set; }
public string Csproj { get; private set; }
public string RawApi { get; private set; }
public string Metadata { get; private set; }
public string[] Includes { get; set; }
public string ExtraArgs { get; set; }
public GAssembly(string name)
{
Includes = new string[0];
Name = name;
Dir = P.Combine("Source", "Libs", name);
GDir = P.Combine(Dir, "Generated");
var temppath = P.Combine(Dir, name);
Csproj = temppath + ".csproj";
RawApi = temppath + "-api.raw";
Metadata = temppath + ".metadata";
}
public void Prepare()
{
// Raw API file found, time to generate some stuff!!!
if (Cake.FileExists(RawApi))
{
Cake.DeleteDirectory(GDir, true);
Cake.CreateDirectory(GDir);
// Fixup API file
var tempapi = P.Combine(GDir, Name + "-api.xml");
var symfile = P.Combine(Dir, Name + "-symbols.xml");
Cake.CopyFile(RawApi, tempapi);
GapiFixup.Run(tempapi, Metadata, Cake.FileExists(symfile) ? symfile : string.Empty);
// Locate APIs to include
foreach(var dep in Includes)
{
var ipath = P.Combine("Source", "Libs", dep, dep + "-api.xml");
if (!Cake.FileExists(ipath))
ipath = P.Combine("Source", "Libs", dep, "Generated", dep + "-api.xml");
if (Cake.FileExists(ipath))
{
ExtraArgs += "--include=" + ipath + " ";
ExtraArgs += "--include=" + ipath + " ";
}
}
// Generate code
GAssembly.Cake.DotNetCoreExecute(P.Combine("BuildOutput", "Generator", "GapiCodegen.dll"),
"--outdir=" + GDir + " " +
"--schema=" + P.Combine("Source", "Libs", "Gapi.xsd") + " " +
ExtraArgs + " " +
"--assembly-name=" + Name + " " +
"--generate=" + tempapi
);
}
Init = true;
}
public void Clean()
{
Cake.DeleteDirectory(GDir, true);
}
}

262
CakeScripts/GapiFixup.cs Executable file
View file

@ -0,0 +1,262 @@
// xml alteration engine.
//
// Authors:
// Mike Kestner <mkestner@speakeasy.net>
// Stephan Sundermann <stephansundermann@gmail.com>
//
// Copyright (c) 2003 Mike Kestner
// Copyright (c) 2013 Stephan Sundermann
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class GapiFixup
{
public static int Run(string api_filename, string meta_filename, string symbol_filename = "")
{
XmlDocument api_doc = new XmlDocument();
XmlDocument meta_doc = new XmlDocument();
XmlDocument symbol_doc = new XmlDocument();
if (!string.IsNullOrEmpty(meta_filename))
{
try
{
Stream stream = System.IO.File.OpenRead(meta_filename);
meta_doc.Load(stream);
stream.Close();
}
catch (XmlException e)
{
Console.WriteLine("Invalid meta file.");
Console.WriteLine(e);
return 1;
}
}
if (!string.IsNullOrEmpty(api_filename))
{
try
{
Stream stream = System.IO.File.OpenRead(api_filename);
api_doc.Load(stream);
stream.Close();
}
catch (XmlException e)
{
Console.WriteLine("Invalid api file.");
Console.WriteLine(e);
return 1;
}
}
if (!string.IsNullOrEmpty(symbol_filename))
{
try
{
Stream stream = System.IO.File.OpenRead(symbol_filename);
symbol_doc.Load(stream);
stream.Close();
}
catch (XmlException e)
{
Console.WriteLine("Invalid api file.");
Console.WriteLine(e);
return 1;
}
}
XPathNavigator meta_nav = meta_doc.CreateNavigator();
XPathNavigator api_nav = api_doc.CreateNavigator();
XPathNodeIterator copy_iter = meta_nav.Select("/metadata/copy-node");
while (copy_iter.MoveNext())
{
string path = copy_iter.Current.GetAttribute("path", String.Empty);
XPathExpression expr = api_nav.Compile(path);
string parent = copy_iter.Current.Value;
XPathNodeIterator parent_iter = api_nav.Select(parent);
bool matched = false;
while (parent_iter.MoveNext())
{
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode();
XPathNodeIterator path_iter = parent_iter.Current.Clone().Select(expr);
while (path_iter.MoveNext())
{
XmlNode node = ((IHasXmlNode)path_iter.Current).GetNode();
parent_node.AppendChild(node.Clone());
}
matched = true;
}
if (!matched)
Console.WriteLine("Warning: <copy-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator rmv_iter = meta_nav.Select("/metadata/remove-node");
while (rmv_iter.MoveNext())
{
string path = rmv_iter.Current.GetAttribute("path", "");
XPathNodeIterator api_iter = api_nav.Select(path);
bool matched = false;
while (api_iter.MoveNext())
{
XmlElement api_node = ((IHasXmlNode)api_iter.Current).GetNode() as XmlElement;
api_node.ParentNode.RemoveChild(api_node);
matched = true;
}
if (!matched)
Console.WriteLine("Warning: <remove-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator add_iter = meta_nav.Select("/metadata/add-node");
while (add_iter.MoveNext())
{
string path = add_iter.Current.GetAttribute("path", "");
XPathNodeIterator api_iter = api_nav.Select(path);
bool matched = false;
while (api_iter.MoveNext())
{
XmlElement api_node = ((IHasXmlNode)api_iter.Current).GetNode() as XmlElement;
foreach (XmlNode child in ((IHasXmlNode)add_iter.Current).GetNode().ChildNodes)
api_node.AppendChild(api_doc.ImportNode(child, true));
matched = true;
}
if (!matched)
Console.WriteLine("Warning: <add-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator change_node_type_iter = meta_nav.Select("/metadata/change-node-type");
while (change_node_type_iter.MoveNext())
{
string path = change_node_type_iter.Current.GetAttribute("path", "");
XPathNodeIterator api_iter = api_nav.Select(path);
bool matched = false;
while (api_iter.MoveNext())
{
XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode() as XmlElement;
XmlElement parent = node.ParentNode as XmlElement;
XmlElement new_node = api_doc.CreateElement(change_node_type_iter.Current.Value);
foreach (XmlNode child in node.ChildNodes)
new_node.AppendChild(child.Clone());
foreach (XmlAttribute attribute in node.Attributes)
new_node.Attributes.Append((XmlAttribute)attribute.Clone());
parent.ReplaceChild(new_node, node);
matched = true;
}
if (!matched)
Console.WriteLine("Warning: <change-node-type path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator attr_iter = meta_nav.Select("/metadata/attr");
while (attr_iter.MoveNext())
{
string path = attr_iter.Current.GetAttribute("path", "");
string attr_name = attr_iter.Current.GetAttribute("name", "");
int max_matches = -1;
var max_matches_str = attr_iter.Current.GetAttribute("max-matches", "");
if (max_matches_str != "")
max_matches = Convert.ToInt32(max_matches_str);
XPathNodeIterator api_iter = api_nav.Select(path);
var nmatches = 0;
while (api_iter.MoveNext())
{
XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode() as XmlElement;
node.SetAttribute(attr_name, attr_iter.Current.Value);
nmatches++;
if (max_matches > 0 && nmatches == max_matches)
break;
}
if (nmatches == 0)
Console.WriteLine("Warning: <attr path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator move_iter = meta_nav.Select("/metadata/move-node");
while (move_iter.MoveNext())
{
string path = move_iter.Current.GetAttribute("path", "");
XPathExpression expr = api_nav.Compile(path);
string parent = move_iter.Current.Value;
XPathNodeIterator parent_iter = api_nav.Select(parent);
bool matched = false;
while (parent_iter.MoveNext())
{
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode();
XPathNodeIterator path_iter = parent_iter.Current.Clone().Select(expr);
while (path_iter.MoveNext())
{
XmlNode node = ((IHasXmlNode)path_iter.Current).GetNode();
parent_node.AppendChild(node.Clone());
node.ParentNode.RemoveChild(node);
}
matched = true;
}
if (!matched)
Console.WriteLine("Warning: <move-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator remove_attr_iter = meta_nav.Select("/metadata/remove-attr");
while (remove_attr_iter.MoveNext())
{
string path = remove_attr_iter.Current.GetAttribute("path", "");
string name = remove_attr_iter.Current.GetAttribute("name", "");
XPathNodeIterator api_iter = api_nav.Select(path);
bool matched = false;
while (api_iter.MoveNext())
{
XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode() as XmlElement;
node.RemoveAttribute(name);
matched = true;
}
if (!matched)
Console.WriteLine("Warning: <remove-attr path=\"{0}\"/> matched no nodes", path);
}
if (symbol_doc != null)
{
XPathNavigator symbol_nav = symbol_doc.CreateNavigator();
XPathNodeIterator iter = symbol_nav.Select("/api/*");
while (iter.MoveNext())
{
XmlNode sym_node = ((IHasXmlNode)iter.Current).GetNode();
XPathNodeIterator parent_iter = api_nav.Select("/api");
if (parent_iter.MoveNext())
{
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode();
parent_node.AppendChild(api_doc.ImportNode(sym_node, true));
}
}
}
api_doc.Save(api_filename);
return 0;
}
}

2
Dockerfile Normal file → Executable file
View file

@ -1,7 +1,7 @@
FROM debian:9 FROM debian:9
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y git python3 python3-pip ninja-build mono-devel libgtk-3-dev apt-get install -y git mono-devel libgtk-3-dev msbuild
RUN pip3 install git+https://github.com/mesonbuild/meson/ RUN pip3 install git+https://github.com/mesonbuild/meson/

View file

@ -1,65 +0,0 @@
NOTE: This file is out of date. Please refer to http://www.mono-project.com/GAPI for a more complete and up-to-date guide to the GAPI tools included with Gtk#
How to use the Gtk# code generator:
Install dependencies:
* You need to install the XML::LibXML perl bindings and Gtk#.
Parse the library:
* Create an xml file defining the libraries to be parsed. The
format of the XML is:
<gapi-parser-input>
<api filename="../api/atk-api.xml">
<library name="libatk-1.0-0.dll">
<namespace name="Atk">
<dir>atk-1.2.4/atk</dir>
</namespace>
</library>
</api>
</gapi-parser-input>
The api element filename attribute specifies the parser output file location.
The name attribute on the library output points to the native library name. If
you are creating a cross-platform project, you will want to specify the win32 dll
name here and use mono's config mechanism to map the name on other platforms.
The dir element points to a src directory to be parsed. Currently all .c and .h
files in the directory are parsed.
All the elements inside the root can have multiples. The source/gtk-sharp-sources.xml
file has examples of producing multiple api files with a single parser input file, as
well as including muliple libraries in a single output file.
* Create metadata rules files named <namespace>.metadata in the directory where you invoke
the parser. Metadata rules allow you to massage the parsed api if necessary. Examples
of rule formats can be found in the sources directory.
* Execute the parser on your xml input file:
gapi-parser <xml-input-filename>
* Distribute the xml file(s) produced by the parser with your project so that your
users don't need to have any native library source, or perl libraries installed in
order to build your project.
Within your project directory, do the following:
* Setup a toplevel subdirectory for each namespace/assembly you
are wrapping. Instruct the makefile for this directory to compile,
at minimum, generated/*.
* Run gapi_codegen.exe on the API file(s) you created with the parser. If you depend
on any other wrapped libraries (such as gtk-sharp.dll), you need to include their API
listings via the --include directive. The code generator, if successful, will have
populated the assembly directories with generated/ directories. It is generally helpful
to automate this process with makefiles. Gtk# uses the following organization:
- sources/: Source directories, .sources listing, .metadata files.
developers run make manually here when they want to update the API files.
- api/: API files
The files are committed to CVS and included in releases for the convenience
of the lib user. This dir is included in the build before the namespace dirs
and the generator is invoked from this dir.

0
LICENSE Normal file → Executable file
View file

0
README.md Normal file → Executable file
View file

0
Source/Addins/MonoDevelop.GtkSharp.Addin.sln Normal file → Executable file
View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

5
Source/Libs/AssemblyInfo.cs Executable file
View file

@ -0,0 +1,5 @@
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly:AssemblyVersion("1.0.0.0")]
[assembly:AssemblyDelaySign(false)]

View file

View file

View file

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>netstandard2.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\..\BuildOutput\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\..\..\BuildOutput\Release</OutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\GLibSharp\GLibSharp.csproj">
<Name>GLibSharp</Name>
</ProjectReference>
</ItemGroup>
</Project>

View file

8
Source/Libs/AtkSharp/Class1.cs Executable file
View file

@ -0,0 +1,8 @@
using System;
namespace AtkSharp
{
public class Class1
{
}
}

View file

View file

0
Source/atk/Misc.cs → Source/Libs/AtkSharp/Misc.cs Normal file → Executable file
View file

View file

View file

0
Source/atk/Util.cs → Source/Libs/AtkSharp/Util.cs Normal file → Executable file
View file

View file

View file

View file

View file

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFramework>netstandard2.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\..\BuildOutput\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\..\..\BuildOutput\Release</OutputPath>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,8 @@
using System;
namespace CairoSharp
{
public class Class1
{
}
}

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

Some files were not shown because too many files have changed in this diff Show more