cxx.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2005-2018 (ita)
  4. "Base for c++ programs and libraries"
  5. from waflib import TaskGen, Task
  6. from waflib.Tools import c_preproc
  7. from waflib.Tools.ccroot import link_task, stlink_task
  8. @TaskGen.extension('.cpp','.cc','.cxx','.C','.c++')
  9. def cxx_hook(self, node):
  10. "Binds c++ file extensions to create :py:class:`waflib.Tools.cxx.cxx` instances"
  11. return self.create_compiled_task('cxx', node)
  12. if not '.c' in TaskGen.task_gen.mappings:
  13. TaskGen.task_gen.mappings['.c'] = TaskGen.task_gen.mappings['.cpp']
  14. class cxx(Task.Task):
  15. "Compiles C++ files into object files"
  16. run_str = '${CXX} ${ARCH_ST:ARCH} ${CXXFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F}${SRC} ${CXX_TGT_F}${TGT[0].relpath()} ${CPPFLAGS}'
  17. vars = ['CXXDEPS'] # unused variable to depend on, just in case
  18. ext_in = ['.h'] # set the build order easily by using ext_out=['.h']
  19. scan = c_preproc.scan
  20. class cxxprogram(link_task):
  21. "Links object files into c++ programs"
  22. run_str = '${LINK_CXX} ${LINKFLAGS} ${CXXLNK_SRC_F}${SRC} ${CXXLNK_TGT_F}${TGT[0].relpath()} ${RPATH_ST:RPATH} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${FRAMEWORK_ST:FRAMEWORK} ${ARCH_ST:ARCH} ${STLIB_MARKER} ${STLIBPATH_ST:STLIBPATH} ${STLIB_ST:STLIB} ${SHLIB_MARKER} ${LIBPATH_ST:LIBPATH} ${LIB_ST:LIB} ${LDFLAGS}'
  23. vars = ['LINKDEPS']
  24. ext_out = ['.bin']
  25. inst_to = '${BINDIR}'
  26. class cxxshlib(cxxprogram):
  27. "Links object files into c++ shared libraries"
  28. inst_to = '${LIBDIR}'
  29. class cxxstlib(stlink_task):
  30. "Links object files into c++ static libraries"
  31. pass # do not remove