diff options
-rw-r--r-- | slang.cpp | 7 | ||||
-rw-r--r-- | slang.h | 5 | ||||
-rw-r--r-- | slang_rs.cpp | 47 | ||||
-rw-r--r-- | slang_rs.h | 3 | ||||
-rw-r--r-- | slang_rs_context.cpp | 8 | ||||
-rw-r--r-- | slang_rs_context.h | 7 | ||||
-rw-r--r-- | slang_rs_object_ref_count.cpp | 3 | ||||
-rw-r--r-- | slang_rs_reflection.cpp | 4 | ||||
-rw-r--r-- | slang_rs_reflection.h | 9 |
9 files changed, 68 insertions, 25 deletions
@@ -382,6 +382,13 @@ int Slang::generateDepFile() { DepOpts.OutputFile = mDepOutputFileName; DepOpts.Targets = mAdditionalDepTargets; DepOpts.Targets.push_back(mDepTargetBCFileName); + for (std::vector<std::string>::const_iterator + I = mGeneratedFileNames.begin(), E = mGeneratedFileNames.end(); + I != E; + I++) { + DepOpts.Targets.push_back(*I); + } + mGeneratedFileNames.clear(); // Per-compilation needed initialization createPreprocessor(); @@ -114,6 +114,7 @@ class Slang { std::string mDepOutputFileName; std::string mDepTargetBCFileName; std::vector<std::string> mAdditionalDepTargets; + std::vector<std::string> mGeneratedFileNames; OutputType mOT; @@ -182,6 +183,10 @@ class Slang { const std::vector<std::string> &AdditionalDepTargets) { mAdditionalDepTargets = AdditionalDepTargets; } + inline void appendGeneratedFileName( + const std::string &GeneratedFileName) { + mGeneratedFileNames.push_back(GeneratedFileName); + } int generateDepFile(); int compile(); diff --git a/slang_rs.cpp b/slang_rs.cpp index c4fc0f3..b14757a 100644 --- a/slang_rs.cpp +++ b/slang_rs.cpp @@ -195,7 +195,8 @@ void SlangRS::initASTContext() { mRSContext = new RSContext(getPreprocessor(), getASTContext(), getTargetInfo(), - &mPragmas); + &mPragmas, + &mGeneratedFileNames); return; } @@ -261,8 +262,9 @@ bool SlangRS::compile( setIncludePaths(IncludePaths); setOutputType(OutputType); - if (OutputDep) + if (OutputDep) { setAdditionalDepTargets(AdditionalDepTargets); + } mAllowRSPrefix = AllowRSPrefix; @@ -278,21 +280,6 @@ bool SlangRS::compile( if (!setOutput(OutputFile)) return false; - if (OutputDep) { - BCOutputFile = DepFileIter->first; - DepOutputFile = DepFileIter->second; - - setDepTargetBC(BCOutputFile); - - if (!setDepOutput(DepOutputFile)) - return false; - - if (generateDepFile() > 0) - return false; - - DepFileIter++; - } - if (Slang::compile() > 0) return false; @@ -302,6 +289,16 @@ bool SlangRS::compile( &RealPackageName)) return false; + for (std::vector<std::string>::const_iterator + I = mGeneratedFileNames.begin(), E = mGeneratedFileNames.end(); + I != E; + I++) { + std::string ReflectedName = RSSlangReflectUtils::ComputePackagedPath( + JavaReflectionPathBase.c_str(), + (RealPackageName + "/" + *I).c_str()); + appendGeneratedFileName(ReflectedName + ".java"); + } + if ((OutputType == Slang::OT_Bitcode) && (BitcodeStorage == BCST_JAVA_CODE) && !generateBitcodeAccessor(JavaReflectionPathBase, @@ -309,6 +306,21 @@ bool SlangRS::compile( return false; } + if (OutputDep) { + BCOutputFile = DepFileIter->first; + DepOutputFile = DepFileIter->second; + + setDepTargetBC(BCOutputFile); + + if (!setDepOutput(DepOutputFile)) + return false; + + if (generateDepFile() > 0) + return false; + + DepFileIter++; + } + if (!checkODR(InputFile)) return false; @@ -321,6 +333,7 @@ bool SlangRS::compile( void SlangRS::reset() { delete mRSContext; mRSContext = NULL; + mGeneratedFileNames.clear(); Slang::reset(); return; } @@ -47,6 +47,9 @@ class SlangRS : public Slang { unsigned mDiagErrorInvalidOutputDepParameter; unsigned mDiagErrorODR; + // Collect generated filenames (without the .java) for dependency generation + std::vector<std::string> mGeneratedFileNames; + // FIXME: Should be std::list<RSExportable *> here. But currently we only // check ODR on record type. // diff --git a/slang_rs_context.cpp b/slang_rs_context.cpp index 28c76cc..333e8a4 100644 --- a/slang_rs_context.cpp +++ b/slang_rs_context.cpp @@ -45,15 +45,19 @@ namespace slang { RSContext::RSContext(clang::Preprocessor &PP, clang::ASTContext &Ctx, const clang::TargetInfo &Target, - PragmaList *Pragmas) + PragmaList *Pragmas, + std::vector<std::string> *GeneratedFileNames) : mPP(PP), mCtx(Ctx), mTarget(Target), mPragmas(Pragmas), + mGeneratedFileNames(GeneratedFileNames), mTargetData(NULL), mLLVMContext(llvm::getGlobalContext()), mLicenseNote(NULL), version(0) { + assert(mGeneratedFileNames && "Must supply GeneratedFileNames"); + // For #pragma rs export_type PP.AddPragmaHandler( "rs", RSPragmaHandler::CreatePragmaExportTypeHandler(this)); @@ -252,7 +256,7 @@ bool RSContext::reflectToJava(const std::string &OutputPathBase, // Copy back the really applied package name RealPackageName->assign(PackageName); - RSReflection *R = new RSReflection(this); + RSReflection *R = new RSReflection(this, mGeneratedFileNames); bool ret = R->reflect(OutputPathBase, PackageName, InputFileName, OutputBCFileName); if (!ret) diff --git a/slang_rs_context.h b/slang_rs_context.h index 199757a..89954ee 100644 --- a/slang_rs_context.h +++ b/slang_rs_context.h @@ -64,6 +64,7 @@ class RSContext { clang::ASTContext &mCtx; const clang::TargetInfo &mTarget; PragmaList *mPragmas; + std::vector<std::string> *mGeneratedFileNames; llvm::TargetData *mTargetData; llvm::LLVMContext &mLLVMContext; @@ -90,7 +91,8 @@ class RSContext { RSContext(clang::Preprocessor &PP, clang::ASTContext &Ctx, const clang::TargetInfo &Target, - PragmaList *Pragmas); + PragmaList *Pragmas, + std::vector<std::string> *GeneratedFileNames); inline clang::Preprocessor &getPreprocessor() const { return mPP; } inline clang::ASTContext &getASTContext() const { return mCtx; } @@ -117,6 +119,9 @@ class RSContext { mReflectJavaPackageName = S; return; } + inline const std::string &getReflectJavaPackageName() { + return mReflectJavaPackageName; + } bool processExport(); inline void newExportable(RSExportable *E) { diff --git a/slang_rs_object_ref_count.cpp b/slang_rs_object_ref_count.cpp index 59ec672..b2af436 100644 --- a/slang_rs_object_ref_count.cpp +++ b/slang_rs_object_ref_count.cpp @@ -153,9 +153,6 @@ static void ReplaceinCompoundStmt(clang::ASTContext& C, StmtCount++; } - //OldStmt->dump(); - //NewStmt->dump(); - clang::Stmt **UpdatedStmtList = new clang::Stmt*[StmtCount]; unsigned UpdatedStmtCount = 0; diff --git a/slang_rs_reflection.cpp b/slang_rs_reflection.cpp index 96a0d35..4c7fbae 100644 --- a/slang_rs_reflection.cpp +++ b/slang_rs_reflection.cpp @@ -1233,6 +1233,8 @@ bool RSReflection::genTypeClass(Context &C, ErrorMsg)) return false; + mGeneratedFileNames->push_back(ClassName); + genTypeItemClass(C, ERT); // Declare item buffer and item buffer packer @@ -1784,6 +1786,8 @@ bool RSReflection::reflect(const std::string &OutputPathBase, return false; } + mGeneratedFileNames->push_back(ScriptClassName); + // class ScriptField_<TypeName> for (RSContext::const_export_type_iterator TI = mRSContext->export_types_begin(), diff --git a/slang_rs_reflection.h b/slang_rs_reflection.h index 77f01d1..f820e59 100644 --- a/slang_rs_reflection.h +++ b/slang_rs_reflection.h @@ -39,6 +39,8 @@ class RSReflection { const RSContext *mRSContext; std::string mLastError; + std::vector<std::string> *mGeneratedFileNames; + inline void setError(const std::string &Error) { mLastError = Error; } class Context { @@ -275,9 +277,12 @@ class RSReflection { void genNewItemBufferPackerIfNull(Context &C); public: - explicit RSReflection(const RSContext *Context) + explicit RSReflection(const RSContext *Context, + std::vector<std::string> *GeneratedFileNames) : mRSContext(Context), - mLastError("") { + mLastError(""), + mGeneratedFileNames(GeneratedFileNames) { + assert(mGeneratedFileNames && "Must supply GeneratedFileNames"); return; } |