Clone in a terminal:
Commit a608671
Johan Mattsson - 2012-08-26T09:11:55+00:00
a6086713db05f484018372425615fc3cdb065120johan.mattsson.m@gmail.com

build installer with waf

Changed files (6)

Diff

diff --git a/.gitignore b/.gitignoreindex 378eac2..348f130 100644--- a/.gitignore+++ b/.gitignore@@ -1 +1,2 @@ build+src/Config.valadiff --git a/README b/READMEindex 0ba3960..6daac0c 100644--- a/README+++ b/README@@ -20,3 +20,19 @@ Configure, build and install with waf: su ./waf install ++------------------------+Bulding windows binaries+------------------------++Windows binaries are cross compiled with mingw on a Ubuntu system. Install+all dependencies from Gregs repository as described here:++http://greg.thehellings.com/2012/02/a-better-ubuntu-mingw-experience/++You need wine and nsis windows installer as well++Compile and build the installer with:+./waf configure --win32 --installer+./waf build --win32 --installer+diff --git a/src/Supplement.vala b/src/Supplement.valaindex ae01e52..5b85790 100644--- a/src/Supplement.vala+++ b/src/Supplement.vala@@ -20,9 +20,6 @@ using Gtk; namespace Supplement {
 
 class Supplement {
-
-	public static const string VERSION = "0.1.1";
-	
 	public static Argument args;
 	public static bool experimental;
 
diff --git a/src/wscript b/src/wscriptindex d363f0b..00a40bf 100644--- a/src/wscript+++ b/src/wscript@@ -6,6 +6,7 @@ SUPPLEMENT_MAIN = [ 	'ExportTool.vala',
 	'FontDisplay.vala',
 	'CharDatabase.vala',
+	'Config.vala',
 	'Context.vala',
 	'CutBackgroundTool.vala',
 	'CutTool.vala',
diff --git a/win32/wscript b/win32/wscriptnew file mode 100644index 0000000..91fb0e4--- /dev/null+++ b/win32/wscript@@ -0,0 +1,264 @@+import os+import shutil++from waflib.TaskGen import feature, before_method++WIN32_LIBS = [+	'glib-2.0',+	'libxml-2.0',+	'gio-2.0',+	'libsoup-2.4',+	'gtk+-2.0',+	'webkit-1.0'+]++WIN32_DLLS = [ +	"libcairo-2.dll",+	"libgdk-win32-2.0-0.dll",+	"libgdk_pixbuf-2.0-0.dll",+	"libgio-2.0-0.dll",+	"libglib-2.0-0.dll",+	"libgobject-2.0-0.dll",+	"libgthread-2.0-0.dll",+	"libgtk-win32-2.0-0.dll",+	"libxml2-2.dll",+	"libfontconfig-1.dll",+	"libfreetype-6.dll",+	"libpixman-1-0.dll",+	"libpng15-15.dll",+	"zlib1.dll",+	"libpixman-1-0.dll",+	"libpng15-15.dll",+	"libintl-8.dll",+	"libgmodule-2.0-0.dll",+	"libffi-5.dll",+	"libgobject-2.0-0.dll",+	"libjasper-1.dll",+	"libjpeg-8.dll",+	"libtiff-5.dll",+	"libgdk_pixbuf-2.0-0.dll",+	"libpango-1.0-0.dll",+	"libpangocairo-1.0-0.dll",+	"libgdk-win32-2.0-0.dll",+	"libgmodule-2.0-0.dll",+	"libexpat-1.dll",+	"libpangoft2-1.0-0.dll",+	"libpangowin32-1.0-0.dll",+	"libpangocairo-1.0-0.dll",+	"libgdk-win32-2.0-0.dll",+	"libpangoft2-1.0-0.dll",+	"libpangowin32-1.0-0.dll",+	"libpangocairo-1.0-0.dll",+	"libatk-1.0-0.dll",+	"libsoup-2.4-1.dll",+	"libsqlite3-0.dll",+	"libxslt-1.dll",+	"libgcc_s_sjlj-1.dll",+	"libstdc++-6.dll",+	"libjavascriptcoregtk-1.0-0.dll",+	"libenchant-1.dll",+	"libgailutil-18.dll",+	"libwebkitgtk-1.0-0.dll",+	"pthreadGC2.dll"+]++@feature('have_windows_runtime')+@before_method('process_source')+def have_windows_runtime(self):+	for pkg in WIN32_LIBS:+		self.bld(rule='i686-w64-mingw32-pkg-config --cflags --libs '+ pkg, always=True, name=pkg)+	self.source = []++def configure(conf):+	print("")+	print("Crosscompile for windows")+	+	conf.find_program('i686-w64-mingw32-gcc', var='MINGW32GCC')+	conf.find_program('i686-w64-mingw32-pkg-config', var='MINGW32PKG-CONFIG')+	conf.check_cc(features='have_windows_runtime', msg='Checking windows runtimes')+	conf.find_program('wine', var='wine')++	if conf.options.installer :+		conf.find_program(os.getenv("HOME") + "/.wine/drive_c/Program/NSIS/makensis.exe", always=True)++def build(bld):+	+	bld.exec_command("mkdir -p build/supplement")+	+	bld(rule="""i686-w64-mingw32-gcc -c ./src/*.c \+		-s \+		-mthreads \+		$(i686-w64-mingw32-pkg-config --cflags --libs glib-2.0) \+		$(i686-w64-mingw32-pkg-config --cflags --libs libxml-2.0) \+		$(i686-w64-mingw32-pkg-config --cflags --libs gio-2.0) \+		$(i686-w64-mingw32-pkg-config --cflags --libs libsoup-2.4) \+		$(i686-w64-mingw32-pkg-config --cflags --libs gtk+-2.0) \+		$(i686-w64-mingw32-pkg-config --cflags --libs webkit-1.0) && mv *.o win32/""", source="../build/src/Supplement.c", target="./Supplement.o", name="mingw compile");++	bld(rule="""i686-w64-mingw32-gcc ./win32/*.o \+		-s \+		-Wl,-subsystem,windows \+		-mthreads \+		-L/usr/i686-w64-mingw32/sys-root/mingw/lib \+		-static -B static -lintl.dll -B static -l glib-2.0.dll -B static -l xml2.dll  \+		-B static -lgio-2.0.dll -B static -l soup-2.4.dll \+		-B static -l webkitgtk-1.0.dll  -B static -lgtk-win32-2.0.dll -B static -lgdk-win32-2.0.dll -B static -latk-1.0.dll -B static -lgio-2.0.dll -B static -lpangowin32-1.0.dll -B static -lpangocairo-1.0.dll -B static -lgdk_pixbuf-2.0.dll -B static -lpango-1.0.dll -B static -lcairo.dll -B static -lgobject-2.0.dll -B static -lgmodule-2.0.dll -B static -lgthread-2.0.dll -B static -lglib-2.0.dll \+		-static -o birdfont.exe""", source="../build/src/Supplement.c", target="../birdfont.exe", depends_on='mingw compile', name="mingw link")++	if bld.options.installer:+		copy_runtime_dependencies (bld)+		generate_nsi(bld)+				+		fn = "birdfont-" + bld.env.VERSION + ".exe"+		bld(rule=os.getenv("HOME") + "/.wine/drive_c/Program/NSIS/makensis.exe supplement/birdfont_installer.nsi", source='', target='supplement/' + fn, depends_on='mingw link', name="nsis installer")+		bld(rule="mv ./${SRC} ${TGT}", source='supplement/' + fn, target='./', depends_on='nsis installer')+	+def generate_nsi(bld):+	print ('generating build/supplement/birdfont_installer.nsi')++	f = open('build/supplement/birdfont_installer.nsi', 'w+')+	f.write("""; windows installation script generated by by win32/wscript++Name "Birdfont"+""")++	f.write("OutFile \"..\\win32\\supplement\\")+	f.write("birdfont-")+	f.write(bld.env.VERSION)+	f.write(".exe\"")+	+	f.write("""+InstallDir $PROGRAMFILES\Birdfont+InstallDirRegKey HKLM "Software\NSIS_Birdfont" "Install_Dir"++; Request application privileges for Windows Vista+RequestExecutionLevel admin++;--------------------------------++; Pages++Page directory+Page instfiles++UninstPage uninstConfirm+UninstPage instfiles++;--------------------------------++Section "Birdfont (required)"++  SectionIn RO+""");++	os.chdir('./build/supplement')+	write_files ('.', f)++	f.write("""+  ; Write the installation path into the registry+  WriteRegStr HKLM SOFTWARE\NSIS_Birdfont "Install_Dir" "$INSTDIR"+  +  ; Write the uninstall keys for Windows+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Birdfont" "DisplayName" "NSIS Birdfont"+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Birdfont" "UninstallString" '"$INSTDIR\uninstall.exe"'+  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Birdfont" "NoModify" 1+  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Birdfont" "NoRepair" 1+  WriteUninstaller "uninstall.exe"+  +SectionEnd++; Optional section (can be disabled by the user)+Section "Start Menu Shortcuts"+  CreateDirectory "$SMPROGRAMS\Birdfont" +SectionEnd++;--------------------------------++; Uninstaller++Section "Uninstall"+  +  ; Remove registry keys+  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Birdfont"+  DeleteRegKey HKLM SOFTWARE\NSIS_Birdfont+""")++	remove_files ('.', f)++	f.write("""+  ; Remove shortcuts, if any+  Delete "$SMPROGRAMS\Birdfont\*.*"+  +  ; Remove directories used+  RMDir "$SMPROGRAMS\Birdfont"++SectionEnd+""")+	os.chdir('../../')++def write_files (dir, f):+	filenames = os.walk(dir)++	f.write("  SetOutPath $INSTDIR\n")+	+	for path in (os.path.join(dir, f) for f in os.listdir(dir)):+		if not os.path.isdir(path):+			f.write("  File \"")+			f.write(path.replace ('./', '').replace ('/', '\\'))+			f.write("\"\n")+				+	for dirname, dirnames, filenames in os.walk(dir):+		for subdirname in dirnames:+			ndir = os.path.join(dirname, subdirname)+			wdir = ndir.replace ('./', '').replace ('/', '\\')+			+			f.write("\n")+			f.write("  SetOutPath $INSTDIR\\")+			f.write(wdir)+			f.write("\n")+			+			dirList = os.listdir(ndir)+			for fname in dirList:+				fp = os.path.join(ndir, fname) +				if not os.path.isdir(fp):+					f.write("  File ")+					f.write(wdir)+					f.write("\\")+					f.write(fname)+					f.write("\n")++def remove_files (dir, f):+	for path in (os.path.join(dir, f) for f in os.listdir(dir)):+		if os.path.isdir(path):+			remove_files (path, f)+		else:+			f.write("  Delete \"$INSTDIR\\")+			f.write(path.replace ('./', '').replace ('/', '\\'))+			f.write("\"\n")+	+	if dir == '.':+		f.write("  RMDir \"$INSTDIR\"\n")	+	else:+		f.write("  RMDir \"$INSTDIR\\")+		f.write(dir.replace ('./', '').replace ('/', '\\'))+		f.write("\"\n")+		+def copy_runtime_dependencies (bld):++	MINGW = "/usr/i686-w64-mingw32/sys-root/mingw"+	MINGW_BIN = MINGW + "/bin"++	bld(rule="cp birdfont.exe supplement/")+	bld(rule="cp ../README supplement/")+	bld(rule="cp ../COPYING supplement/")+	bld(rule="cp ../NEWS supplement/")+	+	bld(rule="cp -ra ../layout/ supplement/")+	bld(rule="cp -ra ../icons/ supplement/")++	bld(rule="cp -r " + MINGW + "/etc supplement/")++	# DLL-hell+	for dll in WIN32_DLLS:+		bld(rule="cp " + MINGW_BIN + "/" + dll + " supplement/")+		diff --git a/wscript b/wscriptindex 1fb76cd..5fa6451 100644--- a/wscript+++ b/wscript@@ -1,4 +1,4 @@-VERSION = '0.1.1'
+VERSION = '0.1.2'
 APPNAME = 'birdfont'
 
 top = '.'
@@ -7,8 +7,9 @@ out = 'build' def options(opt):
 	opt.load('compiler_c')
 	opt.load('vala')
-	opt.add_option('--win32', action='store_true', default=False, help='Crosscompile and create windows installer')
-
+	opt.add_option('--win32', action='store_true', default=False, help='Crosscompile for Windows')
+	opt.add_option('--installer', action='store_true', default=False, help='Create Windows installer')
+        
 def configure(conf):
 	conf.load('compiler_c vala')
 
@@ -21,17 +22,30 @@ def configure(conf): 	conf.env.append_unique('VALAFLAGS', ['--thread', '--pkg', 'webkit-1.0', '--enable-experimental', '--enable-experimental-non-null', '--vapidir=../../'])
 
 	if conf.options.win32 :
-		print ('Crosscompiling for windows32')
-	
+		conf.recurse('win32')
+		
 def build(bld):
 	bld.recurse('src')
 
+	bld.env.VERSION = VERSION
+	
+	write_config ()
+	
 	start_dir = bld.path.find_dir('./')
 	bld.install_files('${PREFIX}/share/birdfont/', start_dir.ant_glob('layout/*'), cwd=start_dir, relative_trick=True)
 	bld.install_files('${PREFIX}/share/birdfont/', start_dir.ant_glob('icons/*'), cwd=start_dir, relative_trick=True)
 	
-	if bld.options.win32 :
-		bld.recurse('win32')
-
 	bld.install_files('${PREFIX}/share/applications/', ['birdfont.desktop'])
 
+	if bld.options.win32:
+		bld.recurse('win32')
+		
+def write_config ():
+	f = open('./src/Config.vala', 'w+')
+	f.write("// Don't edit this file – it's generated by wscript\n")
+	f.write("namespace Supplement {\n")
+	f.write("	public static const string VERSION = \"")
+	f.write(VERSION)
+	f.write("\"");
+	f.write(";\n")
+	f.write("}");

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112