am 5336159e: am 11274a73: Validate FS (and RS) ASTs.

* commit '5336159ece383e1542e5ca6425309d2e1c28d917':
  Validate FS (and RS) ASTs.
diff --git a/Android.mk b/Android.mk
index da28351..dd9109a 100644
--- a/Android.mk
+++ b/Android.mk
@@ -20,7 +20,9 @@
 LOCAL_PATH := $(call my-dir)
 
 local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
-ifneq ($(TARGET_BUILD_VARIANT),eng)
+ifeq ($(TARGET_BUILD_VARIANT),eng)
+local_cflags_for_slang += -O0
+else
 local_cflags_for_slang += -D__DISABLE_ASSERTS
 endif
 local_cflags_for_slang += -DTARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT)
diff --git a/llvm-rs-cc.cpp b/llvm-rs-cc.cpp
index 08e25e7..1e60c6e 100644
--- a/llvm-rs-cc.cpp
+++ b/llvm-rs-cc.cpp
@@ -280,6 +280,10 @@
 
     if (Args->hasArg(OPT_reflect_cpp)) {
       Opts.mBitcodeStorage = slang::BCST_CPP_CODE;
+      // mJavaReflectionPathBase isn't set for C++ reflected builds
+      // set it to mOutputDir so we can use the path sanely from
+      // RSReflectionBase later on
+      Opts.mJavaReflectionPathBase = Opts.mOutputDir;
     }
 
     Opts.mOutputDepDir =
diff --git a/slang_rs_reflection_base.cpp b/slang_rs_reflection_base.cpp
index c29c89d..a4a0d35 100644
--- a/slang_rs_reflection_base.cpp
+++ b/slang_rs_reflection_base.cpp
@@ -105,14 +105,18 @@
   write("");
 }
 
+// remove path plus .rs from filename to generate class name
 string RSReflectionBase::stripRS(const string &s) const {
-  size_t pos = s.rfind(".rs");
+  string tmp(s);
+  size_t pos = tmp.rfind(".rs");
   if(pos != string::npos) {
-    string tmp(s);
     tmp.erase(pos);
-    return tmp;
   }
-  return s;
+  pos = tmp.rfind("/");
+  if (pos != string::npos) {
+    tmp.erase(0, pos+1);
+  }
+  return tmp;
 }
 
 void RSReflectionBase::write(const std::string &t) {
@@ -134,7 +138,7 @@
 }
 
 bool RSReflectionBase::writeFile(const string &filename, const vector< string > &txt) {
-  FILE *pfin = fopen(filename.c_str(), "wt");
+  FILE *pfin = fopen((mOutputPath + filename).c_str(), "wt");
   if (pfin == NULL) {
     fprintf(stderr, "Error: could not write file %s\n", filename.c_str());
     return false;
diff --git a/slang_rs_reflection_base.h b/slang_rs_reflection_base.h
index 474a738..1f96723 100644
--- a/slang_rs_reflection_base.h
+++ b/slang_rs_reflection_base.h
@@ -65,7 +65,7 @@
 
     std::string stripRS(const std::string &s) const;
 
-    static bool writeFile(const std::string &filename, const std::vector< std::string > &txt);
+    bool writeFile(const std::string &filename, const std::vector< std::string > &txt);
 
 
 private:
diff --git a/slang_rs_reflection_cpp.cpp b/slang_rs_reflection_cpp.cpp
index 65ce7d9..b8eb976 100644
--- a/slang_rs_reflection_cpp.cpp
+++ b/slang_rs_reflection_cpp.cpp
@@ -67,11 +67,11 @@
     mText.clear();
 
 
-    RSReflectionBase::writeFile(mClassName + ".h", header);
-    RSReflectionBase::writeFile(mClassName + ".cpp", cpp);
+    writeFile(mClassName + ".h", header);
+    writeFile(mClassName + ".cpp", cpp);
 
 
-    return false;
+    return true;
 }
 
 typedef std::vector<std::pair<std::string, std::string> > ArgTy;