37 "Usage: %s OUTPUT-FILE INPUT-FILE\n"
38 "Generate message catalog.\n"
40 " -?, --help Give this help list\n"
47static void change_ext (std::string&
str,
const char* ext)
49 const std::string::size_type npos = std::string::npos;
50 std::string::size_type dot_pos =
str.find_last_of (
'.');
51 std::string::size_type quote_pos =
52 npos == dot_pos ?
str.find_last_of (
'\"')
53 :
str.find_first_of (
'\"', dot_pos);
54 if (npos == quote_pos)
55 quote_pos =
str.size ();
58 str.replace (dot_pos, quote_pos - dot_pos, ext);
65int main (
int argc,
char *argv[])
70 if (
const char* slash = std::strrchr (argv [0],
SLASH))
85 while (0 != *++argv && 0 < argc-- &&
'-' == **argv) {
94 if (0 == std::strcmp (*argv,
"-help")) {
101 std::printf (
"%s: invalid option -%s\n",
108 std::printf (
"%s: missing arguments\n Try '%s --help'\n",
119 const char*
const env_vars [] = {
120 "VS90COMNTOOLS",
"VS80COMNTOOLS",
121 "VS71COMNTOOLS",
"VSCOMNTOOLS"
124 for (
size_t i = 0;
i <
sizeof (env_vars) /
sizeof (*env_vars); ++
i) {
125 if (
const char* vcvarspath = std::getenv (env_vars [
i])) {
127 cmd +=
"vsvars32.bat";
132 if (std::string::npos != cmd.find (
' ')) {
133 cmd.insert (cmd.begin (), 1,
'\"');
134 cmd.push_back (
'\"');
142 const char*
const dll_name = argv [0];
143 const char*
const rc_name = argv [1];
145 std::string res_name (rc_name);
146 change_ext (res_name,
".res");
150 cmd +=
"windres -O coff -i ";
154 cmd +=
" && gcc -shared -mno-cygwin -o ";
162# define PLATFORM "X86"
164# define PLATFORM "X64"
169 cmd +=
" && link /NOLOGO /DLL /NOENTRY /MACHINE:" PLATFORM
" /OUT:";
176 const int ret = std::system (cmd.c_str ());
178 std::remove (res_name.c_str ());
182 const char*
const cat_name = argv [0];
183 const char*
const msg_name = argv [1];
185 cmd =
"/usr/bin/gencat ";
190 const int ret = std::system (cmd.c_str ());