mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-06-26 01:40:38 +00:00
Add a target to generate nugets.
This commit is contained in:
parent
6027acd4cc
commit
8193dd746c
|
@ -12,7 +12,6 @@ sources = [
|
||||||
|
|
||||||
subdir('generated')
|
subdir('generated')
|
||||||
|
|
||||||
# Install with gacutil_install.py from gtk-sharp.
|
|
||||||
ges_sharp = library(pkg + '-sharp', source_gen, sources,
|
ges_sharp = library(pkg + '-sharp', source_gen, sources,
|
||||||
cs_args: ['-nowarn:169', '-nowarn:108', '-nowarn:114', '-unsafe',
|
cs_args: ['-nowarn:169', '-nowarn:108', '-nowarn:114', '-unsafe',
|
||||||
'-keyfile:' + snk],
|
'-keyfile:' + snk],
|
||||||
|
@ -29,7 +28,6 @@ library('gessharpglue-1.0.0', gluegen, dependencies: gst_deps + [ges_dep])
|
||||||
|
|
||||||
ges_sharp_dep = declare_dependency(dependencies: [glib_sharp_dep, gio_sharp_dep, gst_sharp_dep,
|
ges_sharp_dep = declare_dependency(dependencies: [glib_sharp_dep, gio_sharp_dep, gst_sharp_dep,
|
||||||
ges_dep], link_with: ges_sharp)
|
ges_dep], link_with: ges_sharp)
|
||||||
meson.add_install_script(gacutil_install, meson.project_name(), gst_sharp.full_path())
|
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
input: pkg + '-sharp.dll.config',
|
input: pkg + '-sharp.dll.config',
|
||||||
|
|
69
meson.build
69
meson.build
|
@ -1,6 +1,5 @@
|
||||||
project('gstreamer-sharp', ['cs', 'c'], version: '1.12.0',
|
project('gstreamer-sharp', ['cs', 'c'], version: '1.12.0',
|
||||||
meson_version: '>0.42')
|
meson_version: '>0.42', license: 'LGPL')
|
||||||
|
|
||||||
|
|
||||||
if host_machine.system() == 'osx'
|
if host_machine.system() == 'osx'
|
||||||
lib_prefix=''
|
lib_prefix=''
|
||||||
|
@ -12,47 +11,36 @@ endif
|
||||||
|
|
||||||
gtk_sharp_required_version = '>=3.22.6'
|
gtk_sharp_required_version = '>=3.22.6'
|
||||||
|
|
||||||
glib_sharp_dep = dependency('glib-sharp-3.0',
|
subproject('gtk-sharp', default_options: ['install=false'])
|
||||||
version: gtk_sharp_required_version,
|
gtk_sharp = subproject('gtk-sharp')
|
||||||
fallback: ['gtk-sharp', 'glib_sharp_dep'])
|
|
||||||
|
|
||||||
gio_sharp_dep = dependency('gio-sharp-3.0',
|
glib_sharp_dep = gtk_sharp.get_variable('glib_sharp_dep')
|
||||||
version: gtk_sharp_required_version,
|
glib_sharp = gtk_sharp.get_variable('glib_sharp')
|
||||||
fallback: ['gtk-sharp', 'gio_sharp_dep'])
|
|
||||||
|
|
||||||
if glib_sharp_dep.type_name() == 'internal'
|
gio_sharp_dep = gtk_sharp.get_variable('gio_sharp_dep')
|
||||||
gtk_sharp = subproject('gtk-sharp')
|
gio_sharp = gtk_sharp.get_variable('gio_sharp')
|
||||||
gapi_fixup = gtk_sharp.get_variable('gapi_fixup')
|
gio_glue = gtk_sharp.get_variable('gio_glue')
|
||||||
gapi_codegen = gtk_sharp.get_variable('gapi_codegen')
|
|
||||||
glib_api_includes = gtk_sharp.get_variable('glib_api_includes')
|
gapi_fixup = gtk_sharp.get_variable('gapi_fixup')
|
||||||
gio_api_includes = gtk_sharp.get_variable('gio_api_includes')
|
gapi_codegen = gtk_sharp.get_variable('gapi_codegen')
|
||||||
has_gtk = gtk_sharp.get_variable('has_gtk')
|
|
||||||
if has_gtk
|
glib_api_includes = gtk_sharp.get_variable('glib_api_includes')
|
||||||
gtk_sharp_dep = [gtk_sharp.get_variable('gtk_sharp_dep'),
|
gio_api_includes = gtk_sharp.get_variable('gio_api_includes')
|
||||||
gtk_sharp.get_variable('atk_sharp_dep')]
|
has_gtk = gtk_sharp.get_variable('has_gtk')
|
||||||
else
|
if has_gtk
|
||||||
gtk_sharp_dep = dependency('gtk-sharp-3.0', version: gtk_sharp_required_version,
|
gtk_sharp_dep = [gtk_sharp.get_variable('gtk_sharp_dep'),
|
||||||
required: false)
|
gtk_sharp.get_variable('atk_sharp_dep')]
|
||||||
endif
|
|
||||||
codegen_dependencies = [gapi_codegen, gapi_fixup]
|
|
||||||
gapi_fixup = gapi_fixup.full_path()
|
|
||||||
gapi_codegen = gapi_codegen.full_path()
|
|
||||||
else
|
else
|
||||||
gtk_sharp_dep = dependency('gtk-sharp-3.0', version: gtk_sharp_required_version,
|
gtk_sharp_dep = dependency('gtk-sharp-3.0', version: gtk_sharp_required_version,
|
||||||
required: false)
|
required: false)
|
||||||
has_gtk = gtk_sharp_dep.found()
|
|
||||||
|
|
||||||
gapi_fixup = find_program('gapi3-fixup')
|
|
||||||
gapi_codegen = find_program('gapi3-codegen')
|
|
||||||
pkgconfig = find_program('pkg-config')
|
|
||||||
glib_api_includes = run_command(pkgconfig, '--cflags', 'glib-sharp-3.0').stdout()
|
|
||||||
gio_api_includes = run_command(pkgconfig, '--cflags', 'gio-sharp-3.0').stdout()
|
|
||||||
codegen_dependencies = []
|
|
||||||
endif
|
endif
|
||||||
|
codegen_dependencies = [gapi_codegen, gapi_fixup]
|
||||||
|
gapi_fixup = gapi_fixup.full_path()
|
||||||
|
gapi_codegen = gapi_codegen.full_path()
|
||||||
|
|
||||||
gacutil = find_program('gacutil')
|
gacutil = find_program('gacutil')
|
||||||
generate_api = find_program('generate_code.py')
|
generate_api = find_program('generate_code.py')
|
||||||
gacutil_install = join_paths(meson.current_source_dir(), 'gacutil_install.py')
|
nuget = join_paths(meson.current_source_dir(), 'nuget.py')
|
||||||
|
|
||||||
# TODO Handle monodoc
|
# TODO Handle monodoc
|
||||||
|
|
||||||
|
@ -88,6 +76,19 @@ if ges_dep.found()
|
||||||
subdir('ges')
|
subdir('ges')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
meson.add_install_script(nuget, '--package-name', 'GstSharp',
|
||||||
|
'--assembly', gst_sharp.full_path(),
|
||||||
|
'--native', gst_glue.full_path(),
|
||||||
|
'--assembly', gio_sharp.full_path(),
|
||||||
|
'--native', gio_glue.full_path(),
|
||||||
|
'--assembly', glib_sharp.full_path(),
|
||||||
|
'--project-url', 'https://gstreamer.freedesktop.org/modules/gstreamer-sharp.html',
|
||||||
|
'--icon-url', 'https://gstreamer.freedesktop.org/images/header-logo-top.png',
|
||||||
|
'--license-url', 'https://cgit.freedesktop.org/gstreamer/gstreamer-sharp/plain/COPYING',
|
||||||
|
'--version', meson.project_version(),
|
||||||
|
'--tags', 'GStreamer GstSharp bindings',
|
||||||
|
)
|
||||||
|
|
||||||
subdir('samples')
|
subdir('samples')
|
||||||
|
|
||||||
bindinate = find_program('bindinate', required: false)
|
bindinate = find_program('bindinate', required: false)
|
||||||
|
|
123
nuget.py
Normal file
123
nuget.py
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
#!/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 = """<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Target Name="CopyMapConfigs" AfterTargets="AfterBuild">
|
||||||
|
<CreateItem Include="$(MSBuildThisFileDirectory)\*.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.builddir = os.path.abspath(os.path.curdir)
|
||||||
|
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, self.frameworkdir, 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)
|
||||||
|
|
||||||
|
for f in [assembly + '.config', assembly[:-3] + 'pdb']:
|
||||||
|
if os.path.exists(f):
|
||||||
|
add_file(f, 'build')
|
||||||
|
|
||||||
|
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('--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='')
|
||||||
|
|
||||||
|
nugetifier = Nugetifier()
|
||||||
|
options = parser.parse_args(namespace=nugetifier)
|
||||||
|
|
||||||
|
exit(nugetifier.run())
|
|
@ -36,7 +36,6 @@ sources = [
|
||||||
|
|
||||||
subdir('generated')
|
subdir('generated')
|
||||||
|
|
||||||
# Install with gacutil_install.py from gtk-sharp.
|
|
||||||
gst_sharp = library('gstreamer-sharp', gst_source_gen, sources,
|
gst_sharp = library('gstreamer-sharp', gst_source_gen, sources,
|
||||||
cs_args: ['-nowarn:169', '-nowarn:108', '-nowarn:114', '-unsafe',
|
cs_args: ['-nowarn:169', '-nowarn:108', '-nowarn:114', '-unsafe',
|
||||||
'-keyfile:' + snk],
|
'-keyfile:' + snk],
|
||||||
|
@ -48,11 +47,10 @@ gluegen = custom_target('gluegen',
|
||||||
command: [generate_api, '--fakeglue'],
|
command: [generate_api, '--fakeglue'],
|
||||||
depends: [gst_source_gen])
|
depends: [gst_source_gen])
|
||||||
|
|
||||||
library('gstreamersharpglue-1.0.0', gluegen, 'glue/gobject.c', dependencies: gst_deps)
|
gst_glue = library('gstreamersharpglue-1.0.0', gluegen, 'glue/gobject.c', dependencies: gst_deps)
|
||||||
|
|
||||||
gst_sharp_dep = declare_dependency(dependencies: [glib_sharp_dep, gio_sharp_dep],
|
gst_sharp_dep = declare_dependency(dependencies: [glib_sharp_dep, gio_sharp_dep],
|
||||||
link_with: gst_sharp)
|
link_with: gst_sharp)
|
||||||
meson.add_install_script(gacutil_install, meson.project_name(), gst_sharp.full_path())
|
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
input: '../out/gstreamer-sharp.dll.config',
|
input: '../out/gstreamer-sharp.dll.config',
|
||||||
|
|
Loading…
Reference in a new issue