diff --git a/NuGet/build.py b/NuGet/build.py index 0fbb81679..0fb9491b4 100644 --- a/NuGet/build.py +++ b/NuGet/build.py @@ -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 where 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() diff --git a/NuGet/misc/GtkSharp.nuspec b/NuGet/misc/GtkSharp.nuspec index 3583ea169..70cc70bee 100644 --- a/NuGet/misc/GtkSharp.nuspec +++ b/NuGet/misc/GtkSharp.nuspec @@ -3,7 +3,7 @@ GBD.GtkSharp 3.22.0 - Ric Westell + Grbd grbd https://github.com/mono/gtk-sharp/blob/master/COPYING https://github.com/mono/gtk-sharp diff --git a/NuGet/pybuild/GtkSharp_Builder.py b/NuGet/pybuild/GtkSharp_Builder.py deleted file mode 100644 index 62d8f47f7..000000000 --- a/NuGet/pybuild/GtkSharp_Builder.py +++ /dev/null @@ -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') diff --git a/NuGet/pybuild/Gtk_Builder.py b/NuGet/pybuild/Gtk_Builder.py deleted file mode 100644 index a549835ba..000000000 --- a/NuGet/pybuild/Gtk_Builder.py +++ /dev/null @@ -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') - diff --git a/NuGet/pybuild/Helper.py b/NuGet/pybuild/Helper.py index 32313de64..f54e51e85 100644 --- a/NuGet/pybuild/Helper.py +++ b/NuGet/pybuild/Helper.py @@ -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))) \ No newline at end of file diff --git a/NuGet/pybuild/ProfileBase.py b/NuGet/pybuild/ProfileBase.py new file mode 100644 index 000000000..317f3c062 --- /dev/null +++ b/NuGet/pybuild/ProfileBase.py @@ -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) diff --git a/NuGet/pybuild/Settings.py b/NuGet/pybuild/Settings.py deleted file mode 100644 index 79a7d1860..000000000 --- a/NuGet/pybuild/Settings.py +++ /dev/null @@ -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 \ No newline at end of file diff --git a/NuGet/pybuild/profiles/Glue_Win32.py b/NuGet/pybuild/profiles/Glue_Win32.py new file mode 100644 index 000000000..0904563d9 --- /dev/null +++ b/NuGet/pybuild/profiles/Glue_Win32.py @@ -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) diff --git a/NuGet/pybuild/profiles/Glue_Win64.py b/NuGet/pybuild/profiles/Glue_Win64.py new file mode 100644 index 000000000..74938ac9f --- /dev/null +++ b/NuGet/pybuild/profiles/Glue_Win64.py @@ -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' diff --git a/NuGet/pybuild/profiles/GtkSharp.py b/NuGet/pybuild/profiles/GtkSharp.py new file mode 100644 index 000000000..b285658c0 --- /dev/null +++ b/NuGet/pybuild/profiles/GtkSharp.py @@ -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) diff --git a/NuGet/pybuild/profiles/Gtk_Win32.py b/NuGet/pybuild/profiles/Gtk_Win32.py new file mode 100644 index 000000000..0c4fb1fad --- /dev/null +++ b/NuGet/pybuild/profiles/Gtk_Win32.py @@ -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_')) diff --git a/NuGet/pybuild/profiles/Gtk_Win64.py b/NuGet/pybuild/profiles/Gtk_Win64.py new file mode 100644 index 000000000..998fc8252 --- /dev/null +++ b/NuGet/pybuild/profiles/Gtk_Win64.py @@ -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) diff --git a/NuGet/pybuild/profiles/__init__.py b/NuGet/pybuild/profiles/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/NuGet/vs/GtkSharp-NugetBuild/GtkSharp-NugetBuild.pyproj b/NuGet/vs/GtkSharp-NugetBuild/GtkSharp-NugetBuild.pyproj index 262f9bcbe..1e2f66dec 100644 --- a/NuGet/vs/GtkSharp-NugetBuild/GtkSharp-NugetBuild.pyproj +++ b/NuGet/vs/GtkSharp-NugetBuild/GtkSharp-NugetBuild.pyproj @@ -38,17 +38,29 @@ build.py - - pybuild\GtkSharp_Builder.py - - - pybuild\Gtk_Builder.py - pybuild\Helper.py - - pybuild\Settings.py + + pybuild\ProfileBase.py + + + pybuild\profiles\Glue_Win32.py + + + pybuild\profiles\Glue_Win64.py + + + pybuild\profiles\GtkSharp.py + + + pybuild\profiles\Gtk_Win32.py + + + pybuild\profiles\Gtk_Win64.py + + + pybuild\profiles\__init__.py pybuild\__init__.py @@ -56,6 +68,7 @@ +