-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConscript
173 lines (147 loc) · 6.38 KB
/
SConscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#-*- encoding: utf-8 -*-
#---------------------------------------------------------------------------------
# @File: Sconscript for package
# @Author: liu2guang
# @Date: 2018-09-19 18:07:00(v0.1.0)
#
# @LICENSE: GPLv3: https://github.com/rtpkgs/buildpkg/blob/master/LICENSE.
#
#---------------------------------------------------------------------------------
import os
from building import *
Import('RTT_ROOT')
Import('rtconfig')
#---------------------------------------------------------------------------------
# Package configuration
#---------------------------------------------------------------------------------
PKGNAME = "z_event"
VERSION = "v1.0.0"
DEPENDS = ["PKG_USING_Z_EVENT"]
#---------------------------------------------------------------------------------
# Compile the configuration
#
# SOURCES: Need to compile c and c++ source, auto search when SOURCES is empty
#
# LOCAL_CPPPATH: Local file path (.h/.c/.cpp)
# LOCAL_CCFLAGS: Local compilation parameter
# LOCAL_ASFLAGS: Local assembly parameters
#
# CPPPATH: Global file path (.h/.c/.cpp), auto search when LOCAL_CPPPATH/CPPPATH
# is empty # no pass!!!
# CCFLAGS: Global compilation parameter
# ASFLAGS: Global assembly parameters
#
# CPPDEFINES: Global macro definition
# LOCAL_CPPDEFINES: Local macro definition
#
# LIBS: Specify the static library that need to be linked
# LIBPATH: Specify the search directory for the library file (.lib/.a)
#
# LINKFLAGS: Link options
#---------------------------------------------------------------------------------
SOURCES = Glob('src/*.c')
LOCAL_CPPPATH = []
LOCAL_CCFLAGS = ""
LOCAL_ASFLAGS = ""
CPPPATH = ['inc']
CCFLAGS = ""
ASFLAGS = ""
CPPDEFINES = []
LOCAL_CPPDEFINES = []
LIBS = []
LIBPATH = []
LINKFLAGS = ""
SOURCES_IGNORE = []
CPPPATH_IGNORE = []
#---------------------------------------------------------------------------------
# Feature clip configuration, optional
#---------------------------------------------------------------------------------
if GetDepend(['XXX_USING_FUN1']) == True:
pass
if GetDepend(['XXX_USING_FUN2']) == False:
pass
#---------------------------------------------------------------------------------
# Compiler platform configuration, optional
#---------------------------------------------------------------------------------
if rtconfig.CROSS_TOOL == "gcc":
pass
if rtconfig.CROSS_TOOL == "iar":
pass
if rtconfig.CROSS_TOOL == "keil":
pass
#---------------------------------------------------------------------------------
# Warning: internal related processing, developers do not modify!!!
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
# System variables
#---------------------------------------------------------------------------------
objs = []
root = GetCurrentDir()
ignore = []
#---------------------------------------------------------------------------------
# Add relative path support for CPPPATH and LOCAL_CPPPATH
#---------------------------------------------------------------------------------
for index, value in enumerate(CPPPATH):
if root not in value:
CPPPATH[index] = os.path.join(root, value)
for index, value in enumerate(LOCAL_CPPPATH):
if root not in value:
LOCAL_CPPPATH[index] = os.path.join(root, value)
if rtconfig.CROSS_TOOL == "gcc": # no test
for index, value in enumerate(LIBS):
if value.startswith("lib") == True:
print("Automatic fix the nonstandard lib name, %s -> %s" %
(LIBS[index], LIBS[index].lstrip("lib")))
LIBS[index] = LIBS[index].lstrip("lib")
elif rtconfig.CROSS_TOOL == "keil":
for index, value in enumerate(LIBS):
if value.startswith("lib") == False:
print("Automatic fix the nonstandard lib name, %s -> %s" %
(LIBS[index], "lib" + LIBS[index]))
LIBS[index] = "lib" + LIBS[index]
LIBPATH += [root]
#---------------------------------------------------------------------------------
# Auto search source files and paths, when SOURCES/CPPPATH/LOCAL_CPPPATH are empty
#---------------------------------------------------------------------------------
_SOURCES_IGNORE = SOURCES_IGNORE + ['.git', 'example', 'doc', 'test']
_CPPPATH_IGNORE = CPPPATH_IGNORE + ['test.c', 'example.c']
if not SOURCES:
for dirpath, dirnames, filenames in os.walk(root):
for name in filenames:
suffix = os.path.splitext(name)[1]
if (suffix == '.c' or suffix == '.cpp') and (not suffix in _SOURCES_IGNORE):
SOURCES.append(os.path.join(dirpath, name))
if not LOCAL_CPPPATH and not CPPPATH:
for dirpath, dirnames, filenames in os.walk(root):
for dir in dirnames:
abs_path = os.path.join(dirpath, dir)
if (not ".git" in abs_path) and (not suffix in _SOURCES_IGNORE):
LOCAL_CPPPATH.append(abs_path)
#---------------------------------------------------------------------------------
# Sub target
#---------------------------------------------------------------------------------
list = os.listdir(root)
if GetDepend(DEPENDS):
for d in list:
path = os.path.join(root, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
#---------------------------------------------------------------------------------
# Main target
#---------------------------------------------------------------------------------
objs = DefineGroup(name = PKGNAME, src = SOURCES, depend = DEPENDS,
CPPPATH = CPPPATH,
CCFLAGS = CCFLAGS,
ASFLAGS = ASFLAGS,
LOCAL_CPPPATH = LOCAL_CPPPATH,
LOCAL_CCFLAGS = LOCAL_CCFLAGS,
LOCAL_ASFLAGS = LOCAL_ASFLAGS,
CPPDEFINES = CPPDEFINES,
LOCAL_CPPDEFINES = LOCAL_CPPDEFINES,
LIBS = LIBS,
LIBPATH = LIBPATH,
LINKFLAGS = LINKFLAGS)
Return("objs")
#---------------------------------------------------------------------------------
# End
#---------------------------------------------------------------------------------