-
Notifications
You must be signed in to change notification settings - Fork 6
/
PlatformBaseClass.py
88 lines (74 loc) · 2.81 KB
/
PlatformBaseClass.py
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
#!python
class PlatformBaseClass(object):
def __init__(self):
self._build_dirs = {}
self._build_binaries = {}
self._build_libraries = {}
self._coverage_excludes = []
self._SetupEnv()
# CPPINCLUDES is added because Scons doesn't support
# `-include` command line, so we will manage it
# manually.
# Returns a cusomized environment
# This environment will take changes from build scripts.
def Env(self):
return self._env
# Must returns a string with the name of your platform
def Name(self):
pass
# Must return a list of target names availble
# to user in commandline.
def TargetNameList(self):
return []
# Must return a list of project names that will be
# built using this platform.
def BuildList(self):
return []
# Should return true or false for each of the
# configurations
def ProfileEnabled(self):
return False
def CppUTestExtensionsEnabled (self):
return False
def CoverageAddExclusion (self, file_path):
self._coverage_excludes.append(file_path)
def BuildListAddBinary (self, build_name, path):
self._build_binaries[build_name] = path
def BuildListAddLibrary (self, build_name, path):
self._build_libraries[build_name] = path
def BuildListAddDirectory (self, build_name, path):
self._build_dirs[build_name] = path
# A method that will be called after all build scripts
# have been loaded.
# Use this call to add your custom Commands.
def PostBuildTargets(self):
pass
@staticmethod
def MakeYCMFlags(target, source, env):
from SCons.Node.FS import File, Dir
from SCons.Node import NodeList
def flatten(xs):
result = []
if isinstance(xs, (list, tuple, NodeList)):
for x in xs:
result.extend(flatten(x))
else:
result.append(xs)
return result
def toPath(f):
if isinstance(f, (File, Dir)):
return str(f.path)
return f
flags = flatten(env['CXXFLAGS']) + flatten(env['CFLAGS']) \
+ ['-D ' + define for define in flatten(env['CPPDEFINES'])] \
+ ['-I ' + toPath(inc) for inc in flatten(env['CPPPATH'])] \
+ ['-l ' + toPath(lib) for lib in flatten(env['LIBS'])] \
+ ['-include ' + toPath(inc) for inc in flatten(env['CINCLUDES'])] \
+ ['-include ' + toPath(inc) for inc in flatten(env['CXXINCLUDES'])]
with open(target[0].path, "w") as flags_file:
flags_file.write("flags={}".format(flags))
class Default(object):
def __init__(self, target):
self._target = target
def __str__(self):
return self._target