jcomp.ipp 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef JCOMP_IPP
  14. #define JCOMP_IPP
  15. #include "jlib.hpp"
  16. class CppCompiler : public CInterface, implements ICppCompiler, implements IThreadFactory
  17. {
  18. public:
  19. CppCompiler(const char * _coreName, const char * _sourceDir, const char * _targetDir, unsigned _targetCompiler, bool _verbose);
  20. IMPLEMENT_IINTERFACE
  21. virtual void addCompileOption(const char * option);
  22. virtual void addDefine(const char * symbolName, const char * value = NULL);
  23. virtual void addLibrary(const char * libName);
  24. virtual void addLibraryPath(const char * libPath);
  25. virtual void addLinkOption(const char * option);
  26. virtual void addInclude(const char * includePath);
  27. virtual void addSourceFile(const char * filename);
  28. virtual bool compile();
  29. virtual void setDebug(bool _debug);
  30. virtual void setDebugLibrary(bool _debug);
  31. virtual void setOnlyCompile(bool _onlyCompile) { onlyCompile = _onlyCompile; }
  32. virtual void setCreateExe(bool _createExe);
  33. virtual void setOptimizeLevel(unsigned level);
  34. virtual void setTargetBitLength(unsigned bitlength);
  35. virtual void setMaxCompileThreads(const unsigned max) { maxCompileThreads = max; }
  36. virtual IPooledThread *createNew();
  37. virtual void setCCLogPath(const char* path);
  38. virtual void setSaveTemps(bool _save) { saveTemps = _save; }
  39. virtual void setPrecompileHeader(bool _pch);
  40. virtual void setAbortChecker(IAbortRequestCallback * _abortChecker) {abortChecker = _abortChecker;}
  41. protected:
  42. void expandCompileOptions(StringBuffer & target);
  43. void expandRootDirectory(StringBuffer & expanded, StringBuffer & in);
  44. StringBuffer & getObjectName(StringBuffer & out, const char * filename);
  45. void removeTemporaries();
  46. bool compileFile(IThreadPool * pool, const char * filename, Semaphore & finishedCompiling);
  47. bool doLink();
  48. void writeLogFile(const char* filepath, StringBuffer& log);
  49. public:
  50. atomic_t numFailed;
  51. protected:
  52. StringBuffer compilerOptions;
  53. StringBuffer linkerOptions;
  54. StringBuffer linkerLibraries;
  55. StringAttr sourceDir;
  56. StringAttr targetDir;
  57. StringArray allSources;
  58. StringArray logFiles;
  59. StringAttr ccLogPath;
  60. unsigned targetCompiler;
  61. unsigned maxCompileThreads;
  62. bool onlyCompile;
  63. bool createDLL;
  64. bool targetDebug;
  65. bool useDebugLibrary;
  66. bool verbose;
  67. void _addInclude(StringBuffer &s, const char *paths);
  68. bool saveTemps;
  69. bool precompileHeader;
  70. IAbortRequestCallback * abortChecker;
  71. };
  72. #endif