mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-29 21:32:01 +00:00
Merge "Terminate the output directory argument of flatc." into ub-games-master
This commit is contained in:
committed by
Android (Google) Code Review
commit
63f21cb2a5
@@ -25,6 +25,13 @@
|
|||||||
|
|
||||||
namespace flatbuffers {
|
namespace flatbuffers {
|
||||||
|
|
||||||
|
static const char kPosixPathSeparator = '/';
|
||||||
|
#ifdef _WIN32
|
||||||
|
static const char kPathSeparator = '\\';
|
||||||
|
#else
|
||||||
|
static const char kPathSeparator = kPosixPathSeparator;
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
// Convert an integer or floating point value to a string.
|
// Convert an integer or floating point value to a string.
|
||||||
// In contrast to std::stringstream, "char" values are
|
// In contrast to std::stringstream, "char" values are
|
||||||
// converted to a string of digits.
|
// converted to a string of digits.
|
||||||
|
|||||||
@@ -136,6 +136,10 @@ int main(int argc, const char *argv[]) {
|
|||||||
case 'o':
|
case 'o':
|
||||||
if (++i >= argc) Error("missing path following", arg, true);
|
if (++i >= argc) Error("missing path following", arg, true);
|
||||||
output_path = argv[i];
|
output_path = argv[i];
|
||||||
|
if (!(output_path.back() == flatbuffers::kPathSeparator ||
|
||||||
|
output_path.back() == flatbuffers::kPosixPathSeparator)) {
|
||||||
|
output_path += flatbuffers::kPathSeparator;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
opts.strict_json = true;
|
opts.strict_json = true;
|
||||||
@@ -214,4 +218,3 @@ int main(int argc, const char *argv[]) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,9 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#define PATH_SEPARATOR "\\"
|
|
||||||
#define mkdir(n, m) _mkdir(n)
|
#define mkdir(n, m) _mkdir(n)
|
||||||
#else
|
#else
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#define PATH_SEPARATOR "/"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace flatbuffers {
|
namespace flatbuffers {
|
||||||
@@ -345,7 +343,7 @@ static bool SaveClass(const Parser &parser, const Definition &def,
|
|||||||
it != parser.name_space_.end(); ++it) {
|
it != parser.name_space_.end(); ++it) {
|
||||||
if (name_space_java.length()) {
|
if (name_space_java.length()) {
|
||||||
name_space_java += ".";
|
name_space_java += ".";
|
||||||
name_space_dir += PATH_SEPARATOR;
|
name_space_dir += kPathSeparator;
|
||||||
}
|
}
|
||||||
name_space_java += *it;
|
name_space_java += *it;
|
||||||
name_space_dir += *it;
|
name_space_dir += *it;
|
||||||
@@ -359,7 +357,7 @@ static bool SaveClass(const Parser &parser, const Definition &def,
|
|||||||
code += "import flatbuffers.*;\n\n";
|
code += "import flatbuffers.*;\n\n";
|
||||||
}
|
}
|
||||||
code += classcode;
|
code += classcode;
|
||||||
auto filename = name_space_dir + PATH_SEPARATOR + def.name + ".java";
|
auto filename = name_space_dir + kPathSeparator + def.name + ".java";
|
||||||
return SaveFile(filename.c_str(), code, false);
|
return SaveFile(filename.c_str(), code, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,4 +389,3 @@ bool GenerateJava(const Parser &parser,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace flatbuffers
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user