Generate nuggets for each assembly
Maybe we will want to unsplit some of them, but this makes everything pretty flexible.
This commit is contained in:
parent
c7205a135d
commit
e43baacb48
9 changed files with 158 additions and 1 deletions
|
@ -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])
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -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])
|
||||
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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])
|
||||
|
|
27
meson.build
27
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)
|
||||
|
|
124
nuget.py
Normal file
124
nuget.py
Normal file
|
@ -0,0 +1,124 @@
|
|||
#!/usr/bin/python3
|
||||
import argparse
|
||||
import getpass
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
|
||||
NUSPEC_TEMPLATE ="""<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>{package_name}</id>
|
||||
<authors>{author}</authors>
|
||||
<owners>{owner}</owners>
|
||||
<licenseUrl>{license_url}</licenseUrl>
|
||||
<projectUrl>{project_url}</projectUrl>
|
||||
<iconUrl>{icon_url}</iconUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>{description}.</description>
|
||||
<copyright>{copyright}</copyright>
|
||||
<tags>{tags}</tags>
|
||||
<version>{version}</version>
|
||||
<dependencies>
|
||||
{dependencies} </dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
{files} </files>
|
||||
</package>
|
||||
"""
|
||||
|
||||
TARGETS_TEMPLATE = r"""<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="{package_name}CopyMapConfigs" AfterTargets="AfterBuild">
|
||||
<CreateItem Include="$(MSBuildThisFileDirectory)\{frameworkdir}\*.config">
|
||||
<Output TaskParameter="Include" ItemName="MapConfigs" />
|
||||
</CreateItem>
|
||||
|
||||
<Copy SourceFiles="@(MapConfigs)" DestinationFiles="@(MapConfigs->'$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
</Target>
|
||||
</Project>"""
|
||||
|
||||
|
||||
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 = ' <file src="%s" target="%s"/>\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 += ' <dependency id="%s" version="%s" />\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())
|
|
@ -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])
|
||||
|
|
Loading…
Reference in a new issue