am 8d5a2f6a: Support Windows paths in slang.
* commit '8d5a2f6ab321615bfb3a46f68aff0b643a71caa0':
Support Windows paths in slang.
diff --git a/llvm-rs-cc.cpp b/llvm-rs-cc.cpp
index 8c8b1e1..c4d9244 100644
--- a/llvm-rs-cc.cpp
+++ b/llvm-rs-cc.cpp
@@ -275,8 +275,8 @@
// Append '/' to Opts.mOutputDir if not presents
if (!OutputFile.empty() &&
- (OutputFile[OutputFile.size() - 1]) != '/')
- OutputFile.append(1, '/');
+ (OutputFile[OutputFile.size() - 1]) != OS_PATH_SEPARATOR)
+ OutputFile.append(1, OS_PATH_SEPARATOR);
if (OutputType == slang::Slang::OT_Dependency) {
// The build system wants the .d file name stem to be exactly the same as
diff --git a/os_sep.h b/os_sep.h
new file mode 100644
index 0000000..832e8fe
--- /dev/null
+++ b/os_sep.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Licensed 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.
+ */
+
+#ifndef _FRAMEWORKS_COMPILE_SLANG_OS_SEP_H_ // NOLINT
+#define _FRAMEWORKS_COMPILE_SLANG_OS_SEP_H_
+
+#ifdef USE_MINGW
+/* Define the default path separator for the platform. */
+#define OS_PATH_SEPARATOR '\\'
+#define OS_PATH_SEPARATOR_STR "\\"
+
+#else /* not USE_MINGW */
+
+/* Define the default path separator for the platform. */
+#define OS_PATH_SEPARATOR '/'
+#define OS_PATH_SEPARATOR_STR "/"
+
+#endif
+
+#endif // _FRAMEWORKS_COMPILE_SLANG_NO_SEP_H_ NOLINT
diff --git a/slang_rs.cpp b/slang_rs.cpp
index b14757a..a6a5c50 100644
--- a/slang_rs.cpp
+++ b/slang_rs.cpp
@@ -28,6 +28,7 @@
#include "llvm/System/Path.h"
+#include "os_sep.h"
#include "slang_rs_backend.h"
#include "slang_rs_context.h"
#include "slang_rs_export_type.h"
@@ -295,7 +296,7 @@
I++) {
std::string ReflectedName = RSSlangReflectUtils::ComputePackagedPath(
JavaReflectionPathBase.c_str(),
- (RealPackageName + "/" + *I).c_str());
+ (RealPackageName + OS_PATH_SEPARATOR_STR + *I).c_str());
appendGeneratedFileName(ReflectedName + ".java");
}
diff --git a/slang_rs_reflect_utils.cpp b/slang_rs_reflect_utils.cpp
index 317216f..3298026 100644
--- a/slang_rs_reflect_utils.cpp
+++ b/slang_rs_reflect_utils.cpp
@@ -22,6 +22,7 @@
#include "llvm/ADT/StringRef.h"
+#include "os_sep.h"
#include "slang_utils.h"
namespace slang {
@@ -32,7 +33,7 @@
const char *dot = fileName + strlen(fileName);
const char *slash = dot - 1;
while (slash >= fileName) {
- if (*slash == '/') {
+ if (*slash == OS_PATH_SEPARATOR) {
break;
}
if ((*slash == '.') && (*dot == 0)) {
@@ -48,14 +49,14 @@
const char *prefixPath, const char *packageName) {
string packaged_path(prefixPath);
if (!packaged_path.empty() &&
- (packaged_path[packaged_path.length() - 1] != '/')) {
- packaged_path += "/";
+ (packaged_path[packaged_path.length() - 1] != OS_PATH_SEPARATOR)) {
+ packaged_path += OS_PATH_SEPARATOR_STR;
}
size_t s = packaged_path.length();
packaged_path += packageName;
while (s < packaged_path.length()) {
if (packaged_path[s] == '.') {
- packaged_path[s] = '/';
+ packaged_path[s] = OS_PATH_SEPARATOR;
}
++s;
}
@@ -66,7 +67,7 @@
const char *dot = rsFileName + strlen(rsFileName);
const char *slash = dot - 1;
while (slash >= rsFileName) {
- if (*slash == '/') {
+ if (*slash == OS_PATH_SEPARATOR) {
break;
}
if ((*slash == '.') && (*dot == 0)) {
@@ -250,7 +251,7 @@
filename += ".java";
string output_filename(output_path);
- output_filename += "/";
+ output_filename += OS_PATH_SEPARATOR_STR;
output_filename += filename;
printf("Generating %s ...\n", filename.c_str());
FILE *pfout = fopen(output_filename.c_str(), "w");
diff --git a/slang_rs_reflection.cpp b/slang_rs_reflection.cpp
index 5334c14..2460235 100644
--- a/slang_rs_reflection.cpp
+++ b/slang_rs_reflection.cpp
@@ -28,6 +28,7 @@
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/StringExtras.h"
+#include "os_sep.h"
#include "slang_rs_context.h"
#include "slang_rs_export_var.h"
#include "slang_rs_export_func.h"
@@ -1853,7 +1854,7 @@
if (!SlangUtils::CreateDirectoryWithParents(Path, &ErrorMsg))
return false;
- std::string ClassFile = Path + "/" + ClassName + ".java";
+ std::string ClassFile = Path + OS_PATH_SEPARATOR_STR + ClassName + ".java";
mOF.open(ClassFile.c_str());
if (!mOF.good()) {