mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-09 09:25:39 +00:00
Rewrite of the nuget package genertion code, also included the glue libs
This commit is contained in:
parent
3a80531bdb
commit
c45e3558b6
|
@ -1,9 +1,11 @@
|
|||
#!/usr/bin/python3
|
||||
"""Script to build out the .Net dll's and package them into a Nuget Package for gtksharp3"""
|
||||
import os, sys
|
||||
from pybuild.GtkSharp_Builder import GtkSharp_Builder
|
||||
from pybuild.Gtk_Builder import Gtk_Builder
|
||||
from pybuild.Helper import Helper as helpers
|
||||
from pybuild.profiles.GtkSharp import GtkSharp
|
||||
from pybuild.profiles.Glue_Win32 import Glue_Win32
|
||||
from pybuild.profiles.Glue_Win64 import Glue_Win64
|
||||
from pybuild.profiles.Gtk_Win32 import Gtk_Win32
|
||||
from pybuild.profiles.Gtk_Win64 import Gtk_Win64
|
||||
|
||||
# Ideally I'd like to see the GtkSharp Build system redone via .Net Core or something other than make
|
||||
# For now though we rely on the use of make to build the .Net dll's
|
||||
|
@ -11,11 +13,6 @@ from pybuild.Helper import Helper as helpers
|
|||
|
||||
class Build(object):
|
||||
|
||||
# Class Init
|
||||
def __init__(self):
|
||||
self.GtkSharp_Builder = GtkSharp_Builder()
|
||||
self.Gtk_Builder = Gtk_Builder()
|
||||
|
||||
# Clean the Build directory
|
||||
def clean(self):
|
||||
"""Clean the build dir"""
|
||||
|
@ -26,34 +23,56 @@ class Build(object):
|
|||
def usage(self):
|
||||
print ("Please use GtkSharp3_Build.py <target> where <target> is one of")
|
||||
print (" clean to clean the output directory: ./build")
|
||||
print (" gtksharp_net45 to build ,Net libs for GtkSharp, via .Net 4.5")
|
||||
print (" gtksharp_nuget_net45 to build Nuget Packages for GtkSharp, via .Net 4.5")
|
||||
print (" gtk_nuget_win32 to build the Nuget package for GtkSharp.Win32")
|
||||
print (" gtk_nuget_win64 to build the Nuget package for GtkSharp.Win64")
|
||||
print (" all to make all")
|
||||
|
||||
# print (" gtksharp_all to build .Net libs for GtkSharp, via .Net 4.5 and .Net Core")
|
||||
print (" gtksharp_net45 to build .Net libs for GtkSharp, via .Net 4.5")
|
||||
# print (" gtksharp_core to build .Net libs for GtkSharp, via .Net Core")
|
||||
|
||||
print (" gtk_win32 to build the Nuget package for GtkSharp.Win32")
|
||||
print (" gtk_win64 to build the Nuget package for GtkSharp.Win64")
|
||||
print (" all to make all")
|
||||
|
||||
def main(self):
|
||||
if len(sys.argv) != 2:
|
||||
self.usage()
|
||||
return
|
||||
|
||||
if sys.argv[1] == "gtksharp_net45":
|
||||
self.GtkSharp_Builder.build_net45()
|
||||
if sys.argv[1] == "gtksharp_nuget_net45":
|
||||
self.GtkSharp_Builder.build_nuget_net45()
|
||||
if sys.argv[1] == "gtk_nuget_win32":
|
||||
self.Gtk_Builder.build_nuget_win32()
|
||||
if sys.argv[1] == "gtk_nuget_win64":
|
||||
self.Gtk_Builder.build_nuget_win64()
|
||||
if sys.argv[1] == 'all':
|
||||
self.runbuild('gtksharp_net45')
|
||||
self.runbuild('gtk_win32')
|
||||
self.runbuild('gtk_win64')
|
||||
return
|
||||
|
||||
if sys.argv[1] == "all":
|
||||
self.GtkSharp_Builder.build_net45()
|
||||
self.GtkSharp_Builder.build_nuget_net45()
|
||||
self.Gtk_Builder.build_nuget_win32()
|
||||
self.Gtk_Builder.build_nuget_win64()
|
||||
self.runbuild(sys.argv[1])
|
||||
|
||||
if sys.argv[1] == "clean":
|
||||
|
||||
def runbuild(self, build_type):
|
||||
|
||||
if build_type == 'clean':
|
||||
self.clean()
|
||||
|
||||
elif build_type == 'gtksharp_net45':
|
||||
profile = GtkSharp()
|
||||
profile.clean()
|
||||
profile.build_net45()
|
||||
profile.copy_net45()
|
||||
profile.build_nuget()
|
||||
|
||||
elif build_type == 'gtk_win32':
|
||||
profile_glue = Glue_Win32()
|
||||
profile_glue.clean()
|
||||
profile_glue.build()
|
||||
profile_gtk = Gtk_Win32()
|
||||
profile_gtk.build()
|
||||
profile_gtk.build_nuget()
|
||||
|
||||
elif build_type == 'gtk_win64':
|
||||
profile_glue = Glue_Win64()
|
||||
profile_glue.clean()
|
||||
profile_glue.build()
|
||||
profile = Gtk_Win64()
|
||||
profile.build()
|
||||
profile.build_nuget()
|
||||
|
||||
if __name__ == "__main__":
|
||||
Build().main()
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<metadata>
|
||||
<id>GBD.GtkSharp</id>
|
||||
<version>3.22.0</version>
|
||||
<authors>Ric Westell</authors>
|
||||
<authors>Grbd</authors>
|
||||
<owners>grbd</owners>
|
||||
<licenseUrl>https://github.com/mono/gtk-sharp/blob/master/COPYING</licenseUrl>
|
||||
<projectUrl>https://github.com/mono/gtk-sharp</projectUrl>
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
#! python3
|
||||
import os, shutil
|
||||
from pybuild.Settings import Settings
|
||||
from pybuild.Helper import Helper as helpers
|
||||
from os.path import join
|
||||
from xml.etree import ElementTree as et
|
||||
|
||||
class GtkSharp_Builder(object):
|
||||
|
||||
def __init__(self):
|
||||
"""Class Init"""
|
||||
self.setts = Settings()
|
||||
|
||||
def clean(self):
|
||||
"""Clean the build dir"""
|
||||
helpers.emptydir('./build')
|
||||
print ("Clean finished")
|
||||
|
||||
def build_net45(self):
|
||||
"""Build the gtksharp binaries for .Net 4.5"""
|
||||
self.clean()
|
||||
os.makedirs(self.setts.BuildDir, exist_ok=True)
|
||||
buildfile = join(self.setts.BuildDir, 'net45_build.sh')
|
||||
|
||||
# run script via MSYS for windows, or shell for linux
|
||||
if os.name == 'nt':
|
||||
print("Building .Net GtkSharp using MSYS2")
|
||||
with open(buildfile, 'w') as f:
|
||||
f.write('PATH=$PATH:/c/Program\ Files\ \(x86\)/Microsoft\ SDKs/Windows/v10.0A/bin/NETFX\ 4.6\ Tools/\n')
|
||||
f.write('PATH=$PATH:/c/Windows/Microsoft.NET/Framework/v4.0.30319/\n')
|
||||
f.write('cd ' + helpers.winpath_to_msyspath(self.setts.SrcDir + '\n'))
|
||||
f.write('./autogen.sh --prefix=/tmp/install\n')
|
||||
f.write('make clean\n')
|
||||
f.write('make\n')
|
||||
cmds = [join(self.setts.msys2path, 'usr\\bin\\bash.exe'), '--login', buildfile]
|
||||
cmd = helpers.run_cmd(cmds, self.setts.SrcDir)
|
||||
|
||||
else:
|
||||
print("Building using Linux shell")
|
||||
with open(buildfile, 'w') as f:
|
||||
f.write('cd ' + self.setts.SrcDir + '\n')
|
||||
f.write('./autogen.sh --prefix=/tmp/install\n')
|
||||
f.write('make clean\n')
|
||||
f.write('make\n')
|
||||
cmds = [self.setts.bashpath, buildfile]
|
||||
cmd = helpers.run_cmd(cmds, self.setts.SrcDir)
|
||||
|
||||
def build_nuget_net45(self):
|
||||
"""Package up a nuget file based on the default build"""
|
||||
self.clean()
|
||||
net45_build_dir = join(self.setts.BuildDir, 'build', 'net45')
|
||||
net45_lib_dir = join(self.setts.BuildDir, 'lib', 'net45')
|
||||
GtkVersion = helpers.get_gtksharp_version(self.setts.SrcDir)
|
||||
|
||||
os.makedirs(self.setts.BuildDir, exist_ok=True)
|
||||
os.makedirs(net45_build_dir, exist_ok=True)
|
||||
os.makedirs(net45_lib_dir, exist_ok=True)
|
||||
|
||||
print ('Copying Files')
|
||||
shutil.copy('./misc/GtkSharp.nuspec', self.setts.BuildDir)
|
||||
shutil.copy('./misc/GtkSharp.targets', net45_build_dir)
|
||||
|
||||
dll_list = ['atk', 'cairo', 'gdk', 'gio', 'glib', 'gtk', 'pango']
|
||||
for item in dll_list:
|
||||
shutil.copy(join(self.setts.SrcDir, item, item + "-sharp.dll"), net45_lib_dir)
|
||||
if item != 'cairo':
|
||||
shutil.copy(join(self.setts.SrcDir, item, item + '-sharp.dll.config'), net45_build_dir)
|
||||
|
||||
# Edit the XML version / package name in the .nuspec file
|
||||
nuspecfile = join(self.setts.BuildDir, 'GtkSharp.nuspec')
|
||||
et.register_namespace('', 'http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd')
|
||||
tree = et.parse(nuspecfile)
|
||||
xmlns = {'nuspec': '{http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd}'}
|
||||
tree.find('.//{nuspec}version'.format(**xmlns)).text = GtkVersion
|
||||
tree.find('.//{nuspec}id'.format(**xmlns)).text = self.setts.Gtksharp_PackageName
|
||||
tree.write(nuspecfile)
|
||||
|
||||
# Run Nuget
|
||||
helpers.run_cmd([self.setts.NuGetExe, 'pack', 'GtkSharp.nuspec'], self.setts.BuildDir)
|
||||
|
||||
nugetfile = join(self.setts.BuildDir, self.setts.Gtksharp_PackageName + '.' + GtkVersion + '.nupkg')
|
||||
os.makedirs(self.setts.NugetPkgs, exist_ok=True)
|
||||
shutil.copy(nugetfile, self.setts.NugetPkgs)
|
||||
|
||||
print ('Generation of Nuget package complete')
|
|
@ -1,77 +0,0 @@
|
|||
#! python3
|
||||
import os, shutil
|
||||
from pybuild.Settings import Settings
|
||||
from pybuild.Helper import Helper as helpers
|
||||
from os.path import join
|
||||
from xml.etree import ElementTree as et
|
||||
|
||||
# This script assumes the gtk libraries have already been installed via MSYS2 / MinGW32 / MinGW64
|
||||
|
||||
class Gtk_Builder(object):
|
||||
|
||||
def __init__(self):
|
||||
"""Class Init"""
|
||||
self.setts = Settings()
|
||||
|
||||
def clean(self):
|
||||
"""Clean the build dir"""
|
||||
helpers.emptydir('./build')
|
||||
print ("Clean finished")
|
||||
|
||||
def build_nuget_win32(self):
|
||||
self.build_nuget('Win32')
|
||||
|
||||
def build_nuget_win64(self):
|
||||
self.build_nuget('Win64')
|
||||
|
||||
def build_nuget(self, arch):
|
||||
"""Package up a nuget file based on the default build"""
|
||||
|
||||
if os.name != 'nt':
|
||||
print("Skipping Native Nuget package build, as this needs to be run on Windows")
|
||||
return
|
||||
|
||||
self.clean()
|
||||
net45_build_dir = join(self.setts.BuildDir, 'build', 'net45')
|
||||
if arch == 'Win32':
|
||||
mingwdir = self.setts.mingwin32path
|
||||
else:
|
||||
mingwdir = self.setts.mingwin64path
|
||||
|
||||
os.makedirs(self.setts.BuildDir, exist_ok=True)
|
||||
os.makedirs(net45_build_dir, exist_ok=True)
|
||||
|
||||
print ('Copying Files')
|
||||
shutil.copy('./misc/GtkSharp.nuspec', self.setts.BuildDir)
|
||||
shutil.copy('./misc/GtkSharp.Native.targets', join(net45_build_dir, 'GtkSharp.' + arch + '.targets'))
|
||||
|
||||
# Copy dlls
|
||||
dll_list = []
|
||||
dll_list += self.setts.get_native_win_dlls()
|
||||
dll_list += self.setts.get_native_win_deps()
|
||||
|
||||
for item in dll_list:
|
||||
src = join(mingwdir, item)
|
||||
helpers.copy_files(src, net45_build_dir)
|
||||
|
||||
# Get version
|
||||
GtkVersion = helpers.get_gtk_version(self.setts.msys2path)
|
||||
|
||||
# Edit the XML version / package name in the .nuspec file
|
||||
nuspecfile = join(self.setts.BuildDir, 'GtkSharp.nuspec')
|
||||
et.register_namespace('', 'http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd')
|
||||
tree = et.parse(nuspecfile)
|
||||
xmlns = {'nuspec': '{http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd}'}
|
||||
tree.find('.//{nuspec}version'.format(**xmlns)).text = GtkVersion
|
||||
tree.find('.//{nuspec}id'.format(**xmlns)).text = self.setts.Gtksharp_PackageName + '.' + arch
|
||||
tree.write(nuspecfile)
|
||||
|
||||
# Run Nuget
|
||||
helpers.run_cmd([self.setts.NuGetExe, 'pack', 'GtkSharp.nuspec'], self.setts.BuildDir)
|
||||
|
||||
nugetfile = join(self.setts.BuildDir, self.setts.Gtksharp_PackageName + '.' + arch + '.' + GtkVersion + '.nupkg')
|
||||
os.makedirs(self.setts.NugetPkgs, exist_ok=True)
|
||||
shutil.copy(nugetfile, self.setts.NugetPkgs)
|
||||
|
||||
print ('Generation of Nuget package complete')
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#! python3
|
||||
#!/usr/bin/python3
|
||||
"""Helper Functions"""
|
||||
|
||||
import os, subprocess, shutil, sys
|
||||
|
@ -57,7 +57,7 @@ class Helper(object):
|
|||
break
|
||||
return ret
|
||||
|
||||
def get_gtk_version(msyspath):
|
||||
def get_gtk_version_msys(msyspath):
|
||||
ret = ''
|
||||
pacman_path = join(msyspath, 'usr\\bin\\pacman.exe')
|
||||
# pull version from msys2 / pacman
|
||||
|
@ -72,7 +72,3 @@ class Helper(object):
|
|||
ret = ret[:-2]
|
||||
break
|
||||
return ret
|
||||
|
||||
def copy_files(src_glob, dst_folder):
|
||||
for fname in iglob(src_glob):
|
||||
shutil.copy(fname, join(dst_folder, ntpath.basename(fname)))
|
87
NuGet/pybuild/ProfileBase.py
Normal file
87
NuGet/pybuild/ProfileBase.py
Normal file
|
@ -0,0 +1,87 @@
|
|||
#!/usr/bin/python3
|
||||
"""Base class for Settings profiles"""
|
||||
|
||||
import os, shutil
|
||||
from os.path import abspath, join
|
||||
from xml.etree import ElementTree as et
|
||||
from pybuild.Helper import Helper
|
||||
|
||||
class ProfileBase(object):
|
||||
|
||||
def __init__(self):
|
||||
"""Class Init"""
|
||||
self._NuGetPath = 'nuget.exe'
|
||||
self._SrcDir = '../'
|
||||
self._BuildDir = './build'
|
||||
self._PackageDestination = './nupkg'
|
||||
self._NuGet_PackageName = ''
|
||||
self._MsysPath = 'C:\\msys64'
|
||||
self._LinuxBashPath = '/bin/bash'
|
||||
self._Version = '0.0.0'
|
||||
|
||||
@property
|
||||
def NuGetPath(self):
|
||||
return self._NuGetPath
|
||||
|
||||
@property
|
||||
def SrcDir(self):
|
||||
return abspath(self._SrcDir)
|
||||
|
||||
@property
|
||||
def BuildDir(self):
|
||||
return abspath(self._BuildDir)
|
||||
|
||||
@property
|
||||
def Build_NugetDir(self):
|
||||
return abspath(join(self._BuildDir, 'nuget'))
|
||||
|
||||
@property
|
||||
def PackageDestination(self):
|
||||
return abspath(self._PackageDestination)
|
||||
|
||||
@property
|
||||
def NuGet_PackageName(self):
|
||||
return self._NuGet_PackageName
|
||||
|
||||
@property
|
||||
def MsysPath(self):
|
||||
return abspath(self._MsysPath)
|
||||
|
||||
@property
|
||||
def LinuxBashPath(self):
|
||||
return abspath(self._LinuxBashPath)
|
||||
|
||||
@property
|
||||
def Version(self):
|
||||
return self._Version
|
||||
|
||||
|
||||
def clean(self):
|
||||
"""Clean the build dir"""
|
||||
Helper.emptydir('./build')
|
||||
print ("Clean finished")
|
||||
|
||||
|
||||
def build_nuget(self):
|
||||
"""Package up a nuget file based on the default build"""
|
||||
|
||||
# Copy Nuget Spec file
|
||||
shutil.copy('./misc/GtkSharp.nuspec', self.Build_NugetDir)
|
||||
|
||||
# Edit the XML version / package name in the .nuspec file
|
||||
nuspecfile = join(self.Build_NugetDir, 'GtkSharp.nuspec')
|
||||
et.register_namespace('', 'http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd')
|
||||
tree = et.parse(nuspecfile)
|
||||
xmlns = {'nuspec': '{http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd}'}
|
||||
tree.find('.//{nuspec}version'.format(**xmlns)).text = self.Version
|
||||
tree.find('.//{nuspec}id'.format(**xmlns)).text = self.NuGet_PackageName
|
||||
tree.write(nuspecfile)
|
||||
|
||||
# Run Nuget
|
||||
Helper.run_cmd([self.NuGetPath, 'pack', 'GtkSharp.nuspec'], self.Build_NugetDir)
|
||||
|
||||
# Copy Nuget files out of build directory
|
||||
nugetfile = join(self.Build_NugetDir, self.NuGet_PackageName + '.' + self.Version + '.nupkg')
|
||||
os.makedirs(self.PackageDestination, exist_ok=True)
|
||||
shutil.copy(nugetfile, self.PackageDestination)
|
||||
print ('Generation of Nuget package complete - ' + self.NuGet_PackageName)
|
|
@ -1,80 +0,0 @@
|
|||
#! python3
|
||||
"""Settings for scripts"""
|
||||
|
||||
import os
|
||||
|
||||
class Settings(object):
|
||||
|
||||
def __init__(self):
|
||||
"""Class Init"""
|
||||
|
||||
self.NuGetExe = 'nuget.exe'
|
||||
self.Gtksharp_PackageName = 'GBD.GtkSharp'
|
||||
|
||||
self.SrcDir = '../'
|
||||
self.BuildDir = './build'
|
||||
self.NugetPkgs = './nupkg'
|
||||
self.SrcDir = os.path.abspath(self.SrcDir)
|
||||
self.BuildDir = os.path.abspath(self.BuildDir)
|
||||
self.NugetPkgs = os.path.abspath(self.NugetPkgs)
|
||||
|
||||
self.msys2path = 'C:\\msys64'
|
||||
self.msys2path = os.path.abspath(self.msys2path)
|
||||
self.bashpath = '/bin/bash'
|
||||
|
||||
self.mingwin32path = 'C:\\msys64\\mingw32\\bin'
|
||||
self.mingwin32path = os.path.abspath(self.mingwin32path)
|
||||
self.mingwin64path = 'C:\\msys64\\mingw64\\bin'
|
||||
self.mingwin64path = os.path.abspath(self.mingwin64path)
|
||||
|
||||
def get_native_win_dlls(self):
|
||||
ret = []
|
||||
|
||||
# Gtk
|
||||
ret.append('libgtk-3-0.dll')
|
||||
ret.append('libgdk-3-0.dll')
|
||||
|
||||
# atk
|
||||
ret.append('libatk-1.0-0.dll')
|
||||
|
||||
# cairo
|
||||
ret.append('libcairo-2.dll')
|
||||
ret.append('libcairo-gobject-2.dll')
|
||||
|
||||
# gdk-pixbuf
|
||||
ret.append('libgdk_pixbuf-2.0-0.dll')
|
||||
|
||||
# glib2
|
||||
ret.append('libgio-2.0-0.dll')
|
||||
ret.append('libglib-2.0-0.dll')
|
||||
ret.append('libgmodule-2.0-0.dll')
|
||||
ret.append('libgobject-2.0-0.dll')
|
||||
|
||||
# pango
|
||||
ret.append('libpango-1.0-0.dll')
|
||||
ret.append('libpangocairo-1.0-0.dll')
|
||||
ret.append('libpangoft2-1.0-0.dll')
|
||||
ret.append('libpangowin32-1.0-0.dll')
|
||||
return ret
|
||||
|
||||
def get_native_win_deps(self):
|
||||
ret = []
|
||||
# Determined by using PE Explorer
|
||||
ret.append('libgcc_*.dll')
|
||||
ret.append('libepoxy-0.dll')
|
||||
ret.append('libintl-8.dll')
|
||||
ret.append('libwinpthread-1.dll')
|
||||
ret.append('libiconv-2.dll')
|
||||
ret.append('libfontconfig-1.dll')
|
||||
ret.append('libexpat-1.dll')
|
||||
ret.append('libfreetype-6.dll')
|
||||
ret.append('libpixman-1-0.dll')
|
||||
ret.append('libpng16-16.dll')
|
||||
ret.append('zlib1.dll')
|
||||
ret.append('libpcre-1.dll')
|
||||
ret.append('libffi-6.dll')
|
||||
ret.append('libharfbuzz-0.dll')
|
||||
ret.append('libgraphite2.dll')
|
||||
ret.append('libstdc++-6.dll')
|
||||
ret.append('libbz2-1.dll')
|
||||
return ret
|
51
NuGet/pybuild/profiles/Glue_Win32.py
Normal file
51
NuGet/pybuild/profiles/Glue_Win32.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os, shutil, ntpath
|
||||
from pybuild.ProfileBase import ProfileBase
|
||||
from os.path import abspath, join
|
||||
from glob import glob
|
||||
from pybuild.Helper import Helper
|
||||
from pybuild.profiles.GtkSharp import GtkSharp
|
||||
|
||||
class Glue_Win32(ProfileBase):
|
||||
|
||||
def __init__(self):
|
||||
"""Class Init"""
|
||||
super().__init__()
|
||||
self._NuGet_PackageName = 'GtkSharp.Win32.Glue'
|
||||
self._Version = Helper.get_gtksharp_version(self.SrcDir)
|
||||
self.MSYSTEM = 'MINGW32'
|
||||
|
||||
def Get_Dlls_GtkSharp_Glue(self):
|
||||
ret = []
|
||||
|
||||
# Gtksharp Glue libs
|
||||
ret.append(['atk/glue/.libs/*atksharpglue-3.dll', 'atksharpglue-3.dl_'])
|
||||
ret.append(['pango/glue/.libs/*pangosharpglue-3.dll', 'pangosharpglue-3.dl_'])
|
||||
ret.append(['gio/glue/.libs/*giosharpglue-3.dll', 'giosharpglue-3.dl_'])
|
||||
ret.append(['gtk/glue/.libs/*gtksharpglue-3.dll', 'gtksharpglue-3.dl_'])
|
||||
return ret
|
||||
|
||||
def build(self):
|
||||
"""Package up a nuget file based on the default build"""
|
||||
|
||||
if os.name != 'nt':
|
||||
print("Skipping Native Nuget package build, as this needs to be run on Windows")
|
||||
return
|
||||
|
||||
# Trigger build of gtksharp with specific bash for Mingw32
|
||||
builder = GtkSharp()
|
||||
builder.MSYSTEM = self.MSYSTEM
|
||||
builder.build_net45()
|
||||
|
||||
net45_build_dir = join(self.Build_NugetDir, 'build', 'net45')
|
||||
os.makedirs(net45_build_dir, exist_ok=True)
|
||||
|
||||
print ('Copying Files')
|
||||
dll_list = self.Get_Dlls_GtkSharp_Glue()
|
||||
|
||||
for item in dll_list:
|
||||
src = glob(abspath(join(self.SrcDir, item[0])))[0]
|
||||
f_basename, f_extension = os.path.splitext(ntpath.basename(src))
|
||||
dest = join(net45_build_dir, item[1])
|
||||
shutil.copy(src, dest)
|
14
NuGet/pybuild/profiles/Glue_Win64.py
Normal file
14
NuGet/pybuild/profiles/Glue_Win64.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from pybuild.ProfileBase import ProfileBase
|
||||
from pybuild.Helper import Helper
|
||||
from pybuild.profiles.Glue_Win32 import Glue_Win32
|
||||
|
||||
class Glue_Win64(Glue_Win32):
|
||||
|
||||
def __init__(self):
|
||||
"""Class Init"""
|
||||
super().__init__()
|
||||
self._NuGet_PackageName = 'GtkSharp.Win64.Glue'
|
||||
self._Version = Helper.get_gtksharp_version(self.SrcDir)
|
||||
self.MSYSTEM = 'MINGW64'
|
73
NuGet/pybuild/profiles/GtkSharp.py
Normal file
73
NuGet/pybuild/profiles/GtkSharp.py
Normal file
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/python3
|
||||
import os, shutil
|
||||
from pybuild.ProfileBase import ProfileBase
|
||||
from os.path import abspath, join
|
||||
from pybuild.Helper import Helper
|
||||
|
||||
# TODO Add .Net Core generation
|
||||
|
||||
class GtkSharp(ProfileBase):
|
||||
|
||||
def __init__(self):
|
||||
"""Class Init"""
|
||||
super().__init__()
|
||||
self._NuGet_PackageName = 'GtkSharp'
|
||||
self._Version = Helper.get_gtksharp_version(self.SrcDir)
|
||||
self.MSYSTEM = 'MINGW64'
|
||||
|
||||
@property
|
||||
def Build_ScriptDir(self):
|
||||
return abspath(join(self._BuildDir, 'scripts'))
|
||||
|
||||
def build_net45(self):
|
||||
"""Build the gtksharp binaries for .Net 4.5"""
|
||||
os.makedirs(self.Build_ScriptDir, exist_ok=True)
|
||||
buildfile = join(self.Build_ScriptDir, 'net45_build.sh')
|
||||
buildbatch = join(self.Build_ScriptDir, 'net45_build.bat')
|
||||
|
||||
# run script via MSYS for windows, or shell for linux
|
||||
if os.name == 'nt':
|
||||
print("Building .Net GtkSharp using MSYS2")
|
||||
with open(buildfile, 'w') as f:
|
||||
f.write('PATH=$PATH:/c/Program\ Files\ \(x86\)/Microsoft\ SDKs/Windows/v10.0A/bin/NETFX\ 4.6\ Tools/\n')
|
||||
f.write('PATH=$PATH:/c/Windows/Microsoft.NET/Framework/v4.0.30319/\n')
|
||||
f.write('cd ' + Helper.winpath_to_msyspath(self.SrcDir + '\n'))
|
||||
f.write('./autogen.sh --prefix=/tmp/install\n')
|
||||
f.write('make clean\n')
|
||||
f.write('make\n')
|
||||
|
||||
bashexe = join(self.MsysPath, 'usr\\bin\\bash.exe')
|
||||
|
||||
with open(buildbatch, 'w') as f:
|
||||
f.write('set MSYSTEM=' + self.MSYSTEM + '\n')
|
||||
f.write(bashexe + ' --login ' + buildfile)
|
||||
|
||||
cmds = ['C:\Windows\System32\cmd.exe', '/C', buildbatch]
|
||||
cmd = Helper.run_cmd(cmds, self.SrcDir)
|
||||
|
||||
else:
|
||||
print("Building using Linux shell")
|
||||
with open(buildfile, 'w') as f:
|
||||
f.write('cd ' + self.SrcDir + '\n')
|
||||
f.write('./autogen.sh --prefix=/tmp/install\n')
|
||||
f.write('make clean\n')
|
||||
f.write('make\n')
|
||||
cmds = [self.LinuxBashPath, buildfile]
|
||||
cmd = Helper.run_cmd(cmds, self.SrcDir)
|
||||
|
||||
|
||||
def copy_net45(self):
|
||||
"""Copy the .Net 4.5 dll's to the build dir"""
|
||||
|
||||
net45_build_dir = join(self.Build_NugetDir, 'build', 'net45')
|
||||
net45_lib_dir = join(self.Build_NugetDir, 'lib', 'net45')
|
||||
|
||||
os.makedirs(net45_build_dir, exist_ok=True)
|
||||
os.makedirs(net45_lib_dir, exist_ok=True)
|
||||
shutil.copy('./misc/GtkSharp.targets', net45_build_dir)
|
||||
|
||||
dll_list = ['atk', 'cairo', 'gdk', 'gio', 'glib', 'gtk', 'pango']
|
||||
for item in dll_list:
|
||||
shutil.copy(join(self.SrcDir, item, item + "-sharp.dll"), net45_lib_dir)
|
||||
if item != 'cairo':
|
||||
shutil.copy(join(self.SrcDir, item, item + '-sharp.dll.config'), net45_build_dir)
|
102
NuGet/pybuild/profiles/Gtk_Win32.py
Normal file
102
NuGet/pybuild/profiles/Gtk_Win32.py
Normal file
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/python3
|
||||
"""Build of GTK3 into a NuGet package - Windows 32bit"""
|
||||
|
||||
import os, shutil, ntpath
|
||||
from pybuild.ProfileBase import ProfileBase
|
||||
from os.path import abspath, join
|
||||
from glob import iglob
|
||||
from pybuild.Helper import Helper
|
||||
|
||||
class Gtk_Win32(ProfileBase):
|
||||
|
||||
def __init__(self):
|
||||
"""Class Init"""
|
||||
super().__init__()
|
||||
self._NuGet_PackageName = 'GtkSharp.Win32'
|
||||
self._MingwBinPath = join(self.MsysPath + '\\mingw32\\bin')
|
||||
self.arch = 'Win32'
|
||||
self._Version = Helper.get_gtk_version_msys(self.MsysPath)
|
||||
|
||||
@property
|
||||
def MingwBinPath(self):
|
||||
return abspath(self._MingwBinPath)
|
||||
|
||||
|
||||
def Get_Dlls_Native_GTK(self):
|
||||
ret = []
|
||||
|
||||
# Gtk
|
||||
ret.append('libgtk-3-0.dll')
|
||||
ret.append('libgdk-3-0.dll')
|
||||
|
||||
# atk
|
||||
ret.append('libatk-1.0-0.dll')
|
||||
|
||||
# cairo
|
||||
ret.append('libcairo-2.dll')
|
||||
ret.append('libcairo-gobject-2.dll')
|
||||
|
||||
# gdk-pixbuf
|
||||
ret.append('libgdk_pixbuf-2.0-0.dll')
|
||||
|
||||
# glib2
|
||||
ret.append('libgio-2.0-0.dll')
|
||||
ret.append('libglib-2.0-0.dll')
|
||||
ret.append('libgmodule-2.0-0.dll')
|
||||
ret.append('libgobject-2.0-0.dll')
|
||||
|
||||
# pango
|
||||
ret.append('libpango-1.0-0.dll')
|
||||
ret.append('libpangocairo-1.0-0.dll')
|
||||
ret.append('libpangoft2-1.0-0.dll')
|
||||
ret.append('libpangowin32-1.0-0.dll')
|
||||
return ret
|
||||
|
||||
def Get_Dlls_Native_GTK_Deps(self):
|
||||
ret = []
|
||||
# Determined by using PE Explorer
|
||||
ret.append('libgcc_*.dll')
|
||||
ret.append('libepoxy-0.dll')
|
||||
ret.append('libintl-8.dll')
|
||||
ret.append('libwinpthread-1.dll')
|
||||
ret.append('libiconv-2.dll')
|
||||
ret.append('libfontconfig-1.dll')
|
||||
ret.append('libexpat-1.dll')
|
||||
ret.append('libfreetype-6.dll')
|
||||
ret.append('libpixman-1-0.dll')
|
||||
ret.append('libpng16-16.dll')
|
||||
ret.append('zlib1.dll')
|
||||
ret.append('libpcre-1.dll')
|
||||
ret.append('libffi-6.dll')
|
||||
ret.append('libharfbuzz-0.dll')
|
||||
ret.append('libgraphite2.dll')
|
||||
ret.append('libstdc++-6.dll')
|
||||
ret.append('libbz2-1.dll')
|
||||
return ret
|
||||
|
||||
|
||||
def build(self):
|
||||
"""Package up a nuget file based on the default build"""
|
||||
|
||||
if os.name != 'nt':
|
||||
print("Skipping Native Nuget package build, as this needs to be run on Windows")
|
||||
return
|
||||
|
||||
net45_build_dir = join(self.Build_NugetDir, 'build', 'net45')
|
||||
os.makedirs(net45_build_dir, exist_ok=True)
|
||||
|
||||
print ('Copying Files')
|
||||
shutil.copy('./misc/GtkSharp.Native.targets', join(net45_build_dir, 'GtkSharp.' + self.arch + '.targets'))
|
||||
|
||||
# Copy dlls
|
||||
dll_list = []
|
||||
dll_list += self.Get_Dlls_Native_GTK()
|
||||
dll_list += self.Get_Dlls_Native_GTK_Deps()
|
||||
|
||||
for item in dll_list:
|
||||
src = join(self.MingwBinPath, item)
|
||||
|
||||
srclist = iglob(src)
|
||||
for fname in srclist:
|
||||
f_basename, f_extension = os.path.splitext(ntpath.basename(fname))
|
||||
shutil.copy(fname, join(net45_build_dir, f_basename + '.dl_'))
|
18
NuGet/pybuild/profiles/Gtk_Win64.py
Normal file
18
NuGet/pybuild/profiles/Gtk_Win64.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/python3
|
||||
"""Build of GTK3 into a NuGet package - Windows 64bit"""
|
||||
|
||||
import os, shutil
|
||||
from pybuild.ProfileBase import ProfileBase
|
||||
from os.path import abspath, join
|
||||
from pybuild.Helper import Helper
|
||||
from pybuild.profiles.Gtk_Win32 import Gtk_Win32
|
||||
|
||||
class Gtk_Win64(Gtk_Win32):
|
||||
|
||||
def __init__(self):
|
||||
"""Class Init"""
|
||||
super().__init__()
|
||||
self._NuGet_PackageName = 'GtkSharp.Win64'
|
||||
self._MingwBinPath = join(self.MsysPath + '\\mingw64\\bin')
|
||||
self.arch = 'Win64'
|
||||
self._Version = Helper.get_gtk_version_msys(self.MsysPath)
|
0
NuGet/pybuild/profiles/__init__.py
Normal file
0
NuGet/pybuild/profiles/__init__.py
Normal file
|
@ -38,17 +38,29 @@
|
|||
<Compile Include="..\..\build.py">
|
||||
<Link>build.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\GtkSharp_Builder.py">
|
||||
<Link>pybuild\GtkSharp_Builder.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\Gtk_Builder.py">
|
||||
<Link>pybuild\Gtk_Builder.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\Helper.py">
|
||||
<Link>pybuild\Helper.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\Settings.py">
|
||||
<Link>pybuild\Settings.py</Link>
|
||||
<Compile Include="..\..\pybuild\ProfileBase.py">
|
||||
<Link>pybuild\ProfileBase.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\profiles\Glue_Win32.py">
|
||||
<Link>pybuild\profiles\Glue_Win32.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\profiles\Glue_Win64.py">
|
||||
<Link>pybuild\profiles\Glue_Win64.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\profiles\GtkSharp.py">
|
||||
<Link>pybuild\profiles\GtkSharp.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\profiles\Gtk_Win32.py">
|
||||
<Link>pybuild\profiles\Gtk_Win32.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\profiles\Gtk_Win64.py">
|
||||
<Link>pybuild\profiles\Gtk_Win64.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\profiles\__init__.py">
|
||||
<Link>pybuild\profiles\__init__.py</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\..\pybuild\__init__.py">
|
||||
<Link>pybuild\__init__.py</Link>
|
||||
|
@ -56,6 +68,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="pybuild\" />
|
||||
<Folder Include="pybuild\profiles\" />
|
||||
</ItemGroup>
|
||||
<Import Condition="Exists($(PtvsTargetsFile))" Project="$(PtvsTargetsFile)" />
|
||||
<Import Condition="!Exists($(PtvsTargetsFile))" Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
|
||||
|
|
Loading…
Reference in a new issue