/
SConscript
143 lines (119 loc) · 5.1 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
# -*- mode: python; -*-
#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#
import os
Import('CfgmEnv')
env = CfgmEnv.Clone()
setup_sources = [
'setup.py',
'requirements.txt',
'test-requirements.txt',
'MANIFEST.in',
]
setup_sources_rules = []
for file in setup_sources:
setup_sources_rules.append(env.Install(Dir('.'), File(file).srcnode()))
local_sources = [
'__init__.py',
'zkclient.py',
'exceptions.py',
'utils.py',
'rbaclib.py',
'jsonutils.py',
'imid.py',
'svc_info.py',
'vnc_cpu_info.py',
'rest.py',
'vnc_plugin_base.py',
'vnc_extensions.py',
'importutils.py',
'analytics_client.py',
'vnc_cassandra.py',
'vnc_kombu.py',
'vnc_db.py',
'dependency_tracker.py',
'vnc_api_stats.py',
'ssl_adapter.py',
'vnc_cgitb.py',
]
local_sources_rules = []
for file in local_sources:
local_sources_rules.append(env.Install("cfgm_common", File(file).srcnode()))
ifmap_sources = [ 'ifmap' ]
ifmap_sources_rules = []
for file in ifmap_sources:
ifmap_sources_rules.append(env.Install("cfgm_common/", "#/third_party/ifmap-python-client/" + file))
test_sources = [
'tests/__init__.py',
'tests/test_analytics_client.py',
'tests/test_importutils.py',
'tests/fake.py',
'tests/test_suite.py',
'tests/test_cache_container.py'
]
test_sources_rules = []
for file in test_sources:
test_sources_rules.append(env.Install("cfgm_common/tests/", File(file)))
# install in common so that unit tests can run from src or build
test_sources_rules.append(env.Install("tests", Glob("#controller/src/config/common/tests/*")))
pkg = [env.SandeshGenPy('#controller/src/config/uve/service_instance.sandesh', 'cfgm_common/uve/', False),
env.SandeshGenPy('#controller/src/config/uve/vnc_api.sandesh', 'cfgm_common/uve/', False),
env.SandeshGenPy('#controller/src/config/uve/virtual_machine.sandesh', 'cfgm_common/uve/', False),
env.SandeshGenPy('#controller/src/config/uve/virtual_network.sandesh', 'cfgm_common/uve/', False),
env.SandeshGenPy('#controller/src/config/uve/physical_router.sandesh', 'cfgm_common/uve/', False),
env.SandeshGenPy('#controller/src/config/uve/acl.sandesh', 'cfgm_common/uve/', False),
env.SandeshGenPy('#controller/src/config/uve/cfgm_cpuinfo.sandesh', 'cfgm_common/uve/', False),
]
# Generate the sandesh cpuinfo from base
cpu_info_pkg = env.SandeshGenPy('#controller/src/base/sandesh/cpuinfo.sandesh', 'cfgm_common/uve/cfgm_cpuinfo/', False)
process_info_pkg = env.SandeshGenPy('#controller/src/base/sandesh/process_info.sandesh', 'cfgm_common/uve/cfgm_cpuinfo/', False)
env.Depends(cpu_info_pkg, pkg)
env.Depends(process_info_pkg, pkg)
rel_path = Dir('cfgm_common').path
def BuildInfoAction(target, source, env):
env.GenerateBuildInfoPyCode(path=rel_path)
build_info_rules = [env.Command(target='buildinfo.py', source = None, action=BuildInfoAction)]
sdist_depends = []
sdist_depends.extend(setup_sources_rules)
sdist_depends.extend(local_sources_rules)
sdist_depends.extend(ifmap_sources_rules)
sdist_depends.extend(test_sources_rules)
sdist_depends.extend(pkg)
sdist_depends.extend(cpu_info_pkg)
sdist_depends.extend(process_info_pkg)
sdist_depends.extend(build_info_rules)
cd_cmd = 'cd ' + Dir('.').path + ' && '
# TODO: deprecate
sdist_gen = env.Command('dist/cfgm_common-0.1dev.tar.gz',
'setup.py', cd_cmd + 'python setup.py sdist')
env.Depends(sdist_gen, sdist_depends)
env.Default(sdist_gen)
def BuildPyTestSetup(env, target, source):
file = open(target[0].abspath, 'w')
file.write("[easy_install]\nfind_links =")
for pkg in source:
dependency = env.File(pkg)
file.write(" %s" % os.path.dirname(dependency.abspath))
file.write("\n")
file.close()
return
def GeneratePyTestSetup(env, targets, source):
"""
Generate a setup.cfg file that contains a list of directories
where dependent packages can be found. The fact that package directory
list is being given as a source automatically adds them as dependencies.
"""
target = env.File('setup.cfg')
return env.Command(target=target, source=source, action=BuildPyTestSetup);
env.Append(BUILDERS = {'PythonTestSetup': GeneratePyTestSetup})
test_sources += env.PythonTestSetup(source=pkg)
test = env.Command('test.log', test_sources,
cd_cmd + 'python setup.py test')
#env.Alias('controller/src/config/common:test', test)
if 'install' in BUILD_TARGETS:
install_cmd = env.Command(None, 'setup.py',
cd_cmd + 'python setup.py install %s' %
env['PYTHON_INSTALL_OPT'])
env.Depends(install_cmd, sdist_depends)
env.Alias('install', install_cmd)