c.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2006-2018 (ita)
  4. "Base for c programs/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('.c')
  9. def c_hook(self, node):
  10. "Binds the c file extensions create :py:class:`waflib.Tools.c.c` instances"
  11. if not self.env.CC and self.env.CXX:
  12. return self.create_compiled_task('cxx', node)
  13. return self.create_compiled_task('c', node)
  14. class c(Task.Task):
  15. "Compiles C files into object files"
  16. run_str = '${CC} ${ARCH_ST:ARCH} ${CFLAGS} ${FRAMEWORKPATH_ST:FRAMEWORKPATH} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].relpath()} ${CPPFLAGS}'
  17. vars = ['CCDEPS'] # 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 cprogram(link_task):
  21. "Links object files into c programs"
  22. run_str = '${LINK_CC} ${LINKFLAGS} ${CCLNK_SRC_F}${SRC} ${CCLNK_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. ext_out = ['.bin']
  24. vars = ['LINKDEPS']
  25. inst_to = '${BINDIR}'
  26. class cshlib(cprogram):
  27. "Links object files into c shared libraries"
  28. inst_to = '${LIBDIR}'
  29. class cstlib(stlink_task):
  30. "Links object files into a c static libraries"
  31. pass # do not remove