diff --git a/atk/meson.build b/atk/meson.build
index 9d634a434..7a3a8a6ea 100644
--- a/atk/meson.build
+++ b/atk/meson.build
@@ -41,5 +41,6 @@ library('atksharpglue-3', gluegen,
dependencies: [glib_dep, gio_dep, atk_dep],
install: install)
+nuget_infos += [['AtkSharp', atk_sharp, ['GlibSharp', 'GioSharp']]]
install_infos += [assembly_name, atk_sharp.full_path()]
atk_sharp_dep = declare_dependency(link_with: [glib_sharp, atk_sharp])
diff --git a/cairo/meson.build b/cairo/meson.build
index 4b5eff982..106228269 100644
--- a/cairo/meson.build
+++ b/cairo/meson.build
@@ -69,6 +69,7 @@ cairo_sharp = library(assembly_name, sources,
install_dir: lib_install_dir
)
+nuget_infos += [['CairoSharp', cairo_sharp, []]]
install_infos += [assembly_name, cairo_sharp.full_path()]
cairo_api_includes = join_paths(meson.current_source_dir(), 'cairo-api.xml')
diff --git a/gdk/meson.build b/gdk/meson.build
index 978141a47..6cadc86a5 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -83,6 +83,7 @@ library('gdksharpglue-3', gluegen,
dependencies: [glib_dep, gio_dep, atk_dep, gdk_dep],
install: install)
+nuget_infos += [['GdkSharp', gdk_sharp, ['GlibSharp', 'GioSharp', 'AtkSharp']]]
install_infos += [assembly_name, gdk_sharp.full_path()]
gdk_sharp_dep = declare_dependency(link_with: deps + [gdk_sharp])
diff --git a/gio/meson.build b/gio/meson.build
index d6ce7c437..ade3ae3b4 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -36,5 +36,6 @@ gio_sharp = library(assembly_name, source_gen, sources,
install_dir: lib_install_dir
)
+nuget_infos += [['GioSharp', gio_sharp, ['GlibSharp']]]
install_infos += [assembly_name, gio_sharp.full_path()]
gio_sharp_dep = declare_dependency(link_with: [glib_sharp, gio_sharp])
diff --git a/glib/meson.build b/glib/meson.build
index e110fe07d..6c4e4f772 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -98,6 +98,7 @@ glib_sharp = library(assembly_name, sources,
install_dir: lib_install_dir
)
+nuget_infos += [['GlibSharp', glib_sharp, []]]
install_infos += [assembly_name, glib_sharp.full_path()]
glib_api_includes = join_paths(meson.current_source_dir(), 'glib-api.xml')
diff --git a/gtk/meson.build b/gtk/meson.build
index 00978ead6..cf5ec0f82 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -151,5 +151,7 @@ library('gtksharpglue-3', gluegen,
dependencies: [glib_dep, gio_dep, atk_dep, gdk_dep, gtk_dep],
install: install)
+nuget_infos += [['GtkSharp', gtk_sharp, ['GlibSharp', 'GioSharp',
+ 'AtkSharp', 'GdkSharp']]]
install_infos += [assembly_name, gtk_sharp.full_path()]
gtk_sharp_dep = declare_dependency(link_with: deps + [gtk_sharp])
diff --git a/meson.build b/meson.build
index 973200cfc..63cb87a2c 100644
--- a/meson.build
+++ b/meson.build
@@ -7,6 +7,7 @@ if host_machine.system() == 'windows'
endif
+version = meson.project_version()
apiversion = '3.0.0.0'
mono_required_version = '>=3.2.0'
gtk_required_version='>=3.0.0'
@@ -65,10 +66,11 @@ remap_dl_data.set('LIB_SUFFIX', lib_suffix)
pkg_version = meson.project_name() + '-3.0'
version_data = configuration_data()
-version_data.set('VERSION', meson.project_version())
+version_data.set('VERSION', version)
version_data.set('PACKAGE_VERSION', pkg_version)
install_infos = []
+nuget_infos = []
lib_install_dir = join_paths(get_option('libdir'), 'mono', pkg_version)
pkg_install_dir = join_paths(get_option('libdir'), 'pkgconfig')
gapi_xml_installdir = join_paths(get_option('datadir'), 'gapi-3.0')
@@ -120,6 +122,29 @@ else
message('Gtk not found, not building')
endif
+nuget = find_program('nuget.py')
+license_path = 'https://github.com/gtk-sharp'
+project_uri = 'https://github.com/gtk-sharp'
+icon_uri = 'https://upload.wikimedia.org/wikipedia/en/5/5f/Gtk_Sharp_Logo.png'
+license_uri = 'https://github.com/gtk-sharp/gtk-sharp/blob/master/COPYING'
+
+deps = []
+foreach nugetinfo: nuget_infos
+ # FIXME - Pass proper '--owner' and '--author'
+ cmd = [nuget, '--package-name', nugetinfo[0], '--assembly', nugetinfo[1].full_path(),
+ '--project-url', project_uri, '--icon-url', icon_uri, '--license-url',
+ license_uri, '--version', version, '--tags', 'gtk bindings',
+ '--builddir', meson.current_build_dir()]
+
+ foreach dep: nugetinfo[2]
+ cmd += ['--dependency=' + dep + ':' + version]
+ endforeach
+
+ deps += [custom_target(nugetinfo[0] + '-nugget', command: cmd,
+ depends: [nugetinfo[1]] + deps,
+ output: nugetinfo[0] + '.' + version + '.nupkg')]
+endforeach
+
if install
gacutil_install = join_paths(meson.current_source_dir(), 'gacutil_install.py')
meson.add_install_script(gacutil_install, install_infos)
diff --git a/nuget.py b/nuget.py
new file mode 100644
index 000000000..bfa36960e
--- /dev/null
+++ b/nuget.py
@@ -0,0 +1,124 @@
+#!/usr/bin/python3
+import argparse
+import getpass
+import os
+import shutil
+import subprocess
+from datetime import datetime
+
+NUSPEC_TEMPLATE ="""
+
+
+ {package_name}
+ {author}
+ {owner}
+ {license_url}
+ {project_url}
+ {icon_url}
+ false
+ {description}.
+ {copyright}
+ {tags}
+ {version}
+
+{dependencies}
+
+
+{files}
+
+"""
+
+TARGETS_TEMPLATE = r"""
+
+
+
+
+
+
+
+
+"""
+
+
+class Nugetifier:
+ def cleanup_args(self):
+ self.nugetdir = os.path.join(self.builddir,
+ self.package_name + 'nupkg')
+ self.frameworkdir = 'net45'
+ self.nuget_build_dir = os.path.join(self.nugetdir, 'build', self.frameworkdir)
+ self.nuget_lib_dir = os.path.join(self.nugetdir, 'lib', self.frameworkdir)
+ self.nuspecfile = os.path.join(self.nugetdir, '%s.nuspec' % self.package_name)
+ self.nugettargets = os.path.join(self.nuget_build_dir, "%s.targets" % self.package_name)
+ self.nuget = shutil.which('nuget')
+ if not self.nuget:
+ print("Could not find the `nuget` tool, install it and retry!")
+ return -1
+
+ for d in [self.nugetdir, self.nuget_lib_dir, self.nuget_build_dir]:
+ os.makedirs(d, exist_ok=True)
+ if not self.description:
+ self.description = "%s c# bindings" % self.package_name
+ if not self.copyright:
+ self.copyright = "Copyright %s" % datetime.now().year
+ if not self.tags:
+ self.tags = self.package_name
+
+ return 0
+
+ def run(self):
+ res = self.cleanup_args()
+ if res:
+ return res
+
+ self.files = ''
+ def add_file(path, target="lib"):
+ f = ' \n' % (
+ path, os.path.join(target, os.path.basename(path)))
+ self.files += f
+
+ self.dependencies = ''
+ for dependency in self.dependency:
+ _id, version = dependency.split(":")
+ self.dependencies += ' \n' % (
+ _id, version)
+
+ for assembly in self.assembly:
+ add_file(assembly, os.path.join('lib', self.frameworkdir))
+
+ for f in [assembly + '.config', assembly[:-3] + 'pdb']:
+ if os.path.exists(f):
+ add_file(f, os.path.join('build', self.frameworkdir))
+
+ with open(self.nugettargets, 'w') as _:
+ print(TARGETS_TEMPLATE.format(**self.__dict__), file=_)
+ add_file(self.nugettargets, 'build')
+
+ with open(self.nuspecfile, 'w') as _:
+ print(NUSPEC_TEMPLATE.format(**self.__dict__), file=_)
+
+ subprocess.check_call([self.nuget, 'pack', self.nuspecfile],
+ cwd=self.builddir)
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--builddir')
+ parser.add_argument('--package-name')
+ parser.add_argument('--author', default=getpass.getuser())
+ parser.add_argument('--owner', default=getpass.getuser())
+ parser.add_argument('--native', action='append', default=[])
+ parser.add_argument('--assembly', action='append', default=[])
+ parser.add_argument('--out')
+ parser.add_argument('--description')
+ parser.add_argument('--copyright')
+ parser.add_argument('--version')
+ parser.add_argument('--icon-url', default='')
+ parser.add_argument('--project-url', default='')
+ parser.add_argument('--license-url', default='')
+ parser.add_argument('--tags', default='')
+ parser.add_argument('--dependency', default=[], action='append')
+
+ nugetifier = Nugetifier()
+ options = parser.parse_args(namespace=nugetifier)
+
+ exit(nugetifier.run())
diff --git a/pango/meson.build b/pango/meson.build
index f35fe615f..24d534313 100644
--- a/pango/meson.build
+++ b/pango/meson.build
@@ -77,5 +77,6 @@ library('pangosharpglue-3', gluegen,
dependencies: [glib_dep, gio_dep, pango_dep],
install: install)
+nuget_infos += [['PangoSharp', pango_sharp, ['GlibSharp', 'GioSharp']]]
install_infos += [assembly_name, pango_sharp.full_path()]
pango_sharp_dep = declare_dependency(link_with: deps + [pango_sharp])