-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild.sh
executable file
·2099 lines (1850 loc) · 78.6 KB
/
build.sh
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
#!/bin/bash
################################################################################
# Variable declaration
filename=$0
script_location=`cd "\`dirname "$filename"\`"; pwd`
idl_location="${script_location}/srcIdl"
classic_cpp_folder="${script_location}/srcCpp"
common_cpp_folder="${script_location}/srcCppCommon"
modern_cpp_folder="${script_location}/srcCpp11"
java_folder="${script_location}/srcJava"
java_scripts_folder="${script_location}/resource/scripts/java_execution_scripts"
cs_folder="${script_location}/srcCs"
cs_scripts_folder="${script_location}/resource/scripts/cs_execution_scripts"
bin_folder="${script_location}/bin"
cStringifyFile_script="${script_location}/resource/scripts/cStringifyFile.pl"
qos_file="${script_location}/perftest_qos_profiles.xml"
doc_folder="${script_location}/srcDoc"
generate_doc_folder="${script_location}/doc"
resource_folder="${script_location}/resource"
# By default we will not build TSS with Pro libs
BUILD_TSS=0
BUILD_TSS_PRO=0
FACE_COMPLIANCE="None"
# By default we will build pro, not micro
BUILD_MICRO=0
# In case we build micro, which version.
BUILD_MICRO_24x_COMPATIBILITY=0
MICRO_UNBOUNDED_SEQUENCE_SIZE=1048576
# Default values for building the different APIS:
BUILD_CPP=1
BUILD_CPP11=1
BUILD_JAVA=1
BUILD_CS=0
# If this value is != 0, then it means the user specified specific APIS to be
# built, and not everything.
BUILD_SPECIFIC_APIS=0
MAKE_EXE=make
CMAKE_EXE=cmake
ADDITIONAL_CMAKE_ARGS=""
COMPILER_EXE="" # let rtiddsgen choose the default
LINKER_EXE="" # let rtiddsgen choose the default
PERL_EXEC=perl
JAVAC_EXE=javac
JAVA_EXE=java
JAR_EXE=jar
# Default values for libraries
RELEASE_DEBUG=release
STATIC_DYNAMIC=static
USE_SECURE_LIBS=0
USE_LW_SECURE_LIBS=0
LEGACY_DD_IMPL=0
# Variables for customType
custom_type_folder="${idl_location}/customType"
USE_CUSTOM_TYPE=0
USE_CUSTOM_TYPE_FLAT=0
custom_type="" # Type of the customer
custom_type_flat="" # Type of the customer
custom_type_file_name_support="" # Name of the file with the type. "TSupport.h"
# Intermediate file for including the custom type file #include "file.idl"
custom_idl_file="${custom_type_folder}/custom.idl"
# Variables for FlatData
flatdata_ddsgen_version=3 # We just need the Major value of the version.
FLATDATA_AVAILABLE=0
ZEROCOPY_AVAILABLE=0
darwin_shmem_size=419430400
# For C++ Classic, variable to control if using or not
# the native implementation
RTI_PERFTEST_NANO_CLOCK=0
# For C++ Classic, variable to control if we want to force the use
# of the C++11 infrastructure
RTI_USE_CPP_11_INFRASTRUCTURE=0
# We will use some colors to improve visibility of errors and information
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'
INFO_TAG="${GREEN}[INFO]:${NC}"
WARNING_TAG="${YELLOW}[WARNING]:${NC}"
ERROR_TAG="${RED}[ERROR]:${NC}"
################################################################################
function usage()
{
echo ""
echo "This scripts accepts the following parameters: "
echo " "
echo " --micro Build RTI Perftest for RTI Connext Micro "
echo " By default RTI Perftest will assume it will be "
echo " built against RTI Connext DDS Professional "
echo " --micro-24x-compatibility Similar to --micro but ensuring compatibility "
echo " with RTI Connext Micro 2.4.11 and above. "
echo " --platform <your_arch> Platform for which build.sh is going to compile"
echo " RTI Perftest. "
echo " --nddshome <path> Path to the *RTI Connext DDS Professional "
echo " installation*. If this parameter is not present"
echo " the \$NDDSHOME variable should be set. "
echo " If provided when building micro, it will be "
echo " used as \$RTIMEHOME "
echo " --rtimehome <path> Path to the *RTI Connext DDS Micro* "
echo " installation*. If this parameter is not present"
echo " the \$RTIMEHOME variable should be set. "
echo " --skip-java-build Avoid Java ByteCode generation creation. "
echo " (No effect when building for Micro) "
echo " --skip-cpp-build Avoid C++ code generation and compilation. "
echo " --skip-cpp11-build Avoid C++ New PSM code generation and "
echo " compilation. "
echo " (No effect when building for Micro) "
echo " --java-build Only Java ByteCode generation creation. "
echo " --cpp-build Only C++ code generation and compilation. "
echo " --cpp11-build Only C++ New PSM code generation and "
echo " compilation. "
echo " --make <path> Path to the GNU make executable. If this "
echo " parameter is not present, the GNU make variable"
echo " should be available from your \$PATH variable. "
echo " --cmake <path> Path to the cmake executable. If this "
echo " parameter is not present, cmake executable "
echo " should be available from your \$PATH variable. "
echo " will clean all the generated code and binaries "
echo " --add-cmake-args <s> Additional defines and arguments that will "
echo " be passed to the cmake executable when building"
echo " Micro. Default: Not set. "
echo " --compiler <path> Path to (or name of) the compiler executable. "
echo " If this parameter is not a full path, the named"
echo " executable should be available from your "
echo " \$PATH variable. (NOTE: c++/c++11 builds only) "
echo " --linker <path> Path to (or name of) the linker executable. "
echo " If this parameter is not a full path, the named"
echo " executable should be available from your "
echo " \$PATH variable. (NOTE: c++/c++11 builds only) "
echo " --perl <path> Path to PERL executable. If this parameter is "
echo " not present, the path to PERL should be "
echo " available from your \$PATH variable. "
echo " --java-home <path> Path to the Java JDK home folder. If this "
echo " parameter is not present, javac, jar and java "
echo " executables should be available from your "
echo " \$PATH variable. "
echo " (No effect when building for Micro) "
echo " --clean If this option is present, the build.sh script "
echo " will clean all the generated code and binaries "
echo " --debug Compile against the RTI Connext Debug "
echo " libraries. Default is against release ones. "
echo " --build-doc Generate the HTML and PDF documentation. "
echo " --dynamic Compile against the RTI Connext Dynamic "
echo " libraries. Default is against static ones. "
echo " (No effect when building for Micro) "
echo " --secure / --security Enable the security options for compilation. "
echo " Default is not enabled. "
echo " --lightWeightSecurity Enable the security options for compilation. "
echo " using the lightweight security library. "
echo " Default is not enabled. "
echo " --openssl-home <path> Path to the openssl home. This will be used "
echo " when compiling statically and using security "
echo " Default is an empty string (current folder). "
echo " <path>/release/lib or <path>/debug/lib "
echo " (depending on the --debug flag) should exist. "
echo " --wolfssl-home <path> Path to the wolfssl home. This will be used "
echo " when compiling statically and using security "
echo " Default is an empty string (current folder). "
echo " <path>/release/lib or <path>/debug/lib "
echo " (depending on the --debug flag) should exist. "
echo " --openssl-version <version> Force the use of a specific openssl version. "
echo " By default use openssl-3, else 1, else wolfssl."
echo " --wolfssl-version <version> Force the use of a specific WolfSSL version. "
echo " By default use openssl. "
echo " --ssl-version <version> Force the use of a certain ssl version. "
echo " By default use openssl-3, else 1, else wolfssl."
echo " --customType <type> Use the Custom type feature with your type. "
echo " See details and examples of use in the "
echo " documentation. "
echo " --customTypeFlatData <type> Use the Custom type feature with your FlatData "
echo " Type. See details and examples of use in the "
echo " documentation. "
echo " --flatData-max-size <size> Specify the maximum bounded size on bytes "
echo " for sequences when using FlatData language "
echo " binding. Default 10MB "
echo " --no-zeroCopy Do not try to compile against Zero-Copy libs "
echo " --osx-shmem-shmmax <size> Maximum segment size for shared memory in OSX "
echo " in bytes. Default 400MB "
echo " --ns-resolution Try to use the system real-time clock to get "
echo " nano-second resolution. "
echo " For the Classic C++ Implementation only. "
echo " Default is not enabled. "
echo " --tss Build against Connext TSS (pro and micro) "
echo " For the Classic C++ Implementation only. "
echo " Default is not enabled. "
echo " --help -h Display this message. "
echo " "
echo "================================================================================"
echo ""
}
function clean_custom_type_files()
{
# Remove generated files of the customer type
for file in ${custom_type_folder}/*.idl
do
if [ -f $file ]; then
name_file=$(basename $file)
rm -rf ${idl_location}/${name_file}
name_file="${name_file%.*}"
rm -f "${script_location}"/srcC*/"${name_file}Plugin."*
rm -f "${script_location}"/srcC*/"${name_file}."*
rm -f "${script_location}"/srcC*/"${name_file}Support."*
fi
done
rm -rf ${custom_idl_file}
}
function clean()
{
echo ""
echo -e "${INFO_TAG} Cleaning generated files."
rm -f "${script_location}"/srcC*/README_*.txt
rm -f "${script_location}"/srcC*/perftest.*
rm -f "${script_location}"/srcC*/perftest_ZeroCopy*
rm -f "${script_location}"/srcC*/perftestPlugin.*
rm -f "${script_location}"/srcC*/perftestSupport.*
rm -f "${script_location}"/srcC*/perftest_publisher.*
rm -f "${script_location}"/srcC*/perftest_subscriber.*
rm -f "${script_location}"/srcC*/makefile_*
rm -rf "${script_location}"/srcC*/objs
rm -f "${script_location}"/srcC*/*.vcxproj*
rm -f "${script_location}"/srcC*/*.vcproj*
rm -f "${script_location}"/srcC*/*.csproj
rm -f "${script_location}"/srcC*/*.sln
rm -f "${script_location}"/srcC*/*.sdf
rm -f "${script_location}"/srcC*/perftestImplPlugin.*
rm -f "${script_location}"/srcC*/perftestImpl.*
rm -rf "${script_location}"/srcJava/class
rm -rf "${script_location}"/srcJava/jar
rm -rf "${script_location}"/srcJava/com/rti/perftest/gen
rm -rf "${script_location}"/bin
rm -f "${script_location}"/srcCpp/*.txt
rm -rf "${script_location}"/srcCpp/gen
rm -rf "${script_location}"/srcCpp/perftest_build
rm -rf "${script_location}"/srcCpp/perftestApplication.*
clean_custom_type_files
clean_documentation
clean_copied_files
echo ""
echo "================================================================================"
echo ""
}
function executable_checking()
{
echo -e "\n${INFO_TAG} Pre-compilation checks."
# Is platform specified?
if [ -z "${platform}" ]; then
echo -e "${ERROR_TAG} The platform argument is missing"
usage
exit -1
fi
# If we are Building MICRO
if [ "${BUILD_TSS}" -eq "1" ]; then
if [ -z "${RTITSSHOME}" ]; then
echo -e "${ERROR_TAG} The RTITSSHOME variable is not set or the path does not exist"
usage
exit -1
elif [ "${BUILD_TSS_PRO}" -eq "1" ] && [ -z "${NDDSHOME}" ]; then
echo -e "${ERROR_TAG} The NDDSHOME variable is not set or the path does not exist"
usage
exit -1
elif [ "${BUILD_MICRO}" -eq "1" ] && [ -z "${RTIMEHOME}" ]; then
echo -e "${ERROR_TAG} The RTIMEHOME variable is not set or the path does not exist"
usage
exit -1
fi
elif [ "${BUILD_MICRO}" -eq "1" ]; then
# Is RTIMEHOME set?
if [ -z "${RTIMEHOME}" ]; then
# Is NDDSHOME set?
if [ -z "${NDDSHOME}" ]; then
echo -e "${ERROR_TAG} Nor RTIMEHOME nor NDDSHOME variables are set or the paths do not exist"
usage
exit -1
else
echo -e "${INFO_TAG} The RTIMEHOME variable is not set or the path does not exist, using NDDSHOME instead"
fi
else
export NDDSHOME="${RTIMEHOME}"
fi
# Is CMAKE in the path?
if [ -z `which "${CMAKE_EXE}"` ]
then
echo -e "${WARNING_TAG} ${CMAKE_EXE} executable not found, perftest_cpp will not be built."
fi
# Is MAKE in the path?
if [ "${BUILD_CPP}" -eq "1" ]; then
if [ -z `which "${MAKE_EXE}"` ]
then
echo -e "${WARNING_TAG} ${MAKE_EXE} executable not found, perftest_cpp will not be built."
fi
fi
else # If building pro
# Is NDDSHOME set?
if [ -z "${NDDSHOME}" ]; then
echo -e "${ERROR_TAG} The NDDSHOME variable is not set or the path does not exist"
usage
exit -1
fi
# Is MAKE in the path?
if [ "${BUILD_CPP}" -eq "1" ]; then
if [ -z `which "${MAKE_EXE}"` ]
then
echo -e "${WARNING_TAG} ${MAKE_EXE} executable not found, perftest_cpp will not be built."
fi
fi
if [ "${BUILD_CPP11}" -eq "1" ]; then
if [ -z `which "${MAKE_EXE}"` ]
then
echo -e "${WARNING_TAG} ${MAKE_EXE} executable not found, perftest_cpp11 will not be built."
fi
fi
# Is COMPILER in the path?
if [[ "${BUILD_CPP}" -eq "1" ]] && [[ ! -z ${COMPILER_EXE} ]]; then
if [ -z `which "${COMPILER_EXE}"` ]
then
echo -e "${WARNING_TAG} ${COMPILER_EXE} executable not found, perftest_cpp will not be built."
BUILD_CPP=0
fi
fi
if [[ "${BUILD_CPP11}" -eq "1" ]] && [[ ! -z ${COMPILER_EXE} ]]; then
if [ -z `which "${COMPILER_EXE}"` ]
then
echo -e "${WARNING_TAG} ${COMPILER_EXE} executable not found, perftest_cpp11 will not be built."
BUILD_CPP11=0
fi
fi
# Is LINKER in the path?
if [[ "${BUILD_CPP}" -eq "1" ]] && [[ ! -z ${LINKER_EXE} ]]; then
if [ -z `which "${LINKER_EXE}"` ]
then
echo -e "${WARNING_TAG} ${LINKER_EXE} executable not found, perftest_cpp will not be built."
BUILD_CPP=0
fi
fi
if [[ "${BUILD_CPP11}" -eq "1" ]] && [[ ! -z ${LINKER_EXE} ]]; then
if [ -z `which "${LINKER_EXE}"` ]
then
echo -e "${WARNING_TAG} ${LINKER_EXE} executable not found, perftest_cpp11 will not be built."
BUILD_CPP11=0
fi
fi
if [ "${BUILD_CS}" -eq "1" ]; then
if [ -z `which dotnet` ]; then
echo -e "${YELLOW}[WARNING]:${NC} dotnet executable not found, perftest_java will not be built."
BUILD_CS=0
fi
fi
# Is JAVA in the path?
if [ "${BUILD_JAVA}" -eq "1" ]; then
if [ -z `which "${JAVAC_EXE}"` ]; then
echo -e "${WARNING_TAG} javac executable not found, perftest_java will not be built."
BUILD_JAVA=0
fi
if [ -z `which "${JAVA_EXE}"` ]; then
echo -e "${WARNING_TAG} java executable not found, perftest_java will not be built."
BUILD_JAVA=0
fi
if [ -z `which "${JAR_EXE}"` ]; then
echo -e "${WARNING_TAG} jar executable not found, perftest_java will not be built."
BUILD_JAVA=0
fi
fi
# If the platform is android, we will just build C++ Classic by default.
if [[ ${platform} == *"Android"* ]]; then
BUILD_CPP11=0
BUILD_JAVA=0
BUILD_CS=0
fi
fi #TSS/Micro/Pro
echo -e ""
}
# Check if a path that includes a wildcard exists and return the actual path
function get_absolute_folder_path()
{
local input="$1"
local matching_folders=("${input}"*) # Store matching folders in an array
if [ -d "${matching_folders[0]}" ]; then
local current_dir=$PWD
cd ${matching_folders[0]} # Move to the first matching folder
if [[ "$?" == "0" ]]; then
result=$PWD
else
result=""
fi
cd $current_dir
fi
}
# This function receives the ssl folder pattern and it tries to find it in the
# third_party directory.
function find_ssl_libraries()
{
local find_pattern=$1
# We will try to recreate the RTI_CRYPTOHOME, if it exists
# We will not modify it.
if [ "${RTI_CRYPTOHOME}" == "" ]; then
export result=""
get_absolute_folder_path "$NDDSHOME/third_party/${find_pattern}"
if [[ "$result" == "" ]]; then
# The path does not exist.
return
else
export RTI_CRYPTOHOME="${result}/${platform}"
if [ -d "$RTI_CRYPTOHOME" ]; then
echo -e "${INFO_TAG} Using the CRYPTO LIBS from: \"${RTI_CRYPTOHOME}\""
else
export RTI_CRYPTOHOME=""
echo -e "${INFO_TAG} \"${RTI_CRYPTOHOME}\" does not exist."
return
fi
fi
fi
}
# If the NDDSHOME is staged, we might find that the nddssecurity library
# is not under $NDDSHOME/lib/$platform/ but under $NDDSHOME/lib/$platform/$ndds_security_cryto_lib_folder
# lets try to find this path. This is a best effort approach if we cannof find
# we will not fail.
function rti_security_lib_path_calculation()
{
local find_pattern=$1
export result=""
get_absolute_folder_path "${NDDSHOME}/lib/${platform}/${find_pattern}"
if [[ "$result" != "" ]]; then
export ndds_security_cryto_lib_folder=$result
echo -e "${INFO_TAG} Using the Connext Security libs from: \"${ndds_security_cryto_lib_folder}\""
return
fi
}
# If the NDDSHOME is staged, we might find that the nddssecurity library
# is not under $NDDSHOME/lib/$platform/ but under $NDDSHOME/lib/$platform/$ndds_security_cryto_lib_folder
# lets try to find this path. This is a best effort approach if we cannof find
# we will not fail.
function get_rti_security_lib_path_for_cryto_path()
{
local ssl_version="openssl-3"
if [[ "${RTI_CRYPTOHOME}" == *"$ssl_version"* ]]; then
rti_security_lib_path_calculation $ssl_version
return
fi
ssl_version="openssl-1"
if [[ "${RTI_CRYPTOHOME}" == *"$ssl_version"* ]]; then
rti_security_lib_path_calculation $ssl_version
return
fi
ssl_version="wolfssl-"
if [[ "${RTI_CRYPTOHOME}" == *"$ssl_version"* ]]; then
rti_security_lib_path_calculation $ssl_version
return
fi
}
# Function to try and get the RTI_CRYPTOHOME and ndds_security_cryto_lib_folder when no
# SSL version is provided
function crypto_path_calculation()
{
# We are going to try the following options:
# - Find first openssl 3 and use that
# - Find openssl 1 and use that
# - Find WolfSSL and use that
# - Fail if nothing was found.
echo -e "\n${INFO_TAG} Finding crypto libraries to use:"
local ssl_version="openssl-3"
find_ssl_libraries $ssl_version
if [[ "${RTI_CRYPTOHOME}" != "" ]]; then
rti_security_lib_path_calculation $ssl_version
USE_OPENSSL=1
return
fi
ssl_version="openssl-1"
find_ssl_libraries $ssl_version
if [[ "${RTI_CRYPTOHOME}" != "" ]]; then
rti_security_lib_path_calculation $ssl_version
USE_OPENSSL=1
return
fi
ssl_version="wolfssl-"
find_ssl_libraries $ssl_version
if [[ "${RTI_CRYPTOHOME}" != "" ]]; then
rti_security_lib_path_calculation $ssl_version
USE_OPENSSL=0
return
fi
# Well, we tried...
echo -e "${ERROR_TAG} We couldn't find Any SSL libraries in your Connext " \
"installation folder. You need to provide us with a path to a" \
"crypto library. Set either the OpenSSL home path by" \
"using the --openssl-home option or the WolfSSL home path" \
"by using the --wolfssl-home option"
exit -1
}
function library_sufix_calculation()
{
echo -e "\n${INFO_TAG} Library calculations"
library_sufix=""
if [ "${STATIC_DYNAMIC}" == "static" ]; then
echo -e "${INFO_TAG} C++ libraries will be compiled against RTI static libraries."
library_sufix="z"
else
echo -e "${INFO_TAG} C++ libraries will be compiled against RTI dynamic libraries."
fi
if [ "${RELEASE_DEBUG}" == "debug" ]; then
echo -e "${INFO_TAG} C++ libraries will be compiled against RTI debug libraries."
library_sufix=${library_sufix}"d"
else
echo -e "${INFO_TAG} C++ libraries will be compiled against RTI release libraries."
fi
if [ "${library_sufix}" == "" ]; then
rtiddsgen_extra_options="-sharedLib"
else
rtiddsgen_extra_options="-libSuffix ${library_sufix}"
fi
}
function additional_defines_calculation()
{
additional_rtiddsgen_defines="-D PERFTEST_RTI_PRO"
additional_defines="DPERFTEST_RTI_PRO "
additional_rti_libs=""
additional_lib_paths=""
# Avoid optimized out variables when debugging
if [ "${RELEASE_DEBUG}" == "release" ]; then
echo -e "${INFO_TAG} C++ code will be optimized."
additional_defines=${additional_defines}" O3"
else
additional_defines=${additional_defines}" O0"
fi
if [ "${LEGACY_DD_IMPL}" == "1" ]; then
echo -e "${INFO_TAG} Allow the use of both legacy and new Dynamic Data Impl."
additional_defines=${additional_defines}" DRTI_LEGACY_DD_IMPL"
fi
if [ "${RTI_MONITORING_2}" == "1" ]; then
echo -e "${INFO_TAG} Adding RTI Monitoring Libraries."
additional_rti_libs="rtimonitoring2 ${additional_rti_libs}"
additional_defines=${additional_defines}" DRTI_MONITORING_2"
fi
if [ "${USE_SECURE_LIBS}" == "1" ]; then
if [ "${USE_LW_SECURE_LIBS}" == "1" ]; then
LWS_TAG="Lightweight "
fi
echo -e "\n${INFO_TAG} Using RTI ${LWS_TAG}Security Libraries"
additional_defines="${additional_defines} DRTI_SECURE_PERFTEST"
if [ "${STATIC_DYNAMIC}" == "dynamic" ]; then
additional_defines=${additional_defines}" DRTI_PERFTEST_DYNAMIC_LINKING"
echo -e "${INFO_TAG} Linking Dynamically."
else # Linking Statically.
if [ "${USE_LW_SECURE_LIBS}" == "1" ]; then
additional_defines="${additional_defines} DRTI_LW_SECURE_PERFTEST"
fi
# If we have provided the SSL Version (Hence the RTI_CRYPTOHOME will
# be empty, no need to check)
if [[ "${SSL_VERSION}" != "" ]]; then
find_ssl_libraries $SSL_VERSION
if [[ "${RTI_CRYPTOHOME}" == "" ]]; then
echo -e "${ERROR_TAG} ${SSL_VERSION} Not found."
exit -1
fi
fi
# If the SSL_VERSION is empty and the $RTI_CRYPTOHOME is empty too
# we need to be creative. If we set the $SSL_VERSION before, we will
# not enter here.
if [ "${RTI_CRYPTOHOME}" == "" ]; then
crypto_path_calculation
else
# Check that the RTI_CRYPTOHOME exists
if [ ! -d ${RTI_CRYPTOHOME} ]; then
echo -e "${ERROR_TAG} ${RTI_CRYPTOHOME} Is not a folder."
exit -1
fi
# Lets try to load the ndds_security_cryto_lib_folder if we can.
get_rti_security_lib_path_for_cryto_path
fi
if [ "${USE_LW_SECURE_LIBS}" == "1" ]; then
additional_rti_libs="nddslightweightsecurity ${additional_rti_libs}"
else
additional_rti_libs="nddssecurity ${additional_rti_libs}"
fi
# If the $NDDSHOME points to a staging directory, then the security
# libraries will be in a folder specific to the crypto library, we should
# have calculated this in advance.
# At this point RTI_CRYPTOHOME must be set. ndds_security_cryto_lib_folder
# will be set only if the $NDDSHOME points to a staging directory.
# In a staging directory, ndds_security_cryto_lib_folder is where
# the security libraries are (a folder specific to the crypto library). In a normal
# installation, the security libraries are in
# "${NDDSHOME}/lib/${platform}/", which is already in the path.
if [ -d "${ndds_security_cryto_lib_folder}" ]; then
additional_lib_paths="${ndds_security_cryto_lib_folder} ${additional_lib_paths}"
fi
# Add the path to the crypto libraries.
additional_lib_paths="${RTI_CRYPTOHOME}/${RELEASE_DEBUG}/lib ${additional_lib_paths}"
if [ "${USE_OPENSSL}" = "1" ]; then
rtiddsgen_extra_options="${rtiddsgen_extra_options} -additionalLibraries \"ssl crypto\""
else
rtiddsgen_extra_options="${rtiddsgen_extra_options} -additionalLibraries \"wolfssl\""
fi
# This option would cause issues on certain platforms (like macOS)
# export ADDITIONAL_LINKER_FLAGS="$ADDITIONAL_LINKER_FLAGS -static"
rtiddsgen_extra_options="${rtiddsgen_extra_options} -additionalLibraryPaths \"${additional_lib_paths}\""
echo -e "${INFO_TAG} Linking Statically."
fi
fi
if [ "${USE_CUSTOM_TYPE}" == "1" ]; then
additional_defines=${additional_defines}" DRTI_CUSTOM_TYPE="${custom_type}" DRTI_CUSTOM_TYPE_FILE_NAME_SUPPORT="${custom_type_file_name_support}
fi
if [ "${USE_CUSTOM_TYPE_FLAT}" == "1" ]; then
additional_defines=${additional_defines}" DRTI_CUSTOM_TYPE_FLATDATA="${custom_type_flat}" DRTI_CUSTOM_TYPE_FILE_NAME_SUPPORT="${custom_type_file_name_support}
fi
if [ "${1}" = "CppTraditional" ]; then
additional_defines=${additional_defines}" DRTI_LANGUAGE_CPP_TRADITIONAL"
if [ "${RTI_USE_CPP_11_INFRASTRUCTURE}" == "1" ]; then
echo -e "${INFO_TAG} Force using C++11 and C++11 Infrastructure."
additional_defines=${additional_defines}" DRTI_USE_CPP_11_INFRASTRUCTURE"
fi
if [ "${RTI_PERFTEST_NANO_CLOCK}" == "1" ]; then
additional_defines=${additional_defines}" DRTI_PERFTEST_NANO_CLOCK"
fi
fi
if [ "${1}" = "CppModern" ]; then
additional_defines=${additional_defines}" DRTI_LANGUAGE_CPP_MODERN"
fi
if [[ ! -z `which git` ]] ; then
local folder_before=$PWD
cd $script_location
commit_id=`git rev-parse --short HEAD`
branch_name=`git rev-parse --abbrev-ref HEAD`
cd $folder_before
additional_defines=${additional_defines}" DPERFTEST_COMMIT_ID='\\\"${commit_id}\\\"'"
additional_defines=${additional_defines}" DPERFTEST_BRANCH_NAME='\\\"${branch_name}\\\"'"
fi
if [[ $platform == *"Darwin"* ]]; then
additional_defines=${additional_defines}" DMAX_DARWIN_SHMEM_SIZE=${darwin_shmem_size}"
fi
# Adding RTI_ZEROCOPY_AVAILABLE, RTI_FLATDATA_AVAILABLE and RTI_FLATDATA_MAX_SIZE as defines
if [ "${FLATDATA_AVAILABLE}" == "1" ]; then
additional_defines=${additional_defines}" DRTI_FLATDATA_AVAILABLE"
additional_rtiddsgen_defines_flatdata=" -D RTI_FLATDATA_AVAILABLE"
if [ "${RTI_FLATDATA_MAX_SIZE}" != "" ]; then
additional_defines=${additional_defines}" DRTI_FLATDATA_MAX_SIZE=${RTI_FLATDATA_MAX_SIZE}"
additional_rtiddsgen_defines_flatdata=${additional_rtiddsgen_defines_flatdata}" -D RTI_FLATDATA_MAX_SIZE=${RTI_FLATDATA_MAX_SIZE}"
fi
if [ "${SKIP_ZEROCOPY}" == "1" ]; then
export ZEROCOPY_AVAILABLE="0"
fi
if [ "${ZEROCOPY_AVAILABLE}" == "1" ]; then
additional_rti_libs="nddsmetp ${additional_rti_libs}"
additional_defines=${additional_defines}" DRTI_ZEROCOPY_AVAILABLE"
additional_rtiddsgen_defines_flatdata=$additional_rtiddsgen_defines_flatdata" -D RTI_ZEROCOPY_AVAILABLE"
fi
fi
additional_rtiddsgen_defines="$additional_rtiddsgen_defines $additional_rtiddsgen_defines_flatdata"
}
function additional_defines_calculation_micro()
{
additional_rtiddsgen_defines="-D PERFTEST_RTI_MICRO"
if [[ $platform == *"Darwin"* ]]; then
additional_defines=" RTI_DARWIN"
additional_included_libraries="dl;m;pthread;"
elif [[ $platform == *"Linux"* ]]; then
additional_defines=" RTI_LINUX"
additional_included_libraries="dl;m;pthread;nsl;rt;"
elif [[ $platform == *"QNX"* ]]; then
additional_defines=" RTI_QNX"
additional_included_libraries="m;socket;"
fi
additional_defines="RTI_LANGUAGE_CPP_TRADITIONAL PERFTEST_RTI_MICRO O3"${additional_defines}
if [ "${RTI_PERFTEST_NANO_CLOCK}" == "1" ]; then
additional_defines=${additional_defines}" DRTI_PERFTEST_NANO_CLOCK"
fi
if [ "${RTI_USE_CPP_11_INFRASTRUCTURE}" == "1" ]; then
echo -e "${INFO_TAG} Force using C++11 and C++11 Infrastructure."
additional_defines=${additional_defines}" DRTI_USE_CPP_11_INFRASTRUCTURE"
fi
if [ "${USE_SECURE_LIBS}" == "1" ]; then
additional_defines="${additional_defines} RTI_SECURE_PERFTEST"
if [ "${STATIC_DYNAMIC}" == "dynamic" ]; then
echo -e "${INFO_TAG} Using Security Plugins. Linking Dynamically."
else
if [ "${RTI_CRYPTOHOME}" == "" ]; then
# In this case, we are going to try to use the one that should be
# under $NDDSHOME/third_party/<crypto_lib_dir>/<arch>, we will check if
# it exists.
export RTI_CRYPTOHOME="$NDDSHOME/third_party/${RTI_CRYPTO_LIB_DIRECTORY}${RTI_CRYPTO_LIB_DIRECTORY_VERSION}/${platform}"
if [ ! -f "${RTI_CRYPTOHOME}" ]; then
# Well, we tried...
echo -e "${ERROR_TAG} In order to link statically using the "\
"Security Plugins you need to also provide a path to a"\
"crypto library. Set either the OpenSSL home path by"\
"using the --openssl-home option or the WolfSSL home path"\
"by using the --wolfssl-home option"
exit -1
fi
echo -e "${INFO_TAG} Using the CRYPTO LIBS FROM openSSL from: \"${RTI_CRYPTOHOME}\""
fi
fi
fi
}
# Generate code for the type of the customer.
# Fill additional source and header files for custom type.
function build_cpp_custom_type()
{
# Search the file which contains "Struct ${custom_type} {" and include it to ${custom_idl_file}
found_idl=false
for file in ${custom_type_folder}/*.idl
do
if [ -f $file ]; then
if grep -Fq "struct "${custom_type}" {" ${file}
then # found
custom_type_file_name_support=$(basename $file)
custom_type_file_name_support=${custom_type_file_name_support%.*}
custom_type_file_name_support=${custom_type_file_name_support}"Support.h"
echo "#include \"$(basename $file)\"" > ${custom_idl_file}
found_idl=true
fi
fi
done
if [ "$found_idl" = false ]; then
echo -e "${ERROR_TAG} Cannot find an idl file with the ${custom_type} structure for custom type test."
exit -1
fi
cp -rf ${custom_type_folder}/* ${idl_location}/
additional_header_files_custom_type="CustomType.h"
additional_source_files_custom_type="CustomType.cxx"
# Find all the files in the folder ${custom_type_folder}
# Run codegen with all those files
for file in ${custom_type_folder}/*.idl
do
if [ -f $file ]; then
rtiddsgen_command="\"${rtiddsgen_executable}\" -language ${classic_cpp_lang_string} -unboundedSupport -I ${idl_location} -unboundedSupport -replace -create typefiles -d \"${classic_cpp_folder}\" \"${file}\" "
echo -e "${INFO_TAG} Command (rtiddsgen custom type): $rtiddsgen_command"
eval $rtiddsgen_command
if [ "$?" != 0 ]; then
echo -e "${ERROR_TAG} Failure generating code for ${classic_cpp_lang_string} with the file ${file}."
exit -1
fi
# Adding the generated file as additional HeaderFiles and SourceFiles
name_file=$(basename $file)
name_file="${name_file%.*}"
additional_header_files_custom_type="${name_file}Plugin.h ${name_file}.h ${name_file}Support.h "$additional_header_files_custom_type
additional_source_files_custom_type="${name_file}Plugin.cxx ${name_file}.cxx ${name_file}Support.cxx "$additional_source_files_custom_type
fi
done
# Adding RTI_USE_CUSTOM_TYPE as a macro
additional_defines_custom_type=" -D RTI_CUSTOM_TYPE=${custom_type}"
if [ "${USE_CUSTOM_TYPE_FLAT}" == "1" ]; then
additional_defines_custom_type="${additional_defines_custom_type} -D RTI_CUSTOM_TYPE_FLATDATA=${custom_type_flat}"
fi
}
function generate_qos_string()
{
# If PERL_EXEC is in the path, generate the qos_string.h file.
if [ "${BUILD_CPP}" -eq "1" ] || [ "${BUILD_CPP11}" -eq "1" ]; then
if [ -z `which "${PERL_EXEC}"` ]; then
echo -e "${WARNING_TAG} PERL not found, ${common_cpp_folder}/qos_string.h will not be updated."
else
${PERL_EXEC} ${cStringifyFile_script} ${qos_file} PERFTEST_QOS_STRING > ${common_cpp_folder}/qos_string.h
echo -e "${INFO_TAG} QoS String ${common_cpp_folder}/qos_string.h updated successfully"
fi
fi
}
function copy_src_cpp_common()
{
for file in ${common_cpp_folder}/*
do
if [ -f $file ]; then
cp -rf "$file" "${classic_cpp_folder}"
cp -rf "$file" "${modern_cpp_folder}"
fi
done
}
function copy_src_cpp_connextDDS()
{
# Copy files in the common folder for pro and micro
for file in ${classic_cpp_folder}/connextDDS/*
do
if [ -f $file ]; then
cp -rf "$file" "${classic_cpp_folder}"
fi
done
# Copy now files specific for pro/micro
src_specific_folder="pro"
if [ ${BUILD_MICRO} != 0 ]; then
src_specific_folder="micro"
fi
for file in ${classic_cpp_folder}/connextDDS/${src_specific_folder}/*
do
if [ -f $file ]; then
cp -rf "$file" "${classic_cpp_folder}"
fi
done
}
function clean_copied_files()
{
for file in ${common_cpp_folder}/*
do
if [ -f $file ]; then
name_file=$(basename $file)
rm -rf "${modern_cpp_folder}/${name_file}"
rm -rf "${classic_cpp_folder}/${name_file}"
fi
done
rm -rf "${modern_cpp_folder}/perftest_publisher.cxx"
rm -rf "${modern_cpp_folder}/perftest_subscriber.cxx"
rm -rf "${classic_cpp_folder}/perftest_publisher.cxx"
rm -rf "${classic_cpp_folder}/perftest_subscriber.cxx"
# Delete now files copied from srcCpp/connextDDS/
for file in ${classic_cpp_folder}/connextDDS/*
do
if [ -f $file ]; then
name_file=$(basename $file)
rm -rf "${classic_cpp_folder}/${name_file}"
fi
done
src_specific_folder="pro"
if [ ${BUILD_MICRO} != 0 ]; then
src_specific_folder="micro"
fi
for file in ${classic_cpp_folder}/connextDDS/${src_specific_folder}/*
do
if [ -f $file ]; then
name_file=$(basename $file)
rm -rf "${classic_cpp_folder}/${name_file}"
fi
done
}
function check_flatData_zeroCopy_available()
{
version=$(awk -F"version" '/version/ { split($2, a, " "); print a[1] }' <<< $(${rtiddsgen_executable} -version)) # e.g. 3.0.0
# We just need the Major value of the version.
major=`echo $version | awk -F. '{print $1}'`
if [[ $major -ge $flatdata_ddsgen_version && "${FAST_QUEUE}" != "1" ]]; then
echo -e "${INFO_TAG} FlatData is available"
FLATDATA_AVAILABLE="1"
fi
if [[ "${FLATDATA_AVAILABLE}" == "1" ]] && [[ $platform != *"Android"* ]]; then
echo -e "${INFO_TAG} Zero-Copy is available"
ZEROCOPY_AVAILABLE="1"
fi
}
function build_cpp()
{
echo -e "${INFO_TAG} Copying files from srcCppCommon."
copy_src_cpp_common
echo -e "${INFO_TAG} Copying files from srcCpp/connextDDS."
copy_src_cpp_connextDDS
##############################################################################
# Generate files for the custom type files
additional_defines_custom_type=""
additional_header_files_custom_type=""
additional_source_files_custom_type=""
if [ "${USE_CUSTOM_TYPE}" == "1" ]; then
build_cpp_custom_type
fi
check_flatData_zeroCopy_available
additional_defines_calculation "CppTraditional"
additional_header_files="${additional_header_files_custom_type} \
RTIRawTransportImpl.h \
ThreadPriorities.h \
Parameter.h \
ParameterManager.h \
RTIDDSLoggerDevice.h \
MessagingIF.h \
RTIDDSImpl.h \
perftest_cpp.h \
qos_string.h \
CpuMonitor.h \
PerftestTransport.h \
PerftestSecurity.h \
Infrastructure_common.h \
Infrastructure_pro.h \
PerftestPrinter.h \
FileDataLoader.h"
additional_source_files="${additional_source_files_custom_type} \
RTIRawTransportImpl.cxx \
ThreadPriorities.cxx \
Parameter.cxx \
ParameterManager.cxx \
RTIDDSLoggerDevice.cxx \
RTIDDSImpl.cxx \
CpuMonitor.cxx \
PerftestTransport.cxx \