-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrakefile
1642 lines (1559 loc) · 54.4 KB
/
drakefile
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import collections
import os
import sys
from itertools import chain
import drake
import drake.cxx
import drake.cxx.boost
import drake.docker
import drake.valgrind
from drake.gnu import GNUBuilder
MACOSX_DEPLOYMENT_TARGET = '10.7'
archs = None
athena = None
aws = None
boost = None
config = None
cryptography = None
curl_config = None
curl_lib = None
cxx_toolkit = None
das = None
dropbox = None
elle = None
libarchive_config = None
libarchive_lib = None
nbd = None
openssl_config = None
openssl_lib_crypto = None
openssl_lib_ssl = None
openssl_libs_eay = []
protocol = None
python3 = None
reactor = None
rule_check = None
rule_tests = None
valgrind = None
valgrind_suppressions = None
zlib_config = None
zlib_lib = None
with open(str(drake.path_source('drake-utils.py')), 'r') as f:
exec(f.read(), globals(), globals())
def set_archs(value):
global archs
archs = value
def set_boost(value):
global boost
boost = value
def set_python3(value):
global python3
python3 = value
def set_valgrind(value):
global valgrind
valgrind = value
def set_cxx_toolkit(value):
global cxx_toolkit
cxx_toolkit = value
def configure(cxx_toolkit = None,
cxx_toolkit_host = None,
cxx_config = drake.cxx.Config(),
archs = [],
fuse = None,
production_build = False,
boost = None,
python3 = None,
python_version = None,
enable_cryptographic_rotation = False,
prefix = False,
valgrind: drake.valgrind.Valgrind = None,
valgrind_tests: bool = False,
build_openssl_eay = False,
cryptography_python = True,
codesign = False,
):
global athena
global aws
global config
global cryptography
global das
global dropbox
global elle
global nbd
global protocol
global reactor
global curl_config, curl_lib
global openssl_config, openssl_lib_ssl, openssl_lib_crypto, openssl_libs_eay
global zlib_config, zlib_lib
global libarchive_config, libarchive_lib
global valgrind_suppressions
## ------------- ##
## Architectures ##
## ------------- ##
if archs:
if cxx_toolkit.os is not drake.os.ios:
raise Exception("building for multiple architectures only supported on "\
"iOS")
set_archs(archs)
## -------- ##
## Valgrind ##
## -------- ##
set_valgrind(valgrind)
valgrind_suppressions = drake.node('valgrind.suppr')
## ------- ##
## Toolkit ##
## ------- ##
config = drake.cxx.Config()
config.add_local_include_path('src')
config.add_local_include_path('range-v3/include')
cxx_config = config + cxx_config
cxx_toolkit = cxx_toolkit or drake.cxx.Toolkit()
if cxx_toolkit.os in [drake.os.macos] and cxx_toolkit.kind == drake.cxx.GccToolkit.Kind.clang:
cxx_config.use_local_libcxx = True
cxx_toolkit_host = cxx_toolkit_host or cxx_toolkit
set_cxx_toolkit(cxx_toolkit)
if cxx_toolkit.os is drake.os.ios:
print('Cross compiling for iOS')
windows = cxx_toolkit.os is drake.os.windows
if prefix is not False:
prefix = drake.Path(prefix)
if python3 is not False:
if python_version is None:
python_version = (drake.Version(3, 6),
drake.Version(3, 5),
drake.Version(3, 4),
drake.Version(3, 3),
drake.Version(3, 2))
elif not isinstance(python_version, collections.Iterable):
python_version = (python_version,)
if python3 is None and drake.cxx.PkgConfig.available:
def versions():
for v in python_version:
yield ('python', v)
yield ('python3', v) # CentOS
yield ('python-%s' % v, v) # Gentoo
for pkg_name, version in versions():
pkg = drake.cxx.PkgConfig(pkg_name, version = version)
if pkg.exists:
python3 = pkg.prefix
break
include_dir = list(itertools.chain(
('include',),
*(('include/python%s' % v,
'include/python%sm' % v) for v in python_version)))
python3 = drake.cxx.find_library(
'pyconfig.h',
prefix = python3,
include_dir = include_dir)
python_version = cxx_toolkit.preprocess('''\
#include <patchlevel.h>
PY_MAJOR_VERSION
PY_MINOR_VERSION''', config = python3)
python_version = python_version.split('\n')[-3:-1]
python_version = drake.Version(*map(int, python_version))
if windows:
python_bin = 'python.exe'
else:
python_bin = 'bin/python%s' % python_version
python3.python_interpreter = python3.prefix / python_bin
python3.version = python_version
else:
python3 = None
set_python3(python3)
## -------- ##
## Patchelf ##
## -------- ##
patchelf_version = drake.Version(0, 9)
patchelf_basename = 'patchelf-%s' % patchelf_version
patchelf_url = \
'https://nixos.org/releases/patchelf/{}/{}.tar.bz2'.format(
patchelf_basename, patchelf_basename)
patchelf_tarball = \
drake.node('patchelf/%s.tar.bz2' % patchelf_basename)
patchelf_configure = \
drake.node('patchelf/%s/configure' % patchelf_basename)
patchelf_prefix = drake.path_build('patchelf')
patchelf_prefix_absolute = drake.path_root() / patchelf_prefix
patchelf = drake.node('patchelf/bin/patchelf')
drake.HTTPDownload(
patchelf_url,
patchelf_tarball,
fingerprint = 'd02687629c7e1698a486a93a0d607947',
)
drake.TarballExtractor(
patchelf_tarball,
targets = ['%s/configure' % patchelf_basename],
)
GNUBuilder(
cxx_toolkit,
configure = patchelf_configure,
configure_args = [
'--prefix=%s' % patchelf_prefix_absolute,
'CXX=%s' % ' '.join(cxx_toolkit_host.command_cxx),
],
targets = [patchelf],
sources = [],
)
if cxx_toolkit.os not in [drake.os.windows, drake.os.ios]:
cxx_toolkit.patchelf = patchelf
drake.Rule('patchelf') << patchelf
## ---- ##
## Zlib ##
## ---- ##
zlib_version = '1.2.11'
zlib_basename = 'zlib-%s' % zlib_version
zlib_tarball = drake.node('zlib/%s.tar.gz' % zlib_basename)
zlib_prefix = drake.Path('zlib')
zlib_build = zlib_prefix / zlib_basename
zlib_configure = drake.node(zlib_build / 'configure')
# They don't always update their configure (which is not generated
# by Autoconf). However, the zlib.h file is updated with the
# version number.
zlib_main_header = drake.node(zlib_build / 'zlib.h')
zlib_url = 'http://zlib.net/%s.tar.gz' % zlib_basename
drake.HTTPDownload(
zlib_url,
zlib_tarball,
fingerprint = '1c9f62f0778697a09d36121ead88e08e'
)
drake.TarballExtractor(
zlib_tarball,
targets = ['%s/%s' % (zlib_basename, 'configure'),
'%s/%s' % (zlib_basename, 'zlib.h'),
],
)
zlib_env = {}
if windows:
# XXX only for mingw
zlib_makefile = 'win32/Makefile.gcc'
zlib_lib = drake.cxx.StaticLib('zlib/lib/libz.a')
zlib_configure_call = None
zlib_configure_args = ['--static']
else:
zlib_env['CC'] = ' '.join(cxx_toolkit.command_c)
zlib_env['CFLAGS'] = '-fPIC -w'
zlib_makefile = None
zlib_configure_call = zlib_configure
zlib_configure_args = []
if cxx_toolkit.os is drake.os.macos:
zlib_lib = drake.cxx.DynLib('zlib/lib/libz.%s.dylib' % zlib_version)
elif cxx_toolkit.os in [drake.os.linux]:
zlib_lib = drake.cxx.DynLib('zlib/lib/libz.so.1')
elif cxx_toolkit.os is drake.os.android:
zlib_lib = drake.cxx.StaticLib('zlib/lib/libz.a')
zlib_configure_args = ['--static']
elif cxx_toolkit.os is drake.os.ios:
zlib_lib = drake.cxx.StaticLib('zlib/lib/libz.a')
zlib_arch_str = ''
for arch in archs:
zlib_arch_str += '-arch %s ' % arch
zlib_env['CC'] += ' %s -mios-version-min=7.0' % (zlib_arch_str)
zlib_env['SDKROOT'] = os.environ['SDKROOT']
zlib_env['CFLAGS'] += ' -isysroot %s' % os.environ['SDKROOT']
zlib_libs = [zlib_lib,]
zlib_prefix_absolute = drake.path_build(zlib_prefix,
absolute = True)
zlib_args = [
"BINARY_PATH='%s/bin'" % zlib_prefix_absolute,
"INCLUDE_PATH='%s/include'" % zlib_prefix_absolute,
"LIBRARY_PATH='%s/lib'" % zlib_prefix_absolute,
]
if windows:
zlib_args.append("PREFIX=%s" % cxx_toolkit.prefix)
GNUBuilder(
cxx_toolkit,
configure = zlib_configure_call,
configure_args = [
'--prefix=%s' % zlib_prefix_absolute,
] + zlib_configure_args,
additional_env = zlib_env,
working_directory = drake.path_build(zlib_build),
targets = zlib_libs + drake.nodes('zlib/include/zlib.h',
'zlib/include/zconf.h'),
makefile = zlib_makefile,
sources = [zlib_configure, zlib_main_header],
build_args = ['install'] + list(s.replace('\\', '/') for s in zlib_args)
)
zlib_config = drake.cxx.Config()
zlib_config.add_local_include_path('zlib/include')
drake.Rule('zlib') << zlib_libs
## ------- ##
## OpenSSL ##
## ------- ##
openssl_rule = drake.Rule('openssl')
openssl_version = '1.0.2'
openssl_release_tag = 'j'
openssl_basename = 'openssl-%s' % (openssl_version + openssl_release_tag)
openssl_tarball = drake.node('openssl/%s.tar.gz' % openssl_basename)
openssl_prefix = drake.Path('openssl')
openssl_build = openssl_prefix / openssl_basename
# Only the latest release is in source/ all other releases are in
# source/old/<version>. Use the old location as a fallback.
drake.HTTPDownload(
[
'http://www.openssl.org/source/%s.tar.gz' % openssl_basename,
'http://www.openssl.org/source/old/%s/%s.tar.gz' % (
openssl_version, openssl_basename),
'http://www.openssl.org/source/old/%s%s/%s.tar.gz' % (
openssl_version, openssl_release_tag, openssl_basename),
],
openssl_tarball,
fingerprint = '96322138f0b69e61b7212bc53d5e912b')
openssl_headers = [
'include/openssl/aes.h',
'include/openssl/asn1.h',
'include/openssl/asn1_mac.h',
'include/openssl/asn1t.h',
'include/openssl/bio.h',
'include/openssl/blowfish.h',
'include/openssl/bn.h',
'include/openssl/buffer.h',
'include/openssl/camellia.h',
'include/openssl/cast.h',
'include/openssl/cmac.h',
'include/openssl/cms.h',
'include/openssl/comp.h',
'include/openssl/conf.h',
'include/openssl/conf_api.h',
'include/openssl/crypto.h',
'include/openssl/des.h',
'include/openssl/des_old.h',
'include/openssl/dh.h',
'include/openssl/dsa.h',
'include/openssl/dso.h',
'include/openssl/dtls1.h',
'include/openssl/e_os2.h',
'include/openssl/ebcdic.h',
'include/openssl/ec.h',
'include/openssl/ecdh.h',
'include/openssl/ecdsa.h',
'include/openssl/engine.h',
'include/openssl/err.h',
'include/openssl/evp.h',
'include/openssl/hmac.h',
'include/openssl/idea.h',
'include/openssl/krb5_asn.h',
'include/openssl/kssl.h',
'include/openssl/lhash.h',
'include/openssl/md4.h',
'include/openssl/md5.h',
'include/openssl/mdc2.h',
'include/openssl/modes.h',
'include/openssl/obj_mac.h',
'include/openssl/objects.h',
'include/openssl/ocsp.h',
'include/openssl/opensslconf.h',
'include/openssl/opensslv.h',
'include/openssl/ossl_typ.h',
'include/openssl/pem.h',
'include/openssl/pem2.h',
'include/openssl/pkcs12.h',
'include/openssl/pkcs7.h',
'include/openssl/pqueue.h',
'include/openssl/rand.h',
'include/openssl/rc2.h',
'include/openssl/rc4.h',
'include/openssl/ripemd.h',
'include/openssl/rsa.h',
'include/openssl/safestack.h',
'include/openssl/seed.h',
'include/openssl/sha.h',
'include/openssl/srp.h',
'include/openssl/srtp.h',
'include/openssl/ssl.h',
'include/openssl/ssl2.h',
'include/openssl/ssl23.h',
'include/openssl/ssl3.h',
'include/openssl/stack.h',
'include/openssl/symhacks.h',
'include/openssl/tls1.h',
'include/openssl/ts.h',
'include/openssl/txt_db.h',
'include/openssl/ui.h',
'include/openssl/ui_compat.h',
'include/openssl/whrlpool.h',
'include/openssl/x509.h',
'include/openssl/x509_vfy.h',
'include/openssl/x509v3.h',
]
drake.TarballExtractor(
openssl_tarball,
targets = ['%s/Configure' % openssl_basename],
patch_dir = openssl_basename,
)
# This is not a configure from Autoconf. However it is sufficiently
# alike so that our GNUBuilder can be used.
openssl_configure = drake.node(openssl_build / 'Configure')
from drake.cxx import DynLib, StaticLib
openssl_shared = True
openssl_env = {
'CC': ' '.join(cxx_toolkit.command_c + ['-w']),
'PERL': 'perl',
}
if cxx_toolkit.os in [drake.os.linux]:
openssl_lib_ssl = DynLib(openssl_prefix / 'lib/libssl.so.1.0.0')
openssl_lib_crypto = DynLib(openssl_prefix / 'lib/libcrypto.so.1.0.0')
elif cxx_toolkit.os is drake.os.macos:
openssl_lib_ssl = DynLib(openssl_prefix / 'lib/libssl.1.0.0.dylib')
openssl_lib_crypto = DynLib(openssl_prefix / 'lib/libcrypto.1.0.0.dylib')
elif cxx_toolkit.os in [drake.os.windows, drake.os.ios, drake.os.android]:
openssl_lib_ssl = StaticLib(openssl_prefix / 'lib/libssl.a')
openssl_lib_crypto = StaticLib(openssl_prefix / 'lib/libcrypto.a')
openssl_shared = False
openssl_libs = [openssl_lib_ssl, openssl_lib_crypto]
openssl_prefix_absolute = \
drake.path_build(openssl_prefix, absolute = True)
if cxx_toolkit.os is drake.os.linux:
if cxx_toolkit.architecture == drake.architecture.x86_64:
os_string = 'linux-x86_64'
elif cxx_toolkit.architecture == drake.architecture.x86:
os_string = 'linux-generic32'
elif cxx_toolkit.architecture == drake.architecture.arm:
os_string = 'linux-armv4'
elif cxx_toolkit.os is drake.os.android:
os_string = 'android'
elif windows:
os_string = 'mingw64'
del openssl_env['CC']
openssl_env['CROSS_COMPILE'] = '%s' % cxx_toolkit.prefix
elif cxx_toolkit.os is drake.os.macos:
os_string = 'darwin64-x86_64-cc'
elif cxx_toolkit.os is drake.os.ios:
os_string = 'iphoneos-cross'
openssl_env['CROSS_TOP'] = os.environ['CROSS_TOP']
openssl_env['CROSS_SDK'] = os.environ['CROSS_SDK']
crypto_arch_libs = []
ssl_arch_libs = []
if cxx_toolkit.os is drake.os.ios and archs:
for arch in archs:
openssl_env['CC'] = \
'%s -arch %s -mios-version-min=7.0' % (cxx_toolkit.c, arch)
openssl_arch_prefix = openssl_prefix / drake.Path('%s' % arch)
crypto_arch_lib = StaticLib(openssl_arch_prefix / 'lib/libcrypto.a')
crypto_arch_libs.append(crypto_arch_lib)
ssl_arch_lib = StaticLib(openssl_arch_prefix / 'lib/libssl.a')
ssl_arch_libs.append(ssl_arch_lib)
GNUBuilder(
cxx_toolkit,
configure = openssl_configure,
configure_interpreter = 'perl',
targets = [crypto_arch_lib, ssl_arch_lib],
configure_args = [
'--prefix=%s' % drake.path_build(openssl_arch_prefix, absolute = True),
openssl_shared and 'shared' or 'no-shared',
'-DPURIFY',
os_string,
],
build_args = [
'build_libs', 'install', 'clean'
],
additional_env = openssl_env,
)
FatLibraryGenerator(crypto_arch_libs, openssl_lib_crypto)
FatLibraryGenerator(ssl_arch_libs, openssl_lib_ssl,
headers = openssl_headers,
input_headers = openssl_build / 'include',
output_headers = openssl_prefix)
else:
def build_ssl_libs(targets,
sharing_model):
GNUBuilder(
cxx_toolkit,
configure = openssl_configure,
configure_interpreter = 'perl',
targets = targets,
configure_args = [
'--prefix=%s' % openssl_prefix_absolute,
sharing_model,
'-DPURIFY',
os_string,
],
build_args = [
'all', 'install_sw',
],
additional_env = openssl_env,
)
build_ssl_libs(
targets = chain(
openssl_libs,
(drake.node(openssl_prefix / p) for p in openssl_headers)),
sharing_model = openssl_shared and 'shared' or 'no-shared')
if build_openssl_eay and windows:
names = ['bin/libeay32.dll', 'bin/ssleay32.dll', 'lib/libssl.dll.a', 'lib/libcrypto.dll.a']
openssl_libs_eay = [DynLib(openssl_prefix / name) for name in names]
build_ssl_libs(targets = openssl_libs_eay,
sharing_model = 'shared')
openssl_eay_rule = drake.Rule('openssl/eay')
openssl_eay_rule << openssl_libs_eay
openssl_rule << openssl_eay_rule
openssl_rule << openssl_libs
openssl_config = drake.cxx.Config()
openssl_config.add_local_include_path(openssl_prefix / 'include')
## ---- ##
## Curl ##
## ---- ##
curl_basename = 'curl-7.51.0'
curl_tarball = drake.node('curl/%s.tar.gz' % curl_basename)
curl_prefix = drake.Path('curl')
curl_build = curl_prefix / curl_basename
curl_url = 'http://curl.haxx.se/download/%s.tar.gz' % curl_basename
drake.HTTPDownload(curl_url, curl_tarball,
fingerprint = '490e19a8ccd1f4a244b50338a0eb9456')
drake.TarballExtractor(
curl_tarball,
targets = ['%s/%s' % (curl_basename, f) for f in (
'configure',
)],
patches = ((drake.node('.patches/curl.patch'),1),),
patch_dir = curl_basename,
)
curl_configure = drake.node(curl_build / 'configure')
from drake.cxx import DynLib, StaticLib
if cxx_toolkit.os is drake.os.linux:
curl_lib = DynLib(curl_prefix / 'lib/libcurl.so.4')
elif cxx_toolkit.os is drake.os.macos:
curl_lib = DynLib(curl_prefix / 'lib/libcurl.4.dylib')
elif cxx_toolkit.os in [drake.os.windows, drake.os.ios, drake.os.android]:
curl_lib = StaticLib(curl_prefix / 'lib/libcurl.a')
else:
raise Exception('Unknown OS')
curl_openssl_libs = drake.copy(openssl_libs, curl_prefix / 'lib',
strip_prefix = True)
curl_zlib_libs = drake.copy(zlib_libs, curl_prefix / 'lib',
strip_prefix = True)
curl_configure_args = [
'--with-ssl=%s' % drake.path_build(openssl_prefix,
absolute = True),
'--with-zlib=%s' % drake.path_build(zlib_prefix,
absolute = True),
'--enable-hidden-symbols',
'--enable-optimize',
'--enable-warnings',
'--enable-threaded-resolver',
'--disable-ldap',
'--disable-ldaps',
'--disable-manual',
'--disable-rtmp',
'--disable-sspi',
'--disable-ssh',
'--disable-rtsp',
'--with-gssapi',
'--without-libidn',
'--without-libssh2',
'--without-nghttp2',
]
if cxx_toolkit.os is not drake.os.ios:
curl_configure_args.append(
'--prefix=%s' % drake.path_build(curl_prefix, absolute = True))
if isinstance(curl_lib, StaticLib):
curl_configure_args.extend([
'--disable-shared',
'--enable-static',
])
else:
curl_configure_args.extend([
'--enable-shared',
'--disable-static',
])
# if cxx_toolkit.os is drake.os.linux:
# # So curl links its curl binary with the right SSL.
# curl_configure_args.append(
# 'LDFLAGS=-Wl,-rpath-link,%s -ldl' % (openssl_prefix / 'lib'))
curl_env = {
'CC': ' '.join(cxx_toolkit.command_c),
'CFLAGS': '-w',
# Be sure to control pkg-config, otherwise, because curl's
# configure.ac checks pkg-config *before* --with-zlib, we might
# end up using the system's copy instead ours.
'PKG_CONFIG_PATH': str(drake.path_build(zlib_prefix, absolute = True) / 'lib' / 'pkgconfig'),
}
if cxx_toolkit.architecture is drake.architecture.arm:
curl_configure_args.append('--host=%s' % cxx_toolkit.cxx[:-4])
else:
curl_configure_args.append('--host=%s' % drake.host())
if cxx_toolkit.os is drake.os.macos:
path = drake.path_build(zlib_prefix, absolute = True) / 'lib'
curl_configure_args.append('DYLD_FALLBACK_LIBRARY_PATH=%s' % path)
elif windows:
curl_env['LIBS'] = '-lcrypt32 -lgdi32'
curl_configure_args.append('--build=%s' % cxx_toolkit.prefix[:-1])
elif cxx_toolkit.os is drake.os.ios:
curl_configure_args.append('--with-sysroot=%s' % os.environ['SDKROOT'])
elif cxx_toolkit.os is drake.os.android:
# configure is making a runtime library availability check
curl_env['LD_LIBRARY_PATH'] = \
str(drake.path_build(curl_prefix / 'lib', absolute = True))
curl_dependency_libs = curl_openssl_libs + curl_zlib_libs
curl_headers = [
'include/curl/typecheck-gcc.h',
'include/curl/stdcheaders.h',
'include/curl/easy.h',
'include/curl/mprintf.h',
'include/curl/curl.h',
'include/curl/curlver.h',
'include/curl/multi.h',
'include/curl/curlrules.h'
]
if cxx_toolkit.os is drake.os.ios and archs:
curl_arch_libs = []
for arch in archs:
curl_configure_arch_args = list(curl_configure_args)
curl_arch_prefix = curl_prefix / drake.Path('%s' % arch)
curl_env['CC'] += ' -arch %s -mios-version-min=7.0' % (arch)
arch_str = 'aarch64' if arch is 'arm64' else arch
curl_configure_arch_args.append('--host=%s-apple-darwin' % arch_str)
curl_configure_arch_args.append(
'--prefix=%s' % drake.path_build(curl_arch_prefix, absolute = True))
curl_arch_lib = StaticLib(curl_arch_prefix / 'lib/libcurl.a')
curl_arch_libs.append(curl_arch_lib)
GNUBuilder(
cxx_toolkit,
configure = curl_configure,
working_directory = drake.path_build(curl_build),
targets = [curl_arch_lib],
configure_args = curl_configure_arch_args,
sources = curl_dependency_libs + [curl_configure],
build_args = ['all', 'install', 'distclean'],
additional_env = curl_env,
)
FatLibraryGenerator(curl_arch_libs, curl_lib,
headers = curl_headers,
input_headers = curl_prefix / ('%s/include' % archs[0]),
output_headers = curl_prefix)
else:
GNUBuilder(
cxx_toolkit,
configure = curl_configure,
working_directory = drake.path_build(curl_build),
targets = [curl_lib] +
drake.nodes(*(curl_prefix / path for path in
curl_headers)),
configure_args = curl_configure_args,
sources = curl_dependency_libs + [curl_configure],
build_args = ['all', 'install',],
additional_env = curl_env,
)
for lib in curl_dependency_libs:
curl_lib.dependency_add(lib)
curl_config = drake.cxx.Config()
curl_config.add_local_include_path(curl_prefix / 'include')
if windows:
curl_config.define('CURL_STATICLIB', '1')
drake.Rule('curl') << curl_lib
## ---------- ##
## LibArchive ##
## ---------- ##
libarchive_version = '3.2.2'
libarchive_basename = 'libarchive-%s' % libarchive_version
libarchive_tarball = \
drake.node('libarchive/%s.tar.gz' % libarchive_basename)
libarchive_prefix = drake.Path('libarchive')
libarchive_build = libarchive_prefix / libarchive_basename
libarchive_configure = drake.node(libarchive_build / 'configure')
libarchive_url = \
'http://libarchive.org/downloads/%s.tar.gz' % libarchive_basename
drake.HTTPDownload(
libarchive_url,
libarchive_tarball,
fingerprint = '1ec00b7dcaf969dd2a5712f85f23c764',
)
libarchive_patches = ()
if cxx_toolkit.os is drake.os.android:
libarchive_patches = ((drake.node('.patches/libarchive_android.patch'), 0),)
drake.TarballExtractor(
libarchive_tarball,
targets = ['libarchive-%s/configure' % libarchive_version],
patches = libarchive_patches
)
libarchive_openssl_libs = \
drake.copy(openssl_libs, libarchive_prefix / 'lib',
strip_prefix = True)
libarchive_zlib_libs = \
drake.copy(zlib_libs, libarchive_prefix / 'lib',
strip_prefix = True)
libarchive_dependency_libs = \
libarchive_openssl_libs + libarchive_zlib_libs
libarchive_env = {}
libarchive_configure_args = [
'--disable-acl',
'--disable-xattr',
'CPPFLAGS=-I%s/include -I%s/include' % (openssl_prefix_absolute,
zlib_prefix_absolute),
'CFLAGS=-w', # No warnings.
'LDFLAGS=-L%s/lib -L%s/lib' % (openssl_prefix_absolute,
zlib_prefix_absolute),
'--without-bz2lib',
'--without-expat',
'--without-lzma',
'--without-lzo2',
'--without-nettle',
'--without-xml2',
]
if windows:
libarchive_lib = drake.cxx.StaticLib(libarchive_prefix / 'lib/libarchive.a')
bsdcpio = drake.cxx.Executable('libarchive/bin/bsdcpio.exe')
bsdtar = drake.cxx.Executable('libarchive/bin/bsdtar.exe')
libarchive_configure_args += ['--disable-shared']
libarchive_configure_args += ['--host=%s' % cxx_toolkit.prefix[:-1]]
elif cxx_toolkit.os is drake.os.ios:
bsdcpio = drake.cxx.Executable('libarchive/bin/bsdcpio')
bsdtar = drake.cxx.Executable('libarchive/bin/bsdtar')
libarchive_lib = drake.cxx.StaticLib(libarchive_prefix / 'lib/libarchive.a')
elif cxx_toolkit.os is drake.os.android:
bsdcpio = drake.cxx.Executable('libarchive/bin/bsdcpio')
bsdtar = drake.cxx.Executable('libarchive/bin/bsdtar')
libarchive_lib = drake.cxx.StaticLib(libarchive_prefix / 'lib/libarchive.a')
else:
bsdcpio = drake.cxx.Executable('libarchive/bin/bsdcpio')
bsdtar = drake.cxx.Executable('libarchive/bin/bsdtar')
libarchive_preload = ':'.join(str(drake.path_root() / n.path())
for n in libarchive_dependency_libs)
if cxx_toolkit.os is drake.os.macos:
libarchive_lib = 'lib/libarchive.13.dylib'
libarchive_configure_args.append('DYLD_INSERT_LIBRARIES=%s' %
libarchive_preload)
elif cxx_toolkit.os is drake.os.linux:
libarchive_lib = 'lib/libarchive.so.13'
libarchive_env = {'LD_PRELOAD': libarchive_preload}
libarchive_lib = drake.cxx.DynLib(libarchive_prefix / libarchive_lib)
if cxx_toolkit.architecture is drake.architecture.arm:
libarchive_configure_args += ['--host=%s' % cxx_toolkit.cxx[:-4]]
libarchive_prefix_absolute = drake.path_build(libarchive_prefix,
absolute = True)
if cxx_toolkit.os is not drake.os.ios:
libarchive_configure_args.append('--prefix=%s' % libarchive_prefix_absolute)
libarchive_headers = [
'include/archive.h',
'include/archive_entry.h',
]
if cxx_toolkit.os is drake.os.ios:
libarchive_arch_libs = []
for arch in archs:
libarchive_arch_prefix = libarchive_prefix / drake.Path('%s' % arch)
libarchive_arch_configure_args = list(libarchive_configure_args)
libarchive_arch_configure_args += [
'--host=%s-apple-darwin' % 'armv7',#xxx% arch,
'--prefix=%s' % drake.path_build(libarchive_arch_prefix, absolute = True)
]
libarchive_env.update({
'CC': '%s -arch %s -mios-version-min=7.0' % (cxx_toolkit.c, arch),
'CFLAGS': '-isysroot %s' % os.environ['SDKROOT'],
})
libarchive_arch_lib = \
drake.cxx.StaticLib(libarchive_arch_prefix / 'lib/libarchive.a')
libarchive_arch_libs.append(libarchive_arch_lib)
GNUBuilder(
cxx_toolkit,
configure = libarchive_configure,
configure_args = libarchive_arch_configure_args,
additional_env = libarchive_env,
working_directory = drake.path_build(libarchive_build),
targets = [libarchive_arch_lib,],
sources = [libarchive_configure] + libarchive_dependency_libs,
build_args = ['all', 'install', 'clean'],
)
FatLibraryGenerator(libarchive_arch_libs, libarchive_lib,
headers = libarchive_headers,
input_headers = libarchive_prefix / ('%s/include' % archs[0]),
output_headers = libarchive_prefix)
else:
libarchive_env.update({
'CC': ' '.join(cxx_toolkit.command_c),
})
GNUBuilder(
cxx_toolkit,
configure = libarchive_configure,
configure_args = libarchive_configure_args,
additional_env = libarchive_env,
working_directory = drake.path_build(libarchive_build),
targets = chain([
libarchive_lib,
bsdcpio,
bsdtar,
],
(drake.node(libarchive_prefix / p)
for p in libarchive_headers)),
sources = [libarchive_configure] + libarchive_dependency_libs,
)
for lib in libarchive_dependency_libs:
libarchive_lib.dependency_add(lib)
libarchive_config = drake.cxx.Config()
libarchive_config.add_local_include_path(libarchive_prefix / 'include')
drake.Rule('libarchive') << libarchive_lib
## ----- ##
## Boost ##
## ----- ##
boost_static = cxx_toolkit.os in [drake.os.ios]
boost_version = drake.Version(1, 67, 0)
if boost is not None:
boost = drake.cxx.boost.Boost(
cxx_toolkit = cxx_toolkit,
prefix = boost,
version_effective = boost_version,
prefer_shared = not boost_static,
)
else:
boost_basename = 'boost_%s' % str(boost_version).replace('.', '_')
boost_tarball = drake.node('boost/%s.tar.gz' % boost_basename)
boost_prefix = drake.Path('boost')
boost_prefix_abs = drake.Path(os.getcwd()) / drake.path_build() / boost_prefix
boost_host = \
'https://dl.bintray.com/boostorg/release/1.67.0/source/'
boost_url = '%s/%s.tar.gz' % (boost_host, boost_basename)
drake.HTTPDownload(
boost_url,
boost_tarball,
fingerprint = '4850fceb3f2222ee011d4f3ea304d2cb',
)
boost_patches = [
(drake.Node('.patches/boost_asio_ssl.patch'), 1),
(drake.Node('.patches/boost_optional.patch'), 1),
(drake.Node('.patches/boost_warnings.patch'), 1),
]
boost_locale_enabled = cxx_toolkit.os in [drake.os.windows]
boost_attributes = {}
exec(open(str(drake.path_source('boost.py')), 'r').read(),
boost_attributes)
boost_patched_sources = boost_attributes['patched_sources']
if cxx_toolkit.os is drake.os.macos:
boost_patched_sources += [
'boostcpp.jam', # boost_build_osx.patch
]
boost_patches += [
(drake.Node('.patches/boost_build_osx.patch'), 1),
]
drake.TarballExtractor(
boost_tarball,
targets = ['%s/%s' % (boost_basename, f)
for f in boost_patched_sources + ['bootstrap.sh']
],
patches = boost_patches,
patch_dir = boost_basename,
)
boost_bootstrap = drake.node('boost/%s/bootstrap.sh' % boost_basename)
boost_prefix = 'boost/%s' % boost_version
boost_prefix_abs = drake.path_root() / drake.path_build(boost_prefix)
boost_built_libraries = [
'atomic',
'chrono',
'context',
'date_time',
'filesystem',
'program_options',
'regex',
'signals',
'system',
('test', 'unit_test_framework'),
('thread',
'thread_win32' if windows else 'thread'),
'timer',
]
boost_bootstrap_libraries, boost_library_names = ([
l[i] if isinstance(l, tuple) else l
for l in boost_built_libraries]
for i in (0, 1))
if python3 is not None and not windows:
boost_bootstrap_libraries.append('python')
if boost_locale_enabled:
boost_bootstrap_libraries.append('locale')
boost_bootstrap_command = [
'./bootstrap.sh',
'--prefix=%s' % boost_prefix_abs,
'--with-libraries=%s' % ','.join(boost_bootstrap_libraries),
'--without-icu',
]
if python3 is not None and not windows:
boost_bootstrap_command.append('--with-python=%s' % python_version)
boost_bjam = drake.node('boost/%s/b2' % boost_basename)
if python3 is not None and not windows:
boost_library_names.append('python{}{}'.format(python3.version.major, python3.version.minor))
if boost_locale_enabled:
boost_library_names.append('locale')
if cxx_toolkit.os is drake.os.macos:
boost_static_format = '%s/lib/libboost_%s.a'
boost_dynamic_format = '%s/lib/libboost_%s.dylib'
boost_dynamic_versioned_format = \
'%%s/lib/libboost_%%s-%s_%s.dylib' % \
(boost_version.major, boost_version.minor)
elif windows:
if boost_static:
boost_static_format = '%s/lib/libboost_%s-mt-s.a'
boost_dynamic_format = None
boost_dynamic_versioned_format = None
else:
boost_static_format = '%s/lib/libboost_%s-mt.dll.a'
boost_dynamic_format = '%s/lib/libboost_%s-mt.dll'
boost_dynamic_versioned_format = None
elif cxx_toolkit.os is drake.os.ios:
boost_static_format = '%s/lib/libboost_%s-mt-s.a'
boost_dynamic_format = None
boost_dynamic_versioned_format = None
else:
boost_static_format = '%s/lib/libboost_%s.a'
boost_dynamic_format = '%s/lib/libboost_%s.so'
boost_dynamic_versioned_format = \
'%%s/lib/libboost_%%s.so.%s' % boost_version
if boost_static:
boost_fmt = ((drake.cxx.StaticLib, boost_static_format),)
else:
boost_fmt = ((drake.cxx.DynLib, boost_dynamic_format),
(drake.cxx.DynLib, boost_dynamic_versioned_format))
boost_libraries = (
[t(fmt % (boost_prefix, name))
for t, fmt in boost_fmt
if fmt is not None]
for name in boost_library_names)
boost_libraries = list(chain(*boost_libraries))
class BoostUserConfigGenerator(drake.Builder):
def __init__(self, destination, cxx_toolkit):
self.__toolkit = cxx_toolkit
self.__user_config = destination
# Depend on boost_bootstrap because the configuration is in
# the tarball extraction path and would be erased if
# extraction occurs after.
super().__init__([boost_bootstrap], [self.__user_config])
def execute(self):
self.output('Generate %s' % self.__user_config,
'Generate Boost user configuration')
with open(str(self.__user_config.path()), 'w') as f:
params = self.params
params['linkflags'] = ' '.join(
'<linkflags>%s' % f for f in params['linkflags'])
print(self.format % params, file = f)
return True
@property
def user_config(self):
return self.__user_config
@property
def format(self):
res = '''\
using %(compiler)s : : %(cxx)s : %(linkflags)s ;
'''
if python3 is not None:
res += '''\
using python : %(python_version)s : %(python_prefix)s/%(python_bin)s : %(python_prefix)s/%(python_include)s : %(python_prefix)s/lib %(extra)s;
'''
return res
@property
def params(self):
cxx = ' '.join(self.__toolkit.command_cxx)
linkflags = []
if windows:
extra = ': <target-os>windows '
linkflags = ['-static-libgcc', '-Wl,-Bstatic', '-lstdc++', '-lpthread', '-Wl,-Bdynamic']
elif cxx_toolkit.os is drake.os.ios:
boost_arch_str = ''
for arch in archs:
boost_arch_str += '-arch %s ' % arch
cxx = '%s %s -fvisibility=hidden -fvisibility-inlines-hidden' % (cxx, boost_arch_str)
cxx += '\n: <striper> <root>%s' % os.environ['CROSS_TOP']
cxx += '\n: <architecture>arm <target-os>iphone'
extra = ''
else:
extra = ''
if cxx_toolkit.os is drake.os.macos:
if cxx_toolkit.kind == drake.cxx.GccToolkit.Kind.clang:
compiler = 'clang'
else:
compiler = 'darwin'