aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2013-11-17 23:26:38 -0800
committerStephen Hines <srhines@google.com>2014-02-19 16:11:54 -0800
commit476d4f5a0249a3318cb86460e6a1adb2b40ecd6f (patch)
tree538900a59a6e582fb6730f3d7f9f7cfe0ef318c6
parent3a18f6baa1b89f3d927c6767a8e1a9164996da0e (diff)
downloadslang-476d4f5a0249a3318cb86460e6a1adb2b40ecd6f.tar.gz
Fix C++ reflection so that -p works.
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
-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 ff23206..3f630f0 100644
--- a/slang_rs_reflection_cpp.cpp
+++ b/slang_rs_reflection_cpp.cpp
@@ -128,10 +128,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();