Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
203 lines (171 loc) · 6.58 KB

File metadata and controls

203 lines (171 loc) · 6.58 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/env python
# Copyright 2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import re
import os
import shutil
import subprocess
# this should only be run with python3
import sys
if sys.version_info[0] < 3:
print('ERROR: must run with python3')
sys.exit(1)
from setuptools import setup, find_packages, Extension
script_dir = os.path.dirname(os.path.realpath(__file__))
pdo_root_dir = os.path.abspath(os.path.join(script_dir, '..'))
install_root_dir = os.environ.get('PDO_HOME', '/opt/pdo')
bin_dir = os.path.join(install_root_dir, "bin")
dat_dir = os.path.join(install_root_dir, "data")
etc_dir = os.path.join(install_root_dir, "etc")
log_dir = os.path.join(install_root_dir, "logs")
key_dir = os.path.join(install_root_dir, "keys")
data_files = [
(bin_dir, []),
(etc_dir, [])
]
# -----------------------------------------------------------------
# set up common flags
#
# note that setuptools does not make it easy to pass custom command
# line parameters so we have to use environment variables
# -----------------------------------------------------------------
debug_flag = int(os.environ.get('PDO_DEBUG_BUILD', 1))
if debug_flag :
print("Build debug")
client_only_flag = int(os.environ.get('BUILD_CLIENT', 0))
if client_only_flag :
print("Build client")
compile_args = [
'-std=c++11',
'-Wno-switch',
'-Wno-unused-function',
'-Wno-unused-variable',
'-D_UNTRUSTED_=1',
]
if debug_flag :
compile_args += ['-g']
swig_flags = ['-c++', '-threads']
if client_only_flag :
common_libs = [
'cpdo-common',
'cpdo-crypto'
]
else :
common_libs = [
'updo-common',
'updo-crypto',
]
compile_defs = [
('_UNTRUSTED_', 1),
('PDO_DEBUG_BUILD', debug_flag),
]
if client_only_flag :
compile_defs += [ ('_CLIENT_ONLY_', 1) ]
# -----------------------------------------------------------------
# set up the crypto module
# -----------------------------------------------------------------
# openssl related stuff
# make sure we have recent enough version
subprocess.run(['pkg-config', 'openssl', '--atleast-version=1.1.0g']).check_returncode()
openssl_cflags = subprocess.check_output(['pkg-config', 'openssl', '--cflags']).decode('ascii').strip().split()
openssl_include_dirs = list(
filter(None, re.split('\s*-I', subprocess.check_output(['pkg-config', 'openssl', '--cflags-only-I']).decode('ascii').strip())))
openssl_libs = list(
filter(None, re.split('\s*-l', subprocess.check_output(['pkg-config', 'openssl', '--libs-only-l']).decode('ascii').strip())))
openssl_lib_dirs = list(
filter(None, re.split('\s*-L', subprocess.check_output(['pkg-config', 'openssl', '--libs-only-L']).decode('ascii').strip())))
crypto_module_files = [
"pdo/common/crypto.i"
]
crypto_include_dirs = [
os.path.join(pdo_root_dir, 'common'),
os.path.join(pdo_root_dir, 'common/crypto'),
os.path.join(pdo_root_dir, 'common/state'),
os.path.join(pdo_root_dir, 'common/packages/base64'),
] + openssl_include_dirs
if not client_only_flag :
crypto_include_dirs += [ os.path.join(os.environ['SGX_SDK'], "include") ]
crypto_libraries = common_libs + openssl_libs
crypto_library_dirs = [
os.path.join(pdo_root_dir, "common", "build"),
] + openssl_lib_dirs
crypto_module = Extension(
name = 'pdo.common._crypto',
sources = crypto_module_files,
swig_opts = swig_flags + openssl_cflags + ['-I%s' % i for i in crypto_include_dirs],
extra_compile_args = compile_args,
include_dirs = crypto_include_dirs,
library_dirs = crypto_library_dirs,
libraries = crypto_libraries,
define_macros = compile_defs,
language = 'c++',
)
# -----------------------------------------------------------------
# -----------------------------------------------------------------
version = subprocess.check_output(
os.path.join(pdo_root_dir, 'bin/get_version')).decode('ascii').strip()
# -----------------------------------------------------------------
# set up the key value module
# -----------------------------------------------------------------
key_value_module_files = [
os.path.join('pdo/common/key_value_swig', 'key_value_swig.i'),
os.path.join('pdo/common/key_value_swig', 'block_store.cpp'),
os.path.join('pdo/common/key_value_swig', 'key_value.cpp'),
os.path.join('pdo/common/key_value_swig', 'swig_utils.cpp'),
os.path.join(pdo_root_dir, 'common','c11_support.cpp'),
]
key_value_include_dirs = [
os.path.join(pdo_root_dir, 'common'),
os.path.join(pdo_root_dir, 'common/crypto'),
os.path.join(pdo_root_dir, 'common/state'),
]
if not client_only_flag :
key_value_include_dirs += [ os.path.join(os.environ['SGX_SDK'], "include") ]
key_value_libraries = common_libs + [ 'pdo-lmdb-block-store', 'lmdb' ] + openssl_libs
key_value_library_dirs = [
os.path.join(pdo_root_dir, "common", "build"),
]
key_value_module = Extension(
name = 'pdo.common.key_value_swig._key_value_swig',
sources = key_value_module_files,
swig_opts = swig_flags,
extra_compile_args = compile_args,
include_dirs = key_value_include_dirs,
library_dirs = key_value_library_dirs,
libraries = key_value_libraries,
define_macros = compile_defs,
language = 'c++',
)
# -----------------------------------------------------------------
# -----------------------------------------------------------------
setup(name='pdo_common_library',
version=version,
description='Common library for private objects',
author='Intel Labs',
packages=find_packages(),
install_requires=[],
data_files=data_files,
namespace_packages=['pdo'],
ext_modules=[crypto_module, key_value_module],
entry_points = {
'console_scripts': [
'pdo-configure-services = pdo.scripts.ConfigureCLI:configure_services',
'pdo-configure-users = pdo.scripts.ConfigureCLI:configure_users',
'pdo-configure-ccf = pdo.scripts.ConfigureCLI:configure_ccf',
'pdo-test-contract = pdo.test.contract:Main',
'pdo-test-request = pdo.test.request:Main',
'pdo-test-storage = pdo.test.storage:Main',
]
}
)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.