SConstruct 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. os.path.join(GetCurrentDir(), RTT_ROOT + '/apps/rockchip/%s/platform/dtsi/rockchip' % rtconfig.CHIP)
  57. ]
  58. else:
  59. DTCPATH = [
  60. os.path.join(GetCurrentDir(), RTT_ROOT + '/drivers/include'),
  61. os.path.join(GetCurrentDir(), RTT_ROOT + '/../platform/dtsi/'),
  62. os.path.join(GetCurrentDir(), RTT_ROOT + '/../platform/dtsi/rockchip')
  63. ]
  64. DTCFLAGS = '-b 0 '
  65. DTCFLAGS += '-Wno-interrupt_provider '
  66. DTCFLAGS += '-Wno-unit_address_vs_reg '
  67. DTCFLAGS += '-Wno-avoid_unnecessary_addr_size '
  68. DTCFLAGS += '-Wno-alias_paths '
  69. DTCFLAGS += '-Wno-graph_child_address '
  70. DTCFLAGS += '-Wno-simple_bus_reg '
  71. DTCFLAGS += '-Wno-unique_unit_address '
  72. PrepareDTC(DTCSRC, depend = [], DTCPATH = DTCPATH, DTCFLAGS = DTCFLAGS)
  73. #-------------------------------------------------------------------------------
  74. # Add RuiChing SDK
  75. #-------------------------------------------------------------------------------
  76. if not os.path.isdir('rt-thread'):
  77. objs.extend(
  78. SConscript(RTT_ROOT + '/SConscript',
  79. variant_dir='build/sdk/', duplicate=0)
  80. )
  81. objs.extend(
  82. SConscript(RTT_ROOT + '/apps/rockchip/%s/platform/drivers/SConscript' % rtconfig.CHIP,
  83. variant_dir='build/drivers/', duplicate=0))
  84. elif os.path.isdir('../rt-thread'):
  85. pass
  86. else:
  87. objs.extend(
  88. SConscript('platform/drivers/SConscript',
  89. variant_dir='build/platform/', duplicate=0))
  90. #-------------------------------------------------------------------------------
  91. # Make a building
  92. #-------------------------------------------------------------------------------
  93. DoBuilding(TARGET, objs)