SConscript 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #-*- encoding: utf-8 -*-
  2. #---------------------------------------------------------------------------------
  3. # @File: Sconscript
  4. # @Author: liu2guang
  5. # @Date: 2018-09-19 18:07:00(v0.1.0)
  6. #
  7. # @LICENSE: GPLv3: https://github.com/rtpkgs/buildpkg/blob/master/LICENSE.
  8. #
  9. #---------------------------------------------------------------------------------
  10. import os
  11. from building import *
  12. Import('RTT_ROOT')
  13. Import('rtconfig')
  14. #---------------------------------------------------------------------------------
  15. # Package configuration
  16. #---------------------------------------------------------------------------------
  17. PKGNAME = "button"
  18. VERSION = "v1.0.0"
  19. DEPENDS = ["PKG_USING_BUTTON"]
  20. #---------------------------------------------------------------------------------
  21. # Compile the configuration
  22. #---------------------------------------------------------------------------------
  23. SOURCES = ["button.c"]
  24. CPPPATH = []
  25. CCFLAGS = " -std=gnu99" # no pass
  26. ASFLAGS = ""
  27. LOCAL_CPPPATH = [""]
  28. LOCAL_CCFLAGS = " -std=gnu99"
  29. LOCAL_ASFLAGS = ""
  30. CPPDEFINES = ["CPPDEFINES"]
  31. LOCAL_CPPDEFINES = ["LOCAL_CPPDEFINES"]
  32. LIBS = ["libmm"] # keil libmm, gcc mm
  33. LIBPATH = [os.path.join(GetCurrentDir(), "")]
  34. LINKFLAGS = ""
  35. #---------------------------------------------------------------------------------
  36. # Feature clip configuration, optional
  37. #---------------------------------------------------------------------------------
  38. #---------------------------------------------------------------------------------
  39. # Compiler platform configuration, optional
  40. #---------------------------------------------------------------------------------
  41. if rtconfig.CROSS_TOOL == "gcc":
  42. pass
  43. if rtconfig.CROSS_TOOL == "iar":
  44. pass
  45. if rtconfig.CROSS_TOOL == "keil":
  46. pass
  47. #---------------------------------------------------------------------------------
  48. # Warning: internal related processing, developers do not modify!!!
  49. #---------------------------------------------------------------------------------
  50. #---------------------------------------------------------------------------------
  51. # System variables
  52. #---------------------------------------------------------------------------------
  53. objs = []
  54. root = GetCurrentDir()
  55. #---------------------------------------------------------------------------------
  56. # Add relative path support for CPPPATH and LOCAL_CPPPATH
  57. #---------------------------------------------------------------------------------
  58. for index, value in enumerate(CPPPATH):
  59. if string.find(value, root) == False:
  60. CPPPATH[index] = os.path.join(root, value)
  61. for index, value in enumerate(LOCAL_CPPPATH):
  62. if string.find(value, root) == False:
  63. LOCAL_CPPPATH[index] = os.path.join(root, value)
  64. if rtconfig.CROSS_TOOL == "gcc": # no test
  65. for index, value in enumerate(LIBS):
  66. if value.startswith("lib") == True:
  67. print("Automatic fix the nonstandard lib name, %s -> %s" % (LIBS[index], LIBS[index].lstrip("lib")))
  68. LIBS[index] = LIBS[index].lstrip("lib")
  69. elif rtconfig.CROSS_TOOL == "keil":
  70. for index, value in enumerate(LIBS):
  71. if value.startswith("lib") == False:
  72. print("Automatic fix the nonstandard lib name, %s -> %s" % (LIBS[index], "lib" + LIBS[index]))
  73. LIBS[index] = "lib" + LIBS[index]
  74. LIBPATH += [root]
  75. #---------------------------------------------------------------------------------
  76. # Sub target
  77. #---------------------------------------------------------------------------------
  78. list = os.listdir(root)
  79. if GetDepend(DEPENDS):
  80. for d in list:
  81. path = os.path.join(root, d)
  82. if os.path.isfile(os.path.join(path, 'SConscript')):
  83. objs = objs + SConscript(os.path.join(d, 'SConscript'))
  84. #---------------------------------------------------------------------------------
  85. # Main target
  86. #---------------------------------------------------------------------------------
  87. objs = DefineGroup(name = PKGNAME, src = SOURCES, depend = DEPENDS,
  88. CPPPATH = CPPPATH,
  89. CCFLAGS = CCFLAGS,
  90. ASFLAGS = ASFLAGS,
  91. LOCAL_CPPPATH = LOCAL_CPPPATH,
  92. LOCAL_CCFLAGS = LOCAL_CCFLAGS,
  93. LOCAL_ASFLAGS = LOCAL_ASFLAGS,
  94. CPPDEFINES = CPPDEFINES,
  95. LOCAL_CPPDEFINES = LOCAL_CPPDEFINES,
  96. LIBS = LIBS,
  97. LIBPATH = LIBPATH,
  98. LINKFLAGS = LINKFLAGS)
  99. Return("objs")