Patchwork PATCH RFA: Update exgettext for Go frontend

login
register
mail settings
Submitter Ian Taylor
Date Nov. 9, 2010, 9:37 p.m.
Message ID <mcrd3qeyy8z.fsf@google.com>
Download mbox | patch
Permalink /patch/70578/
State New
Headers show

Comments

Ian Taylor - Nov. 9, 2010, 9:37 p.m.
This patch updates the gcc/po/exgettext script to support the Go
frontend.  There are two main changes.  The first is to look for *.cc
files, and have xgettext process them as C++ files.  The second is to
look in subdirectories of language frontend directories.  The second
change is needed because the Go frontend is split into two directories:
a gcc interface and the frontend proper.  Ada is also split, but Ada
puts a config-lang.in file in each directory.  Go does not.

Running this script on mainline causes some reordering within gcc.pot of
the files in the language subdirectories but causes no substantive
changes.

Bootstrapped on x86_64-unknown-linux-gnu.  OK for mainline?

Ian


2010-11-09  Ian Lance Taylor  <iant@google.com>

	* exgettext: Look for .cc files.  Look in subdirectories of
	language subdirectories.
	* EXCLUDES: Update comment.
Joseph S. Myers - Nov. 9, 2010, 11:29 p.m.
On Tue, 9 Nov 2010, Ian Lance Taylor wrote:

> 2010-11-09  Ian Lance Taylor  <iant@google.com>
> 
> 	* exgettext: Look for .cc files.  Look in subdirectories of
> 	language subdirectories.
> 	* EXCLUDES: Update comment.

OK.

Patch

Index: po/exgettext
===================================================================
--- po/exgettext	(revision 166441)
+++ po/exgettext	(working copy)
@@ -63,14 +63,21 @@  kopt=$pwd/$T/keyword-options
 kopt2=$pwd/$T/keyword2-options
 emsg=$pwd/$T/emsgids.c
 posr=$pwd/$T/po-sources
+posrcxx=$pwd/$T/po-cxx-sources
 pottmp1=$pwd/$T/tmp1.pot
 pottmp2=$pwd/$T/tmp2.pot
+pottmp3=$pwd/$T/tmp3.pot
 pottmp=$pwd/$T/tmp.pot
 
-# Locate files to scan, and generate the list.  All .c, .h, and .def files
-# in $srcdir are examined, likewise $srcdir/config and $srcdir/config/*
-# (directories).  Also, all subdirectories of $srcdir that contain a
-# config-lang.in.  Exclusions come from $srcdir/po/EXCLUDE.
+# Locate files to scan.  We scan the following directories:
+#  $srcdir
+#  $srcdir/c-family
+#  $srcdir/config
+#  $srcdir/config/*
+#  all subdirectories of $srcdir containing a config-lang.in file, and
+#    all subdirectories of those directories.
+# Within those directories, we examine all .c, .cc, .h, and .def files.
+# However, any files listed in $srcdir/po/EXCLUDE are not examined.
 #
 # Then generate keyword options for xgettext, by scanning for declarations
 # of functions whose parameter names end in "msgid".
@@ -83,14 +90,15 @@  pottmp=$pwd/$T/tmp.pot
 echo "scanning for keywords, %e and %n strings..." >&2
 
 ( cd $srcdir
-  lang_subdirs=`echo */config-lang.in */*/config-lang.in | sed -e 's|config-lang\.in||g'`
-  { for dir in "" c-family/ config/ config/*/ $lang_subdirs
-    do  for glob in '*.c' '*.h' '*.def'
+  lang_subdirs=`echo */config-lang.in */*/config-lang.in | sed -e 's|/config-lang\.in||g'`
+  { for dir in "" c-family/ config/ config/*/ \
+      `find $lang_subdirs -type d -print | fgrep -v .svn | sed -e 's|$|/|'`
+    do  for glob in '*.c' '*.cc' '*.h' '*.def'
         do  eval echo $dir$glob
         done
     done;
   } | tr ' ' "$nl" | grep -v '\*' |
-  $AWK -v excl=po/EXCLUDES -v posr=$posr -v kopt=$kopt -v kopt2=$kopt2 -v emsg=$emsg '
+  $AWK -v excl=po/EXCLUDES -v posr=$posr -v posrcxx=$posrcxx -v kopt=$kopt -v kopt2=$kopt2 -v emsg=$emsg '
 function keyword_option(line) {
     paren_index = index(line, "(")
     name = substr(line, 1, paren_index - 1)
@@ -178,7 +186,11 @@  BEGIN {
 }
 
 { if (!($0 in excludes)) {
-    print > posr
+    if ($0 ~ /.cc$/) {
+      print > posrcxx
+    } else {
+      print > posr
+    }
     files[NR] = $0
   }
 }
@@ -256,20 +268,29 @@  echo "scanning option files..." >&2
     }
   }') >> $emsg
 
-# Run the xgettext command, with temporary added as a file to scan.
+# Run the xgettext commands, with temporary added as a file to scan.
 echo "running xgettext..." >&2
 $xgettext --default-domain=$package --directory=$srcdir \
 	  --add-comments `cat $kopt` --files-from=$posr \
 	  --copyright-holder="Free Software Foundation, Inc." \
 	  --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
 	  --language=c -o $pottmp1
+if test -s $posrcxx; then
+  $xgettext --default-domain=$package --directory=$srcdir \
+	    --add-comments `cat $kopt` --files-from=$posrcxx \
+	    --copyright-holder="Free Software Foundation, Inc." \
+	    --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
+	    --language=c++ -o $pottmp2
+else
+  echo > $pottmp2
+fi
 $xgettext --default-domain=$package --directory=$srcdir \
 	  --add-comments --keyword= `cat $kopt2` --files-from=$posr \
 	  --copyright-holder="Free Software Foundation, Inc." \
 	  --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
-	  --language=GCC-source -o $pottmp2
+	  --language=GCC-source -o $pottmp3
 $xgettext --default-domain=$package \
-	  --add-comments $pottmp1 $pottmp2 \
+	  --add-comments $pottmp1 $pottmp2 $pottmp3 \
 	  --copyright-holder="Free Software Foundation, Inc." \
 	  --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
 	  --language=PO -o $pottmp
Index: po/EXCLUDES
===================================================================
--- po/EXCLUDES	(revision 166441)
+++ po/EXCLUDES	(working copy)
@@ -18,8 +18,8 @@ 
 
 # This file lists all the sources which should *not* be scanned for
 # strings to translate.  Only the first word on each line is used; the
-# rest is ignored.  Only files with an extension of .c or .h or .def are
-# examined to begin with.
+# rest is ignored.  Only files with an extension of .c, .cc, .h, or
+# .def are examined to begin with.
 
 #   These files are part of libgcc, or target headers provided by gcc.
 config/darwin-crt2.c