SConstruct 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #-*- encoding: utf-8 -*-
  2. #-------------------------------------------------------------------------------
  3. # SConstruct
  4. # Copyright (c) Shanghai Real-Thread Electronic Technology Co., Ltd.
  5. #-------------------------------------------------------------------------------
  6. import sys
  7. import os
  8. #-------------------------------------------------------------------------------
  9. # System configuration
  10. #-------------------------------------------------------------------------------
  11. if os.path.isdir('rt-thread'):
  12. RTT_ROOT = 'rt-thread'
  13. elif os.path.isdir('../rt-thread'):
  14. RTT_ROOT = '../rt-thread'
  15. else:
  16. RTT_ROOT = os.path.join(os.getcwd(), '..', '..', '..', '..', '..')
  17. sys.pycache_prefix = os.path.join(RTT_ROOT, 'scripts', '__pycache__')
  18. import rtconfig
  19. sys.path = sys.path + [os.path.abspath(os.path.join(RTT_ROOT, 'scripts'))]
  20. from building import *
  21. Export('RTT_ROOT')
  22. Export('rtconfig')
  23. #-------------------------------------------------------------------------------
  24. # Scons Environment
  25. #-------------------------------------------------------------------------------
  26. TARGET = rtconfig.TARGET
  27. DefaultEnvironment(tools=[])
  28. env = Environment(tools = ['mingw'],
  29. CPP = rtconfig.CPP,
  30. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  31. CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
  32. CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
  33. AR = rtconfig.AR, ARFLAGS = '-rc',
  34. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS,
  35. LD = rtconfig.LD, DTC = rtconfig.DTC
  36. )
  37. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  38. #-------------------------------------------------------------------------------
  39. # Prepare building environment
  40. #-------------------------------------------------------------------------------
  41. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False, app = True)
  42. env.Replace(LINKFLAGS = rtconfig.LFLAGS)
  43. if GetDepend('RT_USING_FPU'):
  44. env['CCFLAGS'] = env['CCFLAGS'].replace('-msoft-float', '-mhard-float')
  45. env['ASFLAGS'] = env['ASFLAGS'].replace('-msoft-float', '-mhard-float')
  46. env['CXXFLAGS'] = env['CXXFLAGS'].replace('-msoft-float', '-mhard-float')
  47. env['LINKFLAGS'] = env['LINKFLAGS'].replace('-msoft-float', '-mhard-float')
  48. #-------------------------------------------------------------------------------
  49. # Prepare Device Tree
  50. #-------------------------------------------------------------------------------
  51. DTCSRC = [os.path.join(GetCurrentDir(), 'board/board.dts')]
  52. if not os.path.isdir('rt-thread'):
  53. DTCPATH = [
  54. os.path.join(GetCurrentDir(), RTT_ROOT + '/drivers/include'),
  55. os.path.join(GetCurrentDir(), RTT_ROOT + '/apps/rockchip/%s/platform/dtsi' % rtconfig.CHIP),
  56. ]
  57. else:
  58. DTCPATH = [
  59. os.path.join(GetCurrentDir(), RTT_ROOT + '/drivers/include'),
  60. os.path.join(GetCurrentDir(), RTT_ROOT + '/../platform/dtsi'),
  61. ]
  62. DTCFLAGS = '-b 0 '
  63. DTCFLAGS += '-Wno-interrupt_provider '
  64. DTCFLAGS += '-Wno-unit_address_vs_reg '
  65. DTCFLAGS += '-Wno-avoid_unnecessary_addr_size '
  66. DTCFLAGS += '-Wno-alias_paths '
  67. DTCFLAGS += '-Wno-graph_child_address '
  68. DTCFLAGS += '-Wno-simple_bus_reg '
  69. DTCFLAGS += '-Wno-unique_unit_address '
  70. PrepareDTC(DTCSRC, depend = [], DTCPATH = DTCPATH, DTCFLAGS = DTCFLAGS)
  71. #-------------------------------------------------------------------------------
  72. # Add RuiChing SDK
  73. #-------------------------------------------------------------------------------
  74. if not os.path.isdir('rt-thread'):
  75. objs.extend(
  76. SConscript(RTT_ROOT + '/SConscript',
  77. variant_dir='build/sdk/', duplicate=0)
  78. )
  79. objs.extend(
  80. SConscript(RTT_ROOT + '/apps/rockchip/%s/platform/drivers/SConscript' % rtconfig.CHIP,
  81. variant_dir='build/drivers/', duplicate=0))
  82. elif os.path.isdir('../rt-thread'):
  83. pass
  84. else:
  85. objs.extend(
  86. SConscript('platform/drivers/SConscript',
  87. variant_dir='build/platform/', duplicate=0))
  88. #-------------------------------------------------------------------------------
  89. # Make a building
  90. #-------------------------------------------------------------------------------
  91. DoBuilding(TARGET, objs)