aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2013-11-17 23:26:38 -0800
committerStephen Hines <srhines@google.com>2013-11-18 21:09:25 +0000
commitac71e8c3b3edca77a561377b1f24447a3c2ac3a5 (patch)
tree04ed7cfe2af2bab7b1723e763183715e38efb1ab
parent80706836b18127b5733d790613a5d1b9f97cbb1d (diff)
downloadslang-kitkat-wear.tar.gz
The C++ reflection code was missing support for the -p option, which allows the developer to place the .cpp/.h files into a different directory than the bitcode. It was also missing directory creation (and path separators) for that option. Change-Id: I5b16a6d109c6df8ca3e1542e0c5345691037bf85 (cherry picked from commit c7888b0c7c648b8e3987d9ff277e10e0551e203b)
-rw-r--r--llvm-rs-cc.cpp9
-rw-r--r--slang_rs_reflection_cpp.cpp12
2 files changed, 16 insertions, 5 deletions
diff --git a/llvm-rs-cc.cpp b/llvm-rs-cc.cpp
index e2c9599..1736c0b 100644
--- a/llvm-rs-cc.cpp
+++ b/llvm-rs-cc.cpp
@@ -291,10 +291,11 @@ static void ParseArguments(llvm::SmallVectorImpl<const char*> &ArgVector,
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;
+ // mJavaReflectionPathBase can be set for C++ reflected builds.
+ // Set it to the standard mOutputDir (via -o) by default.
+ if (Opts.mJavaReflectionPathBase.empty()) {
+ Opts.mJavaReflectionPathBase = Opts.mOutputDir;
+ }
}
Opts.mOutputDepDir =
diff --git a/slang_rs_reflection_cpp.cpp b/slang_rs_reflection_cpp.cpp
index f583148..adc05b7 100644
--- a/slang_rs_reflection_cpp.cpp
+++ b/slang_rs_reflection_cpp.cpp
@@ -122,10 +122,20 @@ bool RSReflectionCpp::reflect(const string &OutputPathBase,
const string &InputFileName,
const string &OutputBCFileName) {
mInputFileName = InputFileName;
- mOutputPath = OutputPathBase;
+ mOutputPath = OutputPathBase + OS_PATH_SEPARATOR_STR;
mOutputBCFileName = OutputBCFileName;
mClassName = string("ScriptC_") + stripRS(InputFileName);
+ std::string Path =
+ RSSlangReflectUtils::ComputePackagedPath(OutputPathBase.c_str(), "");
+
+ std::string ErrorMsg;
+ if (!SlangUtils::CreateDirectoryWithParents(Path, &ErrorMsg)) {
+ fprintf(stderr, "Error: Could not create path %s - %s\n",
+ Path.c_str(), ErrorMsg.c_str());
+ return false;
+ }
+
makeHeader("android::RSC::ScriptC");
std::vector< std::string > header(mText);
mText.clear();