[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : alex
Repository : xara
Revision : 1191
Date : Thu May 25 20:22:35 BST 2006
Changed paths:
A /Trunk/XaraLX/Scripts/build-resources.pl
M /Trunk/XaraLX/wxOil
M /Trunk/XaraLX/wxOil/Makefile.am
A /Trunk/XaraLX/wxOil/resources.cpp
New resource build system
Diff:
Index: Trunk/XaraLX/Scripts/build-resources.pl
===================================================================
--- Trunk/XaraLX/Scripts/build-resources.pl (revision 0)
+++ Trunk/XaraLX/Scripts/build-resources.pl (revision 1191)
@@ -0,0 +1,271 @@
+#!/usr/bin/perl
+# Scripts/build-resources.pl
+# Build resources.cpp if necessary
+# Call with a -f argument to force build of resources even if the system doesn't think it necessary
+
+use strict;
+
+sub usage
+{
+ print STDERR <<EOF;
+
+ buildresources.pl - build camelot resources
+
+ Usage:
+
+ buildresources.pl [options]
+
+ Options:
+ -t TOPDIR - Build source directory (for out of tree builds)
+ -o OUTPUTDIR - Build output directory (defaults to "wxOil")
+ -f - Force rebuilding of resources
+ -x - setting of XARALANGUAGE
+ -n / --version x.y - set version to x.y
+ --verbose - be very loud about it
+ --user - setting of USERNAME
+ --help - display this message
+
+EOF
+
+ my $error = shift @_;
+
+ if ($error)
+ {
+ die ($error);
+ }
+ else
+ {
+ exit (0);
+ }
+
+}
+
+use strict;
+use Getopt::Long;
+use Digest::MD5;
+use FileHandle;
+
+my $context=new Digest::MD5;
+
+my $help =0;
+my $verbose = 0;
+my $force=0;
+my $topdir="";
+
+my %tabtable;
+my %tabtableplace;
+my %tabtabledup;
+
+my $checksum="md5sum";
+my $xaralanguage="EN";
+my $xgettext="xgettext";
+my $wxrc="wxrc";
+my $zip="zip";
+my $outputdir="wxOil";
+my $topdir=".";
+my $version="";
+my $user="unknown";
+
+GetOptions( "topdir|t=s" => \$topdir,
+ "ouputdir|o=s" => \$outputdir,
+ "force!" => \$force,
+ "verbose|v+" => \$verbose,
+ "version|n=s" => \$version,
+ "user|u=s" => \$user,
+ "xaralanguage|x=s" => \$xaralanguage,
+ "help!" => \$help ) || usage ("Bad option");
+
+# check the output directory exists
+mkdir ("$outputdir");
+mkdir ("$outputdir/xrc");
+mkdir ("$outputdir/xrc/$xaralanguage");
+
+print STDERR "Testing for new resources and svn version
";
+
+# Firstly, let's find the svn version if one was specified (else we leave it)
+if ($version ne "")
+{
+ my $svnv;
+ $svnv=`svnversion $topdir`;
+ my $bdate;
+ $bdate= `date +"%d-%b-%y %H:%M"`;
+ chomp($bdate);
+ chomp($svnv);
+ my @svnversion;
+ my $camversionmajor;
+ my $camversionminor;
+ ($camversionmajor, $camversionminor)=split('.',$version);
+ push @svnversion, 'const TCHAR g_pszSvnVersion[] = wxT("'.$svnv.'");';
+ push @svnversion, 'const TCHAR g_pszAppVersion[] = wxT("'.$version.'");';
+ push @svnversion, "#define CAMELOT_VERSION_MAJOR $camversionmajor";
+ push @svnversion, "#define CAMELOT_VERSION_MINOR $camversionminor";
+ push @svnversion, "#define CAMELOT_VERSION $version";
+ push @svnversion, "#define CAMELOT_VERSION_STRING wxT(\"$version ($user)\")";
+ push @svnversion, "#define CAMELOT_BUILD_DATE _T(\"$bdate\")".
+
+ my $writeversion;
+ $writeversion=1;
+
+ my $i=0;
+ if (open(VERSION,"$outputdir/svnversion.h"))
+ {
+ $writeversion=$force;
+ while(<VERSION>)
+ {
+ chomp;
+ my $l;
+ $l=$svnversion[$i++];
+ # ignore differences in date, or every make would produce a new link!
+ if (!((/CAMELOT_BUILD_DATE/) && ($l=~/CAMELOT_BUILD_DATE/)) && ($l ne $_))
+ {
+ $writeversion=1;
+ last;
+ }
+ }
+ }
+
+ # OK it's changed
+ if ($writeversion)
+ {
+ print STDERR "Writing svnversion.h
";
+ open (VERSION, ">$outputdir/svnversion.h") || die "Can't write svnversion.h: $!";
+ foreach $i (@svnversion)
+ {
+ print VERSION "$i
";
+ }
+ close(VERSION);
+ }
+}
+
+
+# Resource system
+# We don't bother with timestamps. Just as quick to mdsum these things like subversion does
+
+opendir(DIR, "$topdir/wxOil/xrc") || die "Can't open $topdir/wxOil/xrc: $!";
+my @resfiles=sort grep { /^[^\#].*\.(png|ico|cur|bmp|res|xar)$/ } readdir(DIR);
+closedir(DIR);
+
+opendir(DIR, "$topdir/wxOil/xrc/$xaralanguage") || die "Can't open $topdir/wxOil/xrc/$xaralanguage: $!";
+my @xrcfiles=sort grep { /^[^\#].*\.xrc$/ } readdir(DIR);
+closedir(DIR);
+
+my $f;
+foreach $f (@xrcfiles)
+{
+ $f = "$topdir/wxOil/xrc/$xaralanguage/".$f;
+}
+foreach $f (@resfiles)
+{
+ $f = "$topdir/wxOil/xrc//".$f;
+}
+
+my @dialogfiles = sort grep { $_ !~ /-strings\.xrc$/ } @xrcfiles;
+my @stringfiles = sort grep { $_ =~ /-strings\.xrc$/ } @xrcfiles;
+
+my @all=@resfiles;
+push @all,@xrcfiles;
+my $i;
+foreach $i (@all)
+{
+ print STDERR "Checksumming $i
" if ($verbose);
+ my $fh=new FileHandle "<$i";
+ $context->add($i); # add the name of the file too
+ $context->addfile($fh);
+}
+
+my $checksum=$context->hexdigest();
+
+print STDERR "New checksum = $checksum
" if ($verbose);
+
+my $buildresources=$force;
+
+if (!$buildresources)
+{
+ if (open(CHECK,"$outputdir/xrc/xrc.check"))
+ {
+ $buildresources=1;
+ while(<CHECK>)
+ {
+ chomp;
+ if ($_ eq $checksum)
+ {
+ $buildresources=0;
+ last;
+ }
+ }
+ }
+ else
+ {
+ $buildresources=1;
+ }
+}
+
+exit(0) unless $buildresources;
+
+print STDERR "Rebuilding resources - new checksum $checksum
";
+unlink ("$outputdir/xrc/$xaralanguage/xrc.check");
+unlink ("$outputdir/xrc/xrc.check");
+
+my $ret;
+$ret=system("$topdir/Scripts/combinexrc.pl","-b","missing.png","-o","$outputdir/xrc/dialogs.xrc",@dialogfiles);
+die "Failed to combine dialogs ($ret): $!" if ($ret);
+$ret=system("$topdir/Scripts/combinexrc.pl","-b","missing.png","-t","-s","-o","$outputdir/xrc/strings.lst",@xrcfiles);
+die "Failed to combine strings ($ret): $!" if ($ret);
+
+my @strings;
+open(STRINGS,"$outputdir/xrc/strings.lst") || die "Could not open strings.lst: $!";
+while (<STRINGS>)
+{
+ chomp;
+ s/^\S+ //;
+ my $s;
+ $s="_(\"$_\");";
+ push @strings, $s;
+ print STDERR "String: $s
" if ($verbose>2);
+}
+close(STRINGS);
+
+open(DIALOGS,"$wxrc -g $outputdir/xrc/dialogs.xrc|") || die "Could not read dialogs for translation: $!";
+while (<DIALOGS>)
+{
+ chomp;
+ print STDERR "Dialog: $_
" if ($verbose>2);
+ push @strings,$_;
+}
+
+my @uniqstrings;
+my $last="";
+foreach $i (sort @strings)
+{
+ next if ($i eq $last);
+ $last = $i;
+ my $j;
+ $j=$i;
+ next if ($j =~ /^_\(\"\"\)\;\s+$/);
+ $j=~s/\r\n/\n/g;
+# $j=~s/&/\&/g;
+ push @uniqstrings, $j;
+}
+
+open (XGETTEXT, "|".$xgettext.' --force-po -k_ -C -i - --no-location --copyright-holder "Xara Group Ltd" --msgid-bugs-address=bugs@xxxxxxxx -d xaralx -o '.$outputdir."/xrc/xaralx.po") || die "Can't run $xgettext: $!";
+foreach $i (@uniqstrings)
+{
+ print STDERR "Translate: $i
" if ($verbose>2);
+ print XGETTEXT "$i
";
+}
+close (XGETTEXT);
+
+# Write the file to the wrong directory (deliberate)
+open(CHECK,">$outputdir/xrc/$xaralanguage/xrc.check") || die "Could not write xrc.check: $!";
+print CHECK "$checksum
";
+close CHECK;
+
+$ret = system("$zip","-9","-j","-q","$outputdir/xrc/resources.xrs","$outputdir/xrc/$xaralanguage/xrc.check","$outputdir/xrc/dialogs.xrc","$outputdir/xrc/strings.xrc","$outputdir/xrc/strings.lst",@resfiles);
+die "Could not make resources.xrs: $!" if ($ret);
+$ret = system("$topdir/Scripts/bin2cpp.pl -f CamResource::GetBinaryFileInfo $outputdir/xrc/resources.xrs $outputdir/resources.h");
+die "Could not make resources.cpp: $!" if ($ret);
+
+# OK we've finished so move the checksum into the right place
+rename ("$outputdir/xrc/$xaralanguage/xrc.check", "$outputdir/xrc/xrc.check");
+
+exit(0);
Property changes on: Trunk/XaraLX/Scripts/build-resources.pl
___________________________________________________________________
Name: svn:executable
+ *
Index: Trunk/XaraLX/wxOil/Makefile.am
===================================================================
--- Trunk/XaraLX/wxOil/Makefile.am (revision 1190)
+++ Trunk/XaraLX/wxOil/Makefile.am (revision 1191)
@@ -3,24 +3,12 @@
#########################################################################
# this is the program that gets installed. it's name is used for all
# of the other Makefile.am variables
-BUILT_SOURCES = svnversion.h
+BUILT_SOURCES = svnversion.h resources.h
# Note we don't clean xrc.d and xrc.stamp here to avoid a loop
CLEANFILES = svnversion.h
-MOSTLYCLEANFILES = resources.cpp xrc/dialogs.xrc xrc/strings.xrc xrc/strings.lst xrc/xaralx.po xrc/resources.xrs resources.cpp xrc/xrc.check
+MOSTLYCLEANFILES = resources.h xrc/dialogs.xrc xrc/strings.xrc xrc/strings.lst xrc/xaralx.po xrc/resources.xrs resources.cpp xrc/xrc.check
noinst_LIBRARIES = libwxOil.a
-# This is a hack. It should come from configure. It is the ISO language code
-XARALANGUAGE = @XARALANGUAGE@
-
-version svnversion.h:
- @echo "const TCHAR g_pszSvnVersion[] = wxT(\"`svnversion $(TOPDIR)`\");" > svnversion.h
- @echo "const TCHAR g_pszAppVersion[] = wxT(\"$(VERSION)\");" >> svnversion.h
- @echo "#define CAMELOT_VERSION_MAJOR `echo $(VERSION) | $(AWK) 'BEGIN { FS = "."; } { printf $$1;}'`" >> svnversion.h
- @echo "#define CAMELOT_VERSION_MINOR `echo $(VERSION) | $(AWK) 'BEGIN { FS = "."; } { printf $$2;}'`" >> svnversion.h
- @echo "#define CAMELOT_VERSION $(VERSION)" >> svnversion.h
- @echo "#define CAMELOT_VERSION_STRING wxT(\"$(VERSION) ($(USER))\")" >> svnversion.h
- @echo "#define CAMELOT_BUILD_DATE _T(\"`date +"%d-%b-%y %H:%M"`\")" >> svnversion.h
-
# the application source, library search path, and link libraries
libwxOil_a_SOURCES = \
varstr.cpp \
@@ -47,68 +35,10 @@
binreloc.c exceptio.cpp colpick.cpp \
resources.cpp
-# Keep resources.cpp (the autogenerated resource file) on a separate line.
+# Keep resources.cpp on a separate line as it is odd
AM_CXXFLAGS = $(XARAFLAGS)
-# RESOURCES MAKE SYSTEM
-#
-# Please do not fiddle unless you understand this. The idea is that you can drop in or out resources, and it will automagically
-# remake dependencies etc.
+XARALANGUAGE = @XARALANGUAGE@
-# This makes the dependencies every time the makefile is run (a simple case of running find)
-# Note we make sure if the deps have not changed that we don't rewrite the file, else we get into an
-# infinite loop as "include" notices and rereads the file. Note this is a := assignment, so runs
-# early on
-xrcmake := ${shell echo Testing for new resources... 1>&2 ; \
- if( test ! -d xrc ) ; then mkdir xrc; fi; \
- ( find $(TOPDIR)/wxOil/xrc/$(XARALANGUAGE) -maxdepth 1 -name '*.xrc' ; find $(TOPDIR)/wxOil/xrc -maxdepth 1 -name '*.png' -or -name '*.ico' -or -name '*.cur' -or -name '*.bmp' -or -name '*.res' -or -name '*.xar' ) | \
- perl -e 'while(<>) {chomp; s/
//; push @F, $$_}; printf "xrc/dialogs.xrc xrc/strings.xrc xrc/strings.lst xrc/xaralx.po: xrc/xrc.stamp %s
",join (" ",sort @F);' > xrc/xrc.d.$$$$ ; \
- if ( ! ( cmp -s xrc/xrc.d.$$$$ xrc/xrc.d) ) ; then touch xrc/xrc.stamp ; mv xrc/xrc.d.$$$$ xrc/xrc.d ; echo Found new resources 1>&2 ; \
- else rm -f xrc/xrc.d.$$$$; fi ; \
- if ! [ -e xrc/xrc.stamp ] ; then touch xrc/xrc.stamp ; fi }
-
-# This gives us a target for the dialogs
-@XRCINCLUDE@ xrc/xrc.d
-
-# Define shell commands to get the names of the stringtables, dialogs and bitmaps. Note these are '=' assignments, so
-# evaluated later
-XRCDIALOGS = ${shell perl -ane 'foreach $$f (@F) { push @G,$$f if $$f=~/${XARALANGUAGE}\/.+\.xrc$$/ && $$f!~/-strings\.xrc$$/};print join(" ",@G)."
";' < xrc/xrc.d }
-# For now, include dialogs in strings table, which ensures reverse lookups are done
-#XRCSTRINGS = ${shell perl -ane 'foreach $$f (@F) { push @G,$$f if $$f=~/${XARALANGUAGE}\/.+\.xrc$$/ && $$f=~/-strings\.xrc$$/};print join(" ",@G)."
";' < xrc/xrc.d }
-XRCSTRINGS = ${shell perl -ane 'foreach $$f (@F) { push @G,$$f if $$f=~/${XARALANGUAGE}\/.+\.xrc$$/ };print join(" ",@G)."
";' < xrc/xrc.d }
-XRCBITMAPS = ${shell perl -ane 'foreach $$f (@F) { push @G,$$f if $$f=~/\.(png|ico|cur|bmp|res|xar)$$/};print join(" ",@G)."
";' < xrc/xrc.d }
-
-# A checksum routine - it doesn't much matter what it is
-CHECKSUM = md5sum
-ZIP = zip
-
-.PHONY: resources
-resources: resources.cpp
-
-# We build these two as a pair to match xrc.d (probably unnecessary but makes things clearer, and this bit is
-# very quick compared to wxrc and the compile time for resources.cpp so adds hardly anything)
-# the cp is to trick gettextutoconf into using our template file
-xrc/dialogs.xrc xrc/strings.xrc xrc/strings.lst xrc/xaralx.po: xrc/xrc.stamp
- @echo "Combining dialog & string resources" && \
- touch xrc/strings.xrc && \
- $(TOPDIR)/Scripts/combinexrc.pl -b missing.png -o xrc/dialogs.xrc $(XRCDIALOGS) && \
- $(TOPDIR)/Scripts/combinexrc.pl -b missing.png -t -s -o xrc/strings.lst $(XRCSTRINGS) && \
- ( perl -ne 'chomp;s/^\S+ //;print "_(\"$$_\");
";' < xrc/strings.lst && @WXRC@ -g xrc/dialogs.xrc) | sort -u | \
- perl -ne 'print unless /^_\(\"\"\)\;\s+$$/;' | sed 's/&/\&/g' | \
- ${XGETTEXT} --force-po -k_ -C -i - --no-location --copyright-holder "Xara Group Ltd" --msgid-bugs-address=bugs@xxxxxxxx -d xaralx -o xrc/xaralx.po
-
-# Don't produce strings.xrc any more
-# $(TOPDIR)/Scripts/combinexrc.pl -b missing.png -s -o xrc/strings.xrc $(XRCSTRINGS);
-
-# No need for resources.cpp explicitly to depend on the bitmaps, as dialogs.xrc and strings.xrc depend on these
-# (though they don't need to) but they will get rebuilt if the bitmaps change. This will cause xrc/resources.to be
-# rebuilt. This avoids complicating xrc.d
-
-xrc/xrc.check xrc/resources.xrs: xrc/xrc.d xrc/dialogs.xrc xrc/strings.xrc xrc/strings.lst
- @echo "Generating resource checksum" && \
- ( cat xrc/dialogs.xrc xrc/strings.xrc xrc/strings.lst $(XRCBITMAPS) | $(CHECKSUM) | awk '{print $$1}' > xrc/xrc.check ) && \
- $(ZIP) -9 -j -q xrc/resources.xrs xrc/xrc.check xrc/dialogs.xrc xrc/strings.xrc xrc/strings.lst $(XRCBITMAPS)
-
-resources.cpp: xrc/resources.xrs xrc/xaralx.po
- $(TOPDIR)/Scripts/bin2cpp.pl -f CamResource::GetBinaryFileInfo xrc/resources.xrs resources.cpp
+RESOURCEDUMMY := ${shell $(TOPDIR)/Scripts/build-resources.pl -t $(TOPDIR) -o . --version $(VERSION) -x $(XARALANGUAGE) -u $(USER) }
Index: Trunk/XaraLX/wxOil/resources.cpp
===================================================================
--- Trunk/XaraLX/wxOil/resources.cpp (revision 0)
+++ Trunk/XaraLX/wxOil/resources.cpp (revision 1191)
@@ -0,0 +1,102 @@
+// $Id: camelot.cpp 1184 2006-05-23 19:27:20Z alex $
+/* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
+================================XARAHEADERSTART===========================
+
+ Xara LX, a vector drawing and manipulation program.
+ Copyright (C) 1993-2006 Xara Group Ltd.
+ Copyright on certain contributions may be held in joint with their
+ respective authors. See AUTHORS file for details.
+
+LICENSE TO USE AND MODIFY SOFTWARE
+----------------------------------
+
+This file is part of Xara LX.
+
+Xara LX is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 2 as published
+by the Free Software Foundation.
+
+Xara LX and its component source files are distributed in the hope
+that it will be useful, but WITHOUT ANY WARRANTY; without even the
+implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with Xara LX (see the file GPL in the root directory of the
+distribution); if not, write to the Free Software Foundation, Inc., 51
+Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+ADDITIONAL RIGHTS
+-----------------
+
+Conditional upon your continuing compliance with the GNU General Public
+License described above, Xara Group Ltd grants to you certain additional
+rights.
+
+The additional rights are to use, modify, and distribute the software
+together with the wxWidgets library, the wxXtra library, and the "CDraw"
+library and any other such library that any version of Xara LX relased
+by Xara Group Ltd requires in order to compile and execute, including
+the static linking of that library to XaraLX. In the case of the
+"CDraw" library, you may satisfy obligation under the GNU General Public
+License to provide source code by providing a binary copy of the library
+concerned and a copy of the license accompanying it.
+
+Nothing in this section restricts any of the rights you have under
+the GNU General Public License.
+
+
+SCOPE OF LICENSE
+----------------
+
+This license applies to this program (XaraLX) and its constituent source
+files only, and does not necessarily apply to other Xara products which may
+in part share the same code base, and are subject to their own licensing
+terms.
+
+This license does not apply to files in the wxXtra directory, which
+are built into a separate library, and are subject to the wxWindows
+license contained within that directory in the file "WXXTRA-LICENSE".
+
+This license does not apply to the binary libraries (if any) within
+the "libs" directory, which are subject to a separate license contained
+within that directory in the file "LIBS-LICENSE".
+
+
+ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
+----------------------------------------------
+
+Subject to the terms of the GNU Public License (see above), you are
+free to do whatever you like with your modifications. However, you may
+(at your option) wish contribute them to Xara's source tree. You can
+find details of how to do this at:
+ http://www.xaraxtreme.org/developers/
+
+Prior to contributing your modifications, you will need to complete our
+contributor agreement. This can be found at:
+ http://www.xaraxtreme.org/developers/contribute/
+
+Please note that Xara will not accept modifications which modify any of
+the text between the start and end of this header (marked
+XARAHEADERSTART and XARAHEADEREND).
+
+
+MARKS
+-----
+
+Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
+designs are registered or unregistered trademarks, design-marks, and/or
+service marks of Xara Group Ltd. All rights in these marks are reserved.
+
+
+ Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
+ http://www.xara.com/
+
+=================================XARAHEADEREND============================
+*/
+
+// This file merely includes the auto-generated resources.h
+// NO OTHER FILE SHOULD INCLUDE THIS
+
+#include "resources.h"
Property changes on: Trunk/XaraLX/wxOil
___________________________________________________________________
Name: svn:ignore
- Makefile
resources.cpp
svnversion.h
Makefile.in
.deps
libwxOil.a
+ Makefile
resources.h
svnversion.h
Makefile.in
.deps
libwxOil.a
Xara