1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include "javaoptions.hxx"
23 #include <osl/process.h>
24 #include <osl/thread.h>
30 #define SEPARATOR '\\'
33 bool JavaOptions::initOptions(int ac
, char* av
[], bool bCmdFile
)
43 sal_Int32 index
= name
.lastIndexOf(SEPARATOR
);
44 m_program
= name
.copy(index
> 0 ? index
+1 : 0);
48 fprintf(stderr
, "%s", prepareHelp().getStr());
65 if (i
< ac
- 1 && av
[i
+1][0] != '-')
71 OString
tmp("'-O', please check"_ostr
);
74 tmp
+= OString::Concat(" your input '") + av
[i
+1] + "'";
77 throw IllegalArgument(tmp
);
84 m_options
["-O"_ostr
] = OString(s
);
87 if (av
[i
][2] != 'D' || av
[i
][3] != '\0')
89 OString
tmp(OString::Concat("'-nD', please check your input '") + av
[i
] + "'");
90 throw IllegalArgument(tmp
);
93 m_options
["-nD"_ostr
] = OString();
98 if (i
< ac
- 1 && av
[i
+1][0] != '-')
104 OString
tmp("'-T', please check"_ostr
);
107 tmp
+= OString::Concat(" your input '") + av
[i
+1] + "'";
110 throw IllegalArgument(tmp
);
117 if (m_options
.count("-T"_ostr
) > 0)
119 OString tmp
= m_options
["-T"_ostr
] + ";" + s
;
120 m_options
["-T"_ostr
] = tmp
;
123 m_options
["-T"_ostr
] = OString(s
);
129 if (av
[i
][3] != '\0')
131 OString
tmp("'-Gc', please check"_ostr
);
134 tmp
+= OString::Concat(" your input '") + av
[i
] + "'";
137 throw IllegalArgument(tmp
);
140 m_options
["-Gc"_ostr
] = OString();
142 } else if (av
[i
][2] != '\0')
144 OString
tmp("'-G', please check"_ostr
);
147 tmp
+= OString::Concat(" your input '") + av
[i
] + "'";
150 throw IllegalArgument(tmp
);
153 m_options
["-G"_ostr
] = OString();
155 case 'X': // support for eXtra type rdbs
157 if (av
[i
][2] == '\0')
159 if (i
< ac
- 1 && av
[i
+1][0] != '-')
165 OString
tmp("'-X', please check"_ostr
);
168 tmp
+= OString::Concat(" your input '") + av
[i
+1] + "'";
171 throw IllegalArgument(tmp
);
178 m_extra_input_files
.emplace_back(s
);
183 throw IllegalArgument(OString::Concat("the option is unknown") + av
[i
]);
189 FILE* cmdFile
= fopen(av
[i
]+1, "r");
190 if( cmdFile
== nullptr )
192 fprintf(stderr
, "%s", prepareHelp().getStr());
200 while (fscanf(cmdFile
, "%511s", buffer
) != EOF
&& rargc
< 512)
202 rargv
[rargc
]= strdup(buffer
);
207 ret
= initOptions(rargc
, rargv
, bCmdFile
);
209 for (int j
=0; j
< rargc
; j
++)
216 m_inputFiles
.emplace_back(av
[i
]);
224 OString
JavaOptions::prepareHelp()
226 OString help
= "\nusing: " +
227 m_program
+ " [-options] file_1 ... file_n -Xfile_n+1 -Xfile_n+2\nOptions:\n"
228 " -O<path> = path describes the root directory for the generated output.\n"
229 " The output directory tree is generated under this directory.\n"
230 " -T<name> = name specifies a type or a list of types. The output for this\n"
231 " [t1;...] type and all dependent types are generated. If no '-T' option is\n"
232 " specified, then output for all types is generated.\n"
233 " Example: 'com.sun.star.uno.XInterface' is a valid type.\n"
234 " -nD = no dependent types are generated.\n"
235 " -G = generate only target files which does not exists.\n"
236 " -Gc = generate only target files which content will be changed.\n"
237 " -X<file> = extra types which will not be taken into account for generation.\n\n" +
243 OString
JavaOptions::prepareVersion() const
245 return m_program
+ " Version 2.0\n\n";
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */