2013-01-08 22:40:58 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import rtconfig
|
|
|
|
|
|
|
|
if os.getenv('RTT_ROOT'):
|
|
|
|
RTT_ROOT = os.getenv('RTT_ROOT')
|
|
|
|
else:
|
|
|
|
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
|
|
|
|
|
|
|
|
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
|
|
|
from building import *
|
|
|
|
|
2013-03-01 22:43:33 +08:00
|
|
|
env = Environment(TARGET_ARCH='x86')
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
Export('RTT_ROOT')
|
|
|
|
Export('rtconfig')
|
|
|
|
|
2013-01-22 16:57:47 +08:00
|
|
|
if rtconfig.PLATFORM == 'cl':
|
|
|
|
TARGET = 'rtthread-win32.' + rtconfig.TARGET_EXT
|
|
|
|
|
|
|
|
libs = Split('''
|
|
|
|
winmm
|
|
|
|
gdi32
|
|
|
|
winspool
|
|
|
|
comdlg32
|
|
|
|
advapi32
|
|
|
|
shell32
|
|
|
|
ole32
|
|
|
|
oleaut32
|
|
|
|
uuid
|
|
|
|
odbc32
|
|
|
|
odbccp32
|
|
|
|
''')
|
|
|
|
definitions = Split('''
|
|
|
|
WIN32
|
|
|
|
_DEBUG
|
|
|
|
_CONSOLE
|
|
|
|
MSVC
|
|
|
|
''')
|
|
|
|
env.Append(CCFLAGS=rtconfig.CFLAGS)
|
|
|
|
env.Append(LINKFLAGS=rtconfig.LFLAGS)
|
|
|
|
env['LIBS']=libs
|
|
|
|
env['CPPDEFINES']=definitions
|
2013-02-26 16:03:08 +08:00
|
|
|
elif rtconfig.PLATFORM == 'mingw':
|
|
|
|
libs = Split('''
|
|
|
|
winmm
|
|
|
|
gdi32
|
|
|
|
winspool
|
|
|
|
comdlg32
|
|
|
|
advapi32
|
|
|
|
shell32
|
|
|
|
ole32
|
|
|
|
oleaut32
|
|
|
|
uuid
|
|
|
|
odbc32
|
|
|
|
odbccp32
|
|
|
|
''')
|
|
|
|
TARGET = 'rtthread-win32.' + rtconfig.TARGET_EXT
|
2019-10-22 16:01:46 +08:00
|
|
|
DefaultEnvironment(tools=[])
|
2013-02-26 16:03:08 +08:00
|
|
|
env = Environment(tools = ['mingw'],
|
|
|
|
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
|
|
|
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
|
|
|
|
AR = rtconfig.AR, ARFLAGS = '-rc',
|
|
|
|
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
|
|
|
env['LIBS']=libs
|
|
|
|
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
2013-09-07 15:01:28 +08:00
|
|
|
elif rtconfig.CROSS_TOOL == 'clang-analyze':
|
|
|
|
TARGET = 'rtthread'
|
|
|
|
env = Environment(toolpath=[os.path.join(RTT_ROOT, 'tools', 'tools')],
|
|
|
|
tools = [rtconfig.CROSS_TOOL])
|
2013-01-22 16:57:47 +08:00
|
|
|
else:
|
|
|
|
TARGET = 'rtthread'
|
2013-07-22 23:02:03 +08:00
|
|
|
env['CC']=rtconfig.CC
|
2013-01-22 16:57:47 +08:00
|
|
|
env.Append(CCFLAGS=rtconfig.CFLAGS)
|
|
|
|
env.Append(LINKFLAGS=rtconfig.LFLAGS)
|
2019-07-19 16:14:02 +08:00
|
|
|
env.Append(LIBS=['winmm'])
|
2013-01-22 16:57:47 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
# prepare building environment
|
|
|
|
|
2013-12-08 20:39:19 +08:00
|
|
|
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2013-02-27 00:37:57 +08:00
|
|
|
def ObjRemove(objs, remove):
|
|
|
|
for item in objs:
|
2018-02-06 20:07:28 +08:00
|
|
|
# print(type(item), os.path.basename(str(item)) )
|
2013-02-27 00:37:57 +08:00
|
|
|
if os.path.basename(str(item)) in remove:
|
|
|
|
objs.remove(item)
|
|
|
|
return
|
|
|
|
|
2021-03-31 21:38:19 +08:00
|
|
|
def ProjectRemove(group, remove):
|
|
|
|
global Projects
|
|
|
|
for item in Projects:
|
|
|
|
if item['name'] == group:
|
|
|
|
for src in item['src']:
|
|
|
|
if os.path.basename(str(src)) in remove:
|
|
|
|
# print(type(src), os.path.basename(str(src)) )
|
|
|
|
item['src'].remove(src)
|
|
|
|
return
|
|
|
|
|
|
|
|
ObjRemove(objs, ['components.obj', 'components.o', 'components.c'])
|
|
|
|
ProjectRemove('Kernel', ['components.obj', 'components.o', 'components.c'])
|
|
|
|
|
2013-02-27 00:37:57 +08:00
|
|
|
# build program -shared
|
|
|
|
if GetDepend('RT_USING_MODULE'):
|
|
|
|
# Remove module.c in $RTT_ROOT/src
|
2015-09-30 16:26:40 +08:00
|
|
|
ObjRemove(objs, ['module.obj', 'module.o', 'module.c'])
|
2013-02-27 00:37:57 +08:00
|
|
|
|
|
|
|
AddOption('--def',
|
|
|
|
dest='def',
|
2013-02-27 02:27:19 +08:00
|
|
|
action='store_true',
|
|
|
|
default=False,
|
2020-03-06 21:46:21 +08:00
|
|
|
help='create rtthread.def of rtthread.dll on windows')
|
2013-02-27 02:27:19 +08:00
|
|
|
if GetOption('def'):
|
2013-10-01 17:43:38 +08:00
|
|
|
if rtconfig.PLATFORM == 'mingw':
|
|
|
|
env['LINKFLAGS'] = rtconfig.DEFFILE_LFLAGS
|
|
|
|
else:
|
2015-09-30 16:26:40 +08:00
|
|
|
rtconfig.POST_ACTION = 'python createdef.py $TARGET rtthread.def'
|
2013-02-27 02:27:19 +08:00
|
|
|
|
2013-10-01 17:43:38 +08:00
|
|
|
program = env.Program(TARGET, objs)
|
2013-02-27 02:27:19 +08:00
|
|
|
else:
|
2013-02-27 00:37:57 +08:00
|
|
|
if rtconfig.PLATFORM == 'cl':
|
|
|
|
objs += ['rtthread.def']
|
2013-02-27 02:04:43 +08:00
|
|
|
elif rtconfig.PLATFORM == 'mingw':
|
|
|
|
rtconfig.POST_ACTION = 'del /Q rtthread.lib \n rename librtthread.a rtthread.lib\n'
|
|
|
|
# rtconfig.POST_ACTION = 'lib /machine:i386 /def:rtthread.def /out:rtthread.lib'
|
2013-02-27 00:37:57 +08:00
|
|
|
env.SharedLibrary("rtthread.dll", objs)
|
|
|
|
program = env.Program(TARGET, 'dummy.c', LIBS='rtthread', LIBPATH='.')
|
|
|
|
|
|
|
|
else:
|
|
|
|
program = env.Program(TARGET, objs)
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
# end building
|
|
|
|
EndBuilding(TARGET, program)
|