SConstruct 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import os
  2. import sys
  3. import rtconfig
  4. if os.getenv('RTT_ROOT'):
  5. RTT_ROOT = os.getenv('RTT_ROOT')
  6. else:
  7. RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
  8. if os.getenv('RTT_RTGUI'):
  9. RTT_RTGUI = os.getenv('RTT_RTGUI')
  10. else:
  11. # set the rtgui root directory by hand
  12. # empty string means use the RTGUI in svn
  13. RTT_RTGUI = os.path.normpath(r'F:\Project\git\rt-gui\components\rtgui')
  14. # RTT_RTGUI =''
  15. sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
  16. from building import *
  17. env = Environment(TARGET_ARCH='x86')
  18. Export('RTT_ROOT')
  19. Export('rtconfig')
  20. if rtconfig.PLATFORM == 'cl':
  21. TARGET = 'rtthread-win32.' + rtconfig.TARGET_EXT
  22. libs = Split('''
  23. winmm
  24. gdi32
  25. winspool
  26. comdlg32
  27. advapi32
  28. shell32
  29. ole32
  30. oleaut32
  31. uuid
  32. odbc32
  33. odbccp32
  34. ''')
  35. definitions = Split('''
  36. WIN32
  37. _DEBUG
  38. _CONSOLE
  39. MSVC
  40. ''')
  41. env.Append(CCFLAGS=rtconfig.CFLAGS)
  42. env.Append(LINKFLAGS=rtconfig.LFLAGS)
  43. env['LIBS']=libs
  44. env['CPPDEFINES']=definitions
  45. elif rtconfig.PLATFORM == 'mingw':
  46. libs = Split('''
  47. winmm
  48. gdi32
  49. winspool
  50. comdlg32
  51. advapi32
  52. shell32
  53. ole32
  54. oleaut32
  55. uuid
  56. odbc32
  57. odbccp32
  58. ''')
  59. TARGET = 'rtthread-win32.' + rtconfig.TARGET_EXT
  60. env = Environment(tools = ['mingw'],
  61. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  62. CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
  63. AR = rtconfig.AR, ARFLAGS = '-rc',
  64. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
  65. env['LIBS']=libs
  66. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  67. elif rtconfig.CROSS_TOOL == 'clang-analyze':
  68. TARGET = 'rtthread'
  69. env = Environment(toolpath=[os.path.join(RTT_ROOT, 'tools', 'tools')],
  70. tools = [rtconfig.CROSS_TOOL])
  71. else:
  72. TARGET = 'rtthread'
  73. env['CC']=rtconfig.CC
  74. env.Append(CCFLAGS=rtconfig.CFLAGS)
  75. env.Append(LINKFLAGS=rtconfig.LFLAGS)
  76. env.Append(LIBS=['m'])
  77. # prepare building environment
  78. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False, remove_components=['rtgui'])
  79. if GetDepend('RT_USING_RTGUI'):
  80. if RTT_RTGUI:
  81. objs += SConscript(os.path.join(RTT_RTGUI, 'SConscript'),
  82. variant_dir='build/components/rtgui',
  83. duplicate=0)
  84. objs = objs + SConscript(RTT_RTGUI+'/../../demo/examples/SConscript',
  85. variant_dir='build/examples/gui', duplicate=0)
  86. else:
  87. objs += SConscript(os.path.join(RTT_ROOT + '/components/rtgui', 'SConscript'),
  88. variant_dir='build/components/rtgui',
  89. duplicate=0)
  90. objs = objs + SConscript(RTT_ROOT + '/examples/gui/SConscript',
  91. variant_dir='build/examples/gui', duplicate=0)
  92. if GetDepend('RT_USING_TC'):
  93. objs = objs + SConscript(RTT_ROOT + '/examples/kernel/SConscript', variant_dir = 'build/tc/kernel', duplicate=0)
  94. def ObjRemove(objs, remove):
  95. for item in objs:
  96. # print type(item), os.path.basename(str(item))
  97. if os.path.basename(str(item)) in remove:
  98. objs.remove(item)
  99. return
  100. # build program -shared
  101. if GetDepend('RT_USING_MODULE'):
  102. # Remove module.c in $RTT_ROOT/src
  103. ObjRemove(objs, ['module.obj', 'module.o'])
  104. AddOption('--def',
  105. dest='def',
  106. action='store_true',
  107. default=False,
  108. help='create rthread.def of rtthread.dll on windows')
  109. if GetOption('def'):
  110. if rtconfig.PLATFORM == 'mingw':
  111. env['LINKFLAGS'] = rtconfig.DEFFILE_LFLAGS
  112. else:
  113. rtconfig.POST_ACTION = 'createdef.py $TARGET rtthread.def'
  114. program = env.Program(TARGET, objs)
  115. else:
  116. if rtconfig.PLATFORM == 'cl':
  117. objs += ['rtthread.def']
  118. elif rtconfig.PLATFORM == 'mingw':
  119. rtconfig.POST_ACTION = 'del /Q rtthread.lib \n rename librtthread.a rtthread.lib\n'
  120. # rtconfig.POST_ACTION = 'lib /machine:i386 /def:rtthread.def /out:rtthread.lib'
  121. env.SharedLibrary("rtthread.dll", objs)
  122. program = env.Program(TARGET, 'dummy.c', LIBS='rtthread', LIBPATH='.')
  123. else:
  124. program = env.Program(TARGET, objs)
  125. # end building
  126. EndBuilding(TARGET, program)