[Tools] Add Makefile genernation.
This commit is contained in:
parent
65b7f438ff
commit
ac28dded3e
@ -187,7 +187,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
|||||||
AddOption('--target',
|
AddOption('--target',
|
||||||
dest = 'target',
|
dest = 'target',
|
||||||
type = 'string',
|
type = 'string',
|
||||||
help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses')
|
help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile')
|
||||||
AddOption('--genconfig',
|
AddOption('--genconfig',
|
||||||
dest = 'genconfig',
|
dest = 'genconfig',
|
||||||
action = 'store_true',
|
action = 'store_true',
|
||||||
@ -228,6 +228,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
|||||||
'cb':('keil', 'armcc'),
|
'cb':('keil', 'armcc'),
|
||||||
'ua':('gcc', 'gcc'),
|
'ua':('gcc', 'gcc'),
|
||||||
'cdk':('gcc', 'gcc'),
|
'cdk':('gcc', 'gcc'),
|
||||||
|
'makefile':('gcc', 'gcc'),
|
||||||
'ses' : ('gcc', 'gcc')}
|
'ses' : ('gcc', 'gcc')}
|
||||||
tgt_name = GetOption('target')
|
tgt_name = GetOption('target')
|
||||||
|
|
||||||
@ -824,6 +825,10 @@ def GenTargetProject(program = None):
|
|||||||
from ses import SESProject
|
from ses import SESProject
|
||||||
SESProject(Env)
|
SESProject(Env)
|
||||||
|
|
||||||
|
if GetOption('target') == 'makefile':
|
||||||
|
from makefile import TargetMakefile
|
||||||
|
TargetMakefile(Env)
|
||||||
|
|
||||||
def EndBuilding(target, program = None):
|
def EndBuilding(target, program = None):
|
||||||
import rtconfig
|
import rtconfig
|
||||||
|
|
||||||
|
68
tools/makefile.py
Normal file
68
tools/makefile.py
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from utils import *
|
||||||
|
from utils import _make_path_relative
|
||||||
|
import rtconfig
|
||||||
|
|
||||||
|
def TargetMakefile(env):
|
||||||
|
project = ProjectInfo(env)
|
||||||
|
|
||||||
|
make = open('config.mk', 'w')
|
||||||
|
|
||||||
|
BSP_ROOT = os.path.abspath(env['BSP_ROOT'])
|
||||||
|
RTT_ROOT = os.path.abspath(env['RTT_ROOT'])
|
||||||
|
|
||||||
|
make.write('BSP_ROOT ?= %s\n' % BSP_ROOT.replace('\\', '\\\\'))
|
||||||
|
make.write('RTT_ROOT ?= %s\n' % RTT_ROOT.replace('\\', '\\\\'))
|
||||||
|
make.write('\n')
|
||||||
|
|
||||||
|
cross = os.path.abspath(rtconfig.EXEC_PATH)
|
||||||
|
cross = os.path.join(cross, rtconfig.PREFIX)
|
||||||
|
make.write('CROSS_COMPILE ?=%s' % cross.replace('\\', '\\\\'))
|
||||||
|
make.write('\n')
|
||||||
|
make.write('\n')
|
||||||
|
|
||||||
|
make.write('CFLAGS :=%s' % (rtconfig.CFLAGS))
|
||||||
|
make.write('\n')
|
||||||
|
make.write('AFLAGS :=%s' % (rtconfig.AFLAGS))
|
||||||
|
make.write('\n')
|
||||||
|
make.write('LFLAGS :=%s' % (rtconfig.LFLAGS))
|
||||||
|
make.write('\n')
|
||||||
|
if 'CXXFLAGS' in dir(rtconfig):
|
||||||
|
make.write('CXXFLAGS :=%s' % (rtconfig.CXXFLAGS))
|
||||||
|
make.write('\n')
|
||||||
|
|
||||||
|
make.write('\n')
|
||||||
|
|
||||||
|
Files = project['FILES']
|
||||||
|
Headers = project['HEADERS']
|
||||||
|
CPPDEFINES = project['CPPDEFINES']
|
||||||
|
|
||||||
|
path = ''
|
||||||
|
paths = [_make_path_relative(BSP_ROOT, os.path.normpath(i)) for i in project['CPPPATH']]
|
||||||
|
for item in paths:
|
||||||
|
path += '\t-I%s \\\n' % item
|
||||||
|
|
||||||
|
make.write('CPPPATHS :=')
|
||||||
|
if path[0] == '\t': path = path[1:]
|
||||||
|
length = len(path)
|
||||||
|
if path[length - 2] == '\\': path = path[:length - 2]
|
||||||
|
make.write(path)
|
||||||
|
make.write('\n')
|
||||||
|
make.write('\n')
|
||||||
|
|
||||||
|
defines = ''
|
||||||
|
for item in project['CPPDEFINES']:
|
||||||
|
defines += ' -D%s' % item
|
||||||
|
make.write('DEFINES :=')
|
||||||
|
make.write(defines)
|
||||||
|
make.write('\n')
|
||||||
|
|
||||||
|
src = open('src.mk', 'w')
|
||||||
|
files = [_make_path_relative(BSP_ROOT, os.path.normpath(i)) for i in Files]
|
||||||
|
src.write('SRC_FILES :=\n')
|
||||||
|
for item in files:
|
||||||
|
src.write('SRC_FILES +=%s\n' % item)
|
||||||
|
|
||||||
|
return
|
Loading…
x
Reference in New Issue
Block a user