2 |
${pkgname}
3 |
4 |
12 |
13 |
24 |
25 |
你需要在这里对项目进行简单的介绍,描述项目背景,当前现状、功能特点等等...
26 |
27 |
28 | > 下面需要自由发挥了
29 |
--------------------------------------------------------------------------------
/templates/template-sconscript-example.py:
--------------------------------------------------------------------------------
1 | import os
2 | from building import *
3 |
4 | # get current dir path
5 | cwd = GetCurrentDir()
6 |
7 | # init src and inc vars
8 | src = []
9 | inc = []
10 |
11 | # add libcsv common include
12 | inc = inc + [cwd]
13 |
14 | # add libcsv basic code
15 | src = src + Glob('./*.c')
16 |
17 | # add group to IDE project
18 | objs = DefineGroup('${pkgname}-${version}', src, depend = ['${pkgname_letter}_USING_DEMO'], CPPPATH = inc)
19 |
20 | Return('objs')
21 |
--------------------------------------------------------------------------------
/templates/template-sconscript.py:
--------------------------------------------------------------------------------
1 | #-*- encoding: utf-8 -*-
2 | #---------------------------------------------------------------------------------
3 | # @File: Sconscript for package
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 | #---------------------------------------------------------------------------------
16 | # Package configuration
17 | #---------------------------------------------------------------------------------
18 | PKGNAME = "${pkgname}"
19 | VERSION = "${version}"
20 | DEPENDS = ["PKG_USING_${pkgname_letter}"]
21 |
22 | #---------------------------------------------------------------------------------
23 | # Compile the configuration
24 | #
25 | # SOURCES: Need to compile c and c++ source, auto search when SOURCES is empty
26 | #
27 | # LOCAL_CPPPATH: Local file path (.h/.c/.cpp)
28 | # LOCAL_CCFLAGS: Local compilation parameter
29 | # LOCAL_ASFLAGS: Local assembly parameters
30 | #
31 | # CPPPATH: Global file path (.h/.c/.cpp), auto search when LOCAL_CPPPATH/CPPPATH
32 | # is empty # no pass!!!
33 | # CCFLAGS: Global compilation parameter
34 | # ASFLAGS: Global assembly parameters
35 | #
36 | # CPPDEFINES: Global macro definition
37 | # LOCAL_CPPDEFINES: Local macro definition
38 | #
39 | # LIBS: Specify the static library that need to be linked
40 | # LIBPATH: Specify the search directory for the library file (.lib/.a)
41 | #
42 | # LINKFLAGS: Link options
43 | #---------------------------------------------------------------------------------
44 | SOURCES = []
45 |
46 | LOCAL_CPPPATH = []
47 | LOCAL_CCFLAGS = ""
48 | LOCAL_ASFLAGS = ""
49 |
50 | CPPPATH = []
51 | CCFLAGS = ""
52 | ASFLAGS = ""
53 |
54 | CPPDEFINES = []
55 | LOCAL_CPPDEFINES = []
56 |
57 | LIBS = []
58 | LIBPATH = []
59 |
60 | LINKFLAGS = ""
61 |
62 | SOURCES_IGNORE = []
63 | CPPPATH_IGNORE = []
64 |
65 | #---------------------------------------------------------------------------------
66 | # Feature clip configuration, optional
67 | #---------------------------------------------------------------------------------
68 | if GetDepend(['XXX_USING_FUN1']) == True:
69 | pass
70 |
71 | if GetDepend(['XXX_USING_FUN2']) == False:
72 | pass
73 |
74 | #---------------------------------------------------------------------------------
75 | # Compiler platform configuration, optional
76 | #---------------------------------------------------------------------------------
77 | if rtconfig.CROSS_TOOL == "gcc":
78 | pass
79 |
80 | if rtconfig.CROSS_TOOL == "iar":
81 | pass
82 |
83 | if rtconfig.CROSS_TOOL == "keil":
84 | pass
85 |
86 | #---------------------------------------------------------------------------------
87 | # Warning: internal related processing, developers do not modify!!!
88 | #---------------------------------------------------------------------------------
89 |
90 | #---------------------------------------------------------------------------------
91 | # System variables
92 | #---------------------------------------------------------------------------------
93 | objs = []
94 | root = GetCurrentDir()
95 | ignore = []
96 |
97 | #---------------------------------------------------------------------------------
98 | # Add relative path support for CPPPATH and LOCAL_CPPPATH
99 | #---------------------------------------------------------------------------------
100 | for index, value in enumerate(CPPPATH):
101 | if string.find(value, root) == False:
102 | CPPPATH[index] = os.path.join(root, value)
103 |
104 | for index, value in enumerate(LOCAL_CPPPATH):
105 | if string.find(value, root) == False:
106 | LOCAL_CPPPATH[index] = os.path.join(root, value)
107 |
108 | if rtconfig.CROSS_TOOL == "gcc": # no test
109 | for index, value in enumerate(LIBS):
110 | if value.startswith("lib") == True:
111 | print("Automatic fix the nonstandard lib name, %s -> %s" %
112 | (LIBS[index], LIBS[index].lstrip("lib")))
113 | LIBS[index] = LIBS[index].lstrip("lib")
114 |
115 | elif rtconfig.CROSS_TOOL == "keil":
116 | for index, value in enumerate(LIBS):
117 | if value.startswith("lib") == False:
118 | print("Automatic fix the nonstandard lib name, %s -> %s" %
119 | (LIBS[index], "lib" + LIBS[index]))
120 | LIBS[index] = "lib" + LIBS[index]
121 |
122 | LIBPATH += [root]
123 |
124 | #---------------------------------------------------------------------------------
125 | # Auto search source files and paths, when SOURCES/CPPPATH/LOCAL_CPPPATH are empty
126 | #---------------------------------------------------------------------------------
127 | _SOURCES_IGNORE = SOURCES_IGNORE + ${list_ignore_src}
128 | _CPPPATH_IGNORE = CPPPATH_IGNORE + ${list_ignore_inc}
129 |
130 | if not SOURCES:
131 | for dirpath, dirnames, filenames in os.walk(root):
132 | for name in filenames:
133 | suffix = os.path.splitext(name)[1]
134 | if (suffix == '.c' or suffix == '.cpp') and (not name in _SOURCES_IGNORE):
135 | SOURCES.append(os.path.join(dirpath, name))
136 |
137 | if not LOCAL_CPPPATH and not CPPPATH:
138 | for dirpath, dirnames, filenames in os.walk(root):
139 | for dir in dirnames:
140 | abs_path = os.path.join(dirpath, dir)
141 | if (not ".git" in abs_path) and (not dir in _SOURCES_IGNORE):
142 | LOCAL_CPPPATH.append(abs_path)
143 |
144 | #---------------------------------------------------------------------------------
145 | # Sub target
146 | #---------------------------------------------------------------------------------
147 | list = os.listdir(root)
148 | if GetDepend(DEPENDS):
149 | for d in list:
150 | path = os.path.join(root, d)
151 | if os.path.isfile(os.path.join(path, 'SConscript')):
152 | objs = objs + SConscript(os.path.join(d, 'SConscript'))
153 |
154 | #---------------------------------------------------------------------------------
155 | # Main target
156 | #---------------------------------------------------------------------------------
157 | objs += DefineGroup(name = PKGNAME, src = SOURCES, depend = DEPENDS,
158 | CPPPATH = CPPPATH,
159 | CCFLAGS = CCFLAGS,
160 | ASFLAGS = ASFLAGS,
161 | LOCAL_CPPPATH = LOCAL_CPPPATH,
162 | LOCAL_CCFLAGS = LOCAL_CCFLAGS,
163 | LOCAL_ASFLAGS = LOCAL_ASFLAGS,
164 | CPPDEFINES = CPPDEFINES,
165 | LOCAL_CPPDEFINES = LOCAL_CPPDEFINES,
166 | LIBS = LIBS,
167 | LIBPATH = LIBPATH,
168 | LINKFLAGS = LINKFLAGS)
169 |
170 | Return("objs")
171 | #---------------------------------------------------------------------------------
172 | # End
173 | #---------------------------------------------------------------------------------
174 |
--------------------------------------------------------------------------------