SConscript 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import os
  2. Import('RTT_ROOT')
  3. from building import *
  4. def _ft_get_src_path(fn):
  5. # from docs/INSTALL.ANY
  6. ft_base_src = set([
  7. # use the ftsystem ourown
  8. #'ftsystem.c'
  9. 'ftinit.c',
  10. 'ftdebug.c',
  11. 'ftbase.c',
  12. 'ftbbox.c',
  13. 'ftglyph.c',
  14. 'ftbdf.c',
  15. 'ftbitmap.c',
  16. 'ftcid.c',
  17. 'ftfstype.c',
  18. 'ftgasp.c',
  19. 'ftgxval.c',
  20. 'ftlcdfil.c',
  21. 'ftmm.c',
  22. 'ftotval.c',
  23. 'ftpatent.c',
  24. 'ftpfr.c',
  25. 'ftstroke.c',
  26. 'ftsynth.c',
  27. 'fttype1.c',
  28. 'ftwinfnt.c',
  29. 'ftxf86.c',
  30. 'ftmac.c',
  31. ])
  32. ft_s_fn = {
  33. 'type1cid.c' : 'src/cid/',
  34. 'winfnt.c' : 'src/winfonts/',
  35. 'ftcache.c' : 'src/cache/',
  36. 'ftgzip.c' : 'src/gzip/',
  37. 'ftlzw.c' : 'src/lzw/',
  38. 'ftbz2.c' : 'src/bz2/',
  39. 'ftsystem.c' : 'builds/rt-thread/',
  40. 'gb2312tounicode.c' : 'builds/rt-thread/',
  41. }
  42. # Always keep the path seperator in unix format.
  43. if fn in ft_base_src:
  44. return 'src/base/' + fn
  45. # Handle special files
  46. elif fn in ft_s_fn:
  47. return ft_s_fn[fn] + fn
  48. else:
  49. # str.lstrip is not technically right here, but it just work(tm).
  50. return 'src/' + fn.rstrip('.c') + '/' + fn
  51. # from docs/INSTALL.ANY
  52. ft_deps = {
  53. 'ftcache.c' : ['ftglyph.c'],
  54. 'ftfstype.c' : ['fttype1.c'],
  55. 'ftglyph.c' : ['ftbitmap.c'],
  56. 'ftstroke.c' : ['ftglyph.c'],
  57. 'ftsynth.c' : ['ftbitmap.c'],
  58. 'cff.c' : ['sfnt.c', 'pshinter.c', 'psnames.c'],
  59. 'truetype.c' : ['sfnt.c', 'psnames.c'],
  60. 'type1.c' : ['psaux.c' 'pshinter.c', 'psnames.c'],
  61. 'type1cid.c' : ['psaux.c', 'pshinter.c', 'psnames.c'],
  62. 'type42.c' : ['truetype.c'],
  63. }
  64. ft_modules = {
  65. 'autofit.c' : ['FT_Module_Class' , 'autofit_module_class' ],
  66. 'truetype.c': ['FT_Driver_ClassRec', 'tt_driver_class' ],
  67. 'type1.c' : ['FT_Driver_ClassRec', 't1_driver_class' ],
  68. 'cff.c' : ['FT_Driver_ClassRec', 'cff_driver_class' ],
  69. 'type1cid.c': ['FT_Driver_ClassRec', 't1cid_driver_class' ],
  70. 'pfr.c' : ['FT_Driver_ClassRec', 'pfr_driver_class' ],
  71. 'type42.c' : ['FT_Driver_ClassRec', 't42_driver_class' ],
  72. 'winfnt.c' : ['FT_Driver_ClassRec', 'winfnt_driver_class' ],
  73. 'pcf.c' : ['FT_Driver_ClassRec', 'pcf_driver_class' ],
  74. 'psaux.c' : ['FT_Module_Class' , 'psaux_module_class' ],
  75. 'psnames.c' : ['FT_Module_Class' , 'psnames_module_class' ],
  76. 'pshinter.c': ['FT_Module_Class' , 'pshinter_module_class' ],
  77. 'raster.c' : ['FT_Renderer_Class' , 'ft_raster1_renderer_class' ],
  78. 'sfnt.c' : ['FT_Module_Class' , 'sfnt_module_class' ],
  79. 'smooth.c' : ['FT_Renderer_Class' , 'ft_smooth_renderer_class' ],
  80. #'smooth.c' : ['FT_Renderer_Class' , 'ft_smooth_lcd_renderer_class' ],
  81. #'smooth.c' : ['FT_Renderer_Class' , 'ft_smooth_lcdv_renderer_class'],
  82. 'bdf.c' : ['FT_Driver_ClassRec', 'bdf_driver_class' ],
  83. }
  84. def _ft_build_dep_src(fnli):
  85. dep_added = False
  86. for i in fnli:
  87. for k in ft_deps.get(i, []):
  88. if k not in fnli:
  89. dep_added = True
  90. fnli.append(k)
  91. if not dep_added:
  92. return fnli
  93. else:
  94. return _ft_build_dep_src(fnli)
  95. def _ft_add_basic_system(fnli):
  96. for i in ('ftbase.c',
  97. 'ftbbox.c',
  98. 'ftfstype.c',
  99. 'ftglyph.c',
  100. 'ftinit.c',
  101. 'ftlcdfil.c',
  102. 'ftmm.c',
  103. 'ftpatent.c',
  104. 'gb2312tounicode.c',
  105. 'ftsystem.c',):
  106. if i not in fnli:
  107. fnli.append(i)
  108. return fnli
  109. group = []
  110. # Test the depend before do any thing(copy config files etc).
  111. if not GetDepend(['RT_USING_RTGUI', 'RTGUI_USING_TTF']):
  112. Return('group')
  113. ###
  114. # Configurations
  115. ###
  116. enabled_modules = ['autofit.c', 'truetype.c', 'smooth.c']
  117. ###
  118. #
  119. ###
  120. enabled_modules = _ft_add_basic_system(enabled_modules)
  121. enabled_modules = _ft_build_dep_src(enabled_modules)
  122. proj_dir = str(Dir('#'))
  123. config_dir = os.path.join(proj_dir, 'ftconfig')
  124. if not os.path.exists(config_dir):
  125. os.mkdir(config_dir)
  126. for d, i in (('/include/config/', 'ftconfig.h'),
  127. ('/builds/rt-thread/', 'ftoption.h')):
  128. if not os.path.exists(os.path.join(config_dir, i)):
  129. import shutil
  130. shutil.copy(GetCurrentDir() + d + i, config_dir)
  131. if not os.path.exists(os.path.join(config_dir, 'ft2build.h')):
  132. with open(os.path.join(config_dir, 'ft2build.h'), 'w') as e:
  133. e.write('''
  134. #ifndef __FT2BUILD_H__
  135. #define __FT2BUILD_H__
  136. #define FT_CONFIG_OPTIONS_H <ftoption.h>
  137. #define FT_CONFIG_MODULES_H <ftmodule.h>
  138. #define FT_CONFIG_CONFIG_H <ftconfig.h>
  139. #include <config/ftheader.h>
  140. #endif /* __FT2BUILD_H__ */
  141. ''')
  142. f = open(os.path.join(config_dir, 'ftmodule.h'), 'w')
  143. for m in enabled_modules:
  144. if m in ft_modules:
  145. f.write('FT_USE_MODULE( ' + ', '.join(ft_modules[m]) + ')\n')
  146. # proj_dir/ftconfig should precede include/ in freetype
  147. cpp_path = [config_dir, os.path.join(GetCurrentDir(), 'include/')]
  148. src_file = [_ft_get_src_path(i) for i in enabled_modules]
  149. group = DefineGroup('FreeType',
  150. src_file,
  151. CPPPATH = cpp_path,
  152. # Depend is tested above
  153. depend = [],
  154. CPPDEFINES = ['FT2_BUILD_LIBRARY']
  155. )
  156. Return('group')