You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2007/09/05 11:18:49 UTC

svn commit: r572913 - in /incubator/stdcxx/trunk: etc/config/GNUmakefile.bin etc/config/windows/projects.js util/gencat.cpp

Author: faridz
Date: Wed Sep  5 02:18:49 2007
New Revision: 572913

URL: http://svn.apache.org/viewvc?rev=572913&view=rev
Log:
2007-09-05 Farid Zaripov <Fa...@epam.com>

	* GNUmakefile.bin: Added gencat target.
	* projects.js (CreateProjectsDefs): Added gencat utility project.
	* gencat.cpp: New utility for generating the message catalogs.

Added:
    incubator/stdcxx/trunk/util/gencat.cpp   (with props)
Modified:
    incubator/stdcxx/trunk/etc/config/GNUmakefile.bin
    incubator/stdcxx/trunk/etc/config/windows/projects.js

Modified: incubator/stdcxx/trunk/etc/config/GNUmakefile.bin
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/etc/config/GNUmakefile.bin?rev=572913&r1=572912&r2=572913&view=diff
==============================================================================
--- incubator/stdcxx/trunk/etc/config/GNUmakefile.bin (original)
+++ incubator/stdcxx/trunk/etc/config/GNUmakefile.bin Wed Sep  5 02:18:49 2007
@@ -34,7 +34,7 @@
 ONE_REPOSITORY = 1
 include ../makefile.common
 
-TARGET    = exec localedef locale
+TARGET    = exec localedef locale gencat
 
 # locale sources and related 
 NLSDIR = $(TOPDIR)/etc/nls
@@ -99,6 +99,12 @@
 
 # link the locale utility
 locale: locale_stub.o
+	@echo "$(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS)" $(call CXX.repo,$<) \
+	>> $(LOGFILE)
+	$(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS) $(call CXX.repo,$<) $(TEEOPTS)
+
+# link the gencat utility
+gencat: gencat.o
 	@echo "$(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS)" $(call CXX.repo,$<) \
 	>> $(LOGFILE)
 	$(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS) $(call CXX.repo,$<) $(TEEOPTS)

Modified: incubator/stdcxx/trunk/etc/config/windows/projects.js
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/etc/config/windows/projects.js?rev=572913&r1=572912&r2=572913&view=diff
==============================================================================
--- incubator/stdcxx/trunk/etc/config/windows/projects.js (original)
+++ incubator/stdcxx/trunk/etc/config/windows/projects.js Wed Sep  5 02:18:49 2007
@@ -190,6 +190,22 @@
     utilsArray.push(localeDef);
 
 ///////////////////////////////////////////////////////////////////////////////
+    var gencatDef = new ProjectDef("util_gencat", typeApplication);
+    gencatDef.VCProjDir = ProjectsDir + "\\util";
+    gencatDef.FilterDefs.push(
+        new FilterDef(sourceFilterName, sourceFilterUuid, sourceFilterExts, eFileTypeCppCode, false).
+            addFiles("%SRCDIR%\\util",
+                new Array("gencat.cpp")));
+    gencatDef.Defines = commonDefines;
+    gencatDef.Includes = stdcxxIncludes;
+    gencatDef.OutDir = binPath;
+    gencatDef.Libs = commonLibs;
+    gencatDef.OutFile = "$(OutDir)\\gencat.exe";
+    gencatDef.PrjRefs.push(stdcxxDef);
+
+    utilsArray.push(gencatDef);
+
+///////////////////////////////////////////////////////////////////////////////
     var utilsDef = new ProjectDef(".stdcxx_utils", typeGeneric);
     utilsDef.VCProjDir = ProjectsDir + "\\util";
     utilsDef.OutDir = binPath;
@@ -197,6 +213,7 @@
     utilsDef.PrjDeps.push(execDef);
     utilsDef.PrjDeps.push(localedefDef);
     utilsDef.PrjDeps.push(localeDef);
+    utilsDef.PrjDeps.push(gencatDef);
 
     utilsArray.push(utilsDef);
 

Added: incubator/stdcxx/trunk/util/gencat.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/gencat.cpp?rev=572913&view=auto
==============================================================================
--- incubator/stdcxx/trunk/util/gencat.cpp (added)
+++ incubator/stdcxx/trunk/util/gencat.cpp Wed Sep  5 02:18:49 2007
@@ -0,0 +1,169 @@
+/***************************************************************************
+ *
+ * gencat.cpp - Utility for generating message catalogs on Windows
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * Licensed to the Apache Software  Foundation (ASF) under one or more
+ * contributor  license agreements.  See  the NOTICE  file distributed
+ * with  this  work  for  additional information  regarding  copyright
+ * ownership.   The ASF  licenses this  file to  you under  the Apache
+ * License, Version  2.0 (the  "License"); you may  not use  this file
+ * except in  compliance with the License.   You may obtain  a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the  License is distributed on an  "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY  KIND, either  express or
+ * implied.   See  the License  for  the  specific language  governing
+ * permissions and limitations under the License.
+ *
+ **************************************************************************/
+
+#include <cstdlib>   // for system(), getenv()
+#include <cstdio>    // for printf()
+#include <cstring>   // for strcmp(), strrchr()
+#include <cstddef>   // for size_t
+
+#include <string>
+
+static const char
+usage_text[] = {
+    "Usage: %s OUTPUT-FILE INPUT-FILE\n"
+    "Generate message catalog.\n"
+    "\n"
+    "  -?, --help                 Give this help list\n"
+};
+
+#ifdef _WIN32
+#  define SLASH '\\'
+
+// replace file extension in str by new extension ext
+static void change_ext (std::string& str, const char* ext)
+{
+    const std::string::size_type npos = std::string::npos;
+    std::string::size_type dot_pos = str.find_last_of ('.');
+    std::string::size_type quote_pos =
+        npos == dot_pos ? str.find_last_of ('\"')
+        : str.find_first_of ('\"', dot_pos);
+    if (npos == quote_pos)
+        quote_pos = str.size ();
+    if (npos == dot_pos)
+        dot_pos = quote_pos;
+    str.replace (dot_pos, quote_pos - dot_pos, ext);
+}
+
+#else    // !_WIN32
+#  define SLASH '/'
+#endif   // _WIN32
+
+int main (int argc, char *argv[])
+{
+    const char* exe_name = std::strrchr (argv [0], SLASH);
+    if (exe_name)
+        ++exe_name;
+    else
+        exe_name = argv [0];
+
+    if (1 == argc) {
+        std::printf (usage_text, exe_name);
+        return 0;
+    }
+
+    --argc;
+
+    while (0 != *++argv && 0 < argc-- && '-' == **argv) {
+
+        switch (*++*argv) {
+
+        case '?':
+            std::printf (usage_text, exe_name);
+            return 0;
+
+        case '-':
+            if (0 == std::strcmp (*argv, "-help")) {
+                std::printf (usage_text, exe_name);
+                return 0;
+            }
+
+            // fall through...
+        default:
+            std::printf ("%s: invalid option -%s\n",
+                         exe_name, *argv);
+            return 1;
+        }
+    }
+
+    if (1 > argc) {
+        std::printf ("%s: missing arguments\n Try '%s --help'\n",
+                     exe_name, exe_name);
+        return 1;
+    }
+
+    std::string cmd;
+
+#ifdef _WIN32
+
+#  ifndef _WIN64
+#    define PLATFORM "X86"
+#  else   // _WIN64
+#    define PLATFORM "X64"
+#  endif  // _WIN64
+
+    const char* const env_vars [] = {
+        "VS80COMNTOOLS", "VS71COMNTOOLS", "VSCOMNTOOLS"
+    };
+
+    for (size_t i = 0; i < sizeof (env_vars) / sizeof (*env_vars); ++i) {
+        if (const char* vcvarspath = std::getenv (env_vars [i])) {
+            cmd = vcvarspath;
+            cmd += "vsvars32.bat";
+            break;
+        }
+    }
+
+    if (std::string::npos != cmd.find (' ')) {
+        cmd.insert (0, 1, '\"');
+        cmd.push_back ('\"');
+    }
+
+    const char* const dll_name = argv [0];
+    const char* const rc_name = argv [1];
+
+    std::string res_name (rc_name);
+    change_ext (res_name, ".res");
+
+    if (!cmd.empty ())
+        cmd += " && ";
+
+    cmd += "rc ";
+    cmd += rc_name;
+    cmd += " && link /NOLOGO /DLL /NOENTRY /MACHINE:" PLATFORM " /OUT:";
+    cmd += dll_name;
+    cmd += ' ';
+    cmd += res_name;
+    
+    const int ret = std::system (cmd.c_str ());
+
+    std::remove (res_name.c_str ());
+
+#else    // !_WIN32
+
+    const char* const cat_name = argv [0];
+    const char* const msg_name = argv [1];
+
+    cmd = "/usr/bin/gencat ";
+    cmd += cat_name;
+    cmd += ' ';
+    cmd += msg_name;
+
+    const int ret = std::system (cmd.c_str ());
+
+#endif   // _WIN32
+
+    return ret;
+}

Propchange: incubator/stdcxx/trunk/util/gencat.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stdcxx/trunk/util/gencat.cpp
------------------------------------------------------------------------------
    svn:keywords = Id