forked from GafferHQ/gaffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
1348 lines (1058 loc) · 42.1 KB
/
SConstruct
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
##########################################################################
#
# Copyright (c) 2011-2014, John Haddon. All rights reserved.
# Copyright (c) 2011-2014, Image Engine Design Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with
# the distribution.
#
# * Neither the name of John Haddon nor the names of
# any other contributors to this software may be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##########################################################################
import os
import re
import sys
import glob
import shutil
import fnmatch
import functools
import platform
import py_compile
import subprocess
###############################################################################################
# Version
###############################################################################################
gafferMilestoneVersion = 0 # for announcing major milestones - may contain all of the below
gafferMajorVersion = 53 # backwards-incompatible changes
gafferMinorVersion = 0 # new backwards-compatible features
gafferPatchVersion = 0 # bug fixes
# All of the following must be considered when determining
# whether or not a change is backwards-compatible
#
# - Library ABIs
# - Python APIs
# - Node/Plug naming
# - Application command line arguments
###############################################################################################
# Command line options
###############################################################################################
optionsFile = None
if "GAFFER_OPTIONS_FILE" in os.environ :
optionsFile = os.environ["GAFFER_OPTIONS_FILE"]
if "OPTIONS" in ARGUMENTS :
optionsFile = ARGUMENTS["OPTIONS"]
options = Variables( optionsFile, ARGUMENTS )
options.Add(
"CXX",
"The C++ compiler.",
"clang++" if sys.platform == "darwin" else "g++",
)
options.Add(
"CXXFLAGS",
"The extra flags to pass to the C++ compiler during compilation.",
[ "-pipe", "-Wall" ]
)
options.Add(
EnumVariable(
"BUILD_TYPE",
"Optimisation and debug symbol configuration",
"RELEASE",
allowed_values = ('RELEASE', 'DEBUG', 'RELWITHDEBINFO')
)
)
options.Add(
"CXXSTD",
"The C++ standard to build against. A minimum of C++11 is required.",
"c++11",
)
options.Add(
BoolVariable( "WARNINGS_AS_ERRORS", "Treat compiler and linker warnings as errors.", True )
)
options.Add(
"LINKFLAGS",
"The extra flags to pass to the C++ linker during compilation.",
""
)
options.Add(
BoolVariable( "ASAN", "Enable ASan when compiling with clang++", False)
)
options.Add(
"BUILD_DIR",
"The destination directory in which the build will be made.",
"./build/gaffer-${GAFFER_MILESTONE_VERSION}.${GAFFER_MAJOR_VERSION}.${GAFFER_MINOR_VERSION}.${GAFFER_PATCH_VERSION}-${GAFFER_PLATFORM}",
)
options.Add(
"BUILD_CACHEDIR",
"Specify a directory for SCons to cache build results in. This allows the sharing of build results"
"among multiple developers and can significantly reduce build times, particularly when switching"
"between multiple compilers and build options.",
""
)
options.Add(
"INSTALL_DIR",
"The destination directory for the installation.",
"./install/gaffer-${GAFFER_MILESTONE_VERSION}.${GAFFER_MAJOR_VERSION}.${GAFFER_MINOR_VERSION}.${GAFFER_PATCH_VERSION}-${GAFFER_PLATFORM}",
)
options.Add(
"PACKAGE_FILE",
"The file in which the final gaffer file will be created by the package target.",
"${INSTALL_DIR}.tar.gz",
)
options.Add(
"DELIGHT_ROOT",
"The directory in which 3delight is installed. Used to build GafferDelight, an NSI-based"
"3delight backend.",
"",
)
options.Add(
"VTUNE_ROOT",
"The directory in which VTune is installed.",
""
)
options.Add(
"ARNOLD_ROOT",
"The directory in which Arnold is installed. Used to build GafferArnold",
"",
)
# Variables to be used when making a build which will use dependencies previously
# installed in some central location, rather than using the precompiled dependencies
# provided by the GafferHQ/dependencies project.
options.Add(
"APPLESEED_ROOT",
"The directory in which Appleseed is installed. Used to build Gafferseed",
"$BUILD_DIR/appleseed",
)
options.Add(
"OSLHOME",
"The directory in which OpenShadingLanguage is installed.",
"$BUILD_DIR",
)
options.Add(
"LOCATE_DEPENDENCY_CPPPATH",
"Locations on which to search for include files "
"for the dependencies. These are included with -I.",
[],
)
options.Add(
"LOCATE_DEPENDENCY_SYSTEMPATH",
"Locations on which to search for include files "
"for the dependencies. These are included with -isystem.",
[],
)
options.Add(
"LOCATE_DEPENDENCY_LIBPATH",
"The locations on which to search for libraries for "
"the dependencies.",
"",
)
options.Add(
"LOCATE_DEPENDENCY_PYTHONPATH",
"The locations on which to search for python modules for "
"the dependencies.",
"",
)
options.Add(
"LOCATE_DEPENDENCY_RESOURCESPATH",
"The path to the resources provided by the gafferResources project. "
"If you follow the build instructions using the precompiled "
"dependencies then you will not need this option.",
"",
)
options.Add(
"LOCATE_DEPENDENCY_APPLESEED_SEARCHPATH",
"The paths in which Appleseed resources are installed.",
"",
)
options.Add(
"OPENEXR_LIB_SUFFIX",
"The suffix used when locating the OpenEXR libraries.",
"",
)
options.Add(
"BOOST_LIB_SUFFIX",
"The suffix used when locating the boost libraries.",
"",
)
options.Add(
"GLEW_LIB_SUFFIX",
"The suffix used when locating the glew libraries.",
"",
)
options.Add(
"CORTEX_LIB_SUFFIX",
"The suffix used when locating the cortex libraries.",
"",
)
options.Add(
"CORTEX_PYTHON_LIB_SUFFIX",
"The suffix used when locating the IECorePython library.",
"",
)
options.Add(
"OIIO_LIB_SUFFIX",
"The suffix used when locating the OpenImageIO libraries.",
"",
)
options.Add(
"OCIO_LIB_SUFFIX",
"The suffix used when locating the OpenColorIO libraries.",
"",
)
options.Add(
"OSL_LIB_SUFFIX",
"The suffix used when locating the OpenShadingLanguage libraries.",
"",
)
options.Add(
"VDB_LIB_SUFFIX",
"The suffix used when locating the OpenVDB libraries.",
"",
)
# general variables
options.Add(
"ENV_VARS_TO_IMPORT",
"By default SCons ignores the environment it is run in, to avoid it contaminating the "
"build process. This can be problematic if some of the environment is critical for "
"running the applications used during the build. This space separated list of environment "
"variables is imported to help overcome these problems.",
"",
)
options.Add(
"INKSCAPE",
"Where to find the inkscape binary",
"inkscape",
)
options.Add(
"SPHINX",
"Where to find the sphinx-build program",
"sphinx-build",
)
options.Add(
"INSTALL_POST_COMMAND",
"A command which is run following a successful install process. "
"This could be used to customise installation further for a "
"particular site.",
"",
)
###############################################################################################
# Basic environment object. All the other environments will be based on this.
###############################################################################################
env = Environment(
options = options,
GAFFER_MILESTONE_VERSION = str( gafferMilestoneVersion ),
GAFFER_MAJOR_VERSION = str( gafferMajorVersion ),
GAFFER_MINOR_VERSION = str( gafferMinorVersion ),
GAFFER_PATCH_VERSION = str( gafferPatchVersion ),
CPPDEFINES = [
( "GAFFER_MILESTONE_VERSION", "$GAFFER_MILESTONE_VERSION" ),
( "GAFFER_MAJOR_VERSION", "$GAFFER_MAJOR_VERSION" ),
( "GAFFER_MINOR_VERSION", "$GAFFER_MINOR_VERSION" ),
( "GAFFER_PATCH_VERSION", "$GAFFER_PATCH_VERSION" ),
],
CPPPATH = [
"include",
"$LOCATE_DEPENDENCY_CPPPATH",
],
CPPFLAGS = [
"-DBOOST_FILESYSTEM_VERSION=3",
"-DBOOST_FILESYSTEM_NO_DEPRECATED",
"-DBOOST_SIGNALS_NO_DEPRECATION_WARNING",
],
LIBPATH = [
"./lib",
"$BUILD_DIR/lib",
"$LOCATE_DEPENDENCY_LIBPATH",
],
FRAMEWORKPATH = "$BUILD_DIR/lib",
)
# include 3rd party headers with -isystem rather than -I.
# this should turn off warnings from those headers, allowing us to
# build with -Werror. there are so many warnings from boost
# in particular that this would be otherwise impossible.
for path in [
"$BUILD_DIR/include",
"$BUILD_DIR/include/python$PYTHON_VERSION",
"$BUILD_DIR/include/OpenEXR",
"$BUILD_DIR/include/GL",
] + env["LOCATE_DEPENDENCY_SYSTEMPATH"] :
env.Append(
CXXFLAGS = [ "-isystem", path ]
)
if "clang++" in os.path.basename( env["CXX"] ):
env.Append(
CXXFLAGS = [ "-Wno-unused-local-typedef" ]
)
env["BUILD_DIR"] = os.path.abspath( env["BUILD_DIR"] )
# DISPLAY and HOME are essential for running gaffer when generating
# the documentation. TERM is needed to get coloured output from the
# compiler.
for e in env["ENV_VARS_TO_IMPORT"].split() + [ "DISPLAY", "HOME", "TERM" ] :
if e in os.environ :
env["ENV"][e] = os.environ[e]
if env["PLATFORM"] == "darwin" :
env.Append( CXXFLAGS = [ "-D__USE_ISOC99" ] )
env["GAFFER_PLATFORM"] = "osx"
osxVersion = [ int( v ) for v in platform.mac_ver()[0].split( "." ) ]
if osxVersion[0] == 10 and osxVersion[1] > 7 :
# Fix problems with Boost 1.55 and recent versions of Clang.
env.Append( CXXFLAGS = [ "-DBOOST_HAS_INT128", "-Wno-unused-local-typedef" ] )
elif env["PLATFORM"] == "posix" :
if "g++" in os.path.basename( env["CXX"] ) :
gccVersion = subprocess.Popen( [ env["CXX"], "-dumpversion" ], env=env["ENV"], stdout=subprocess.PIPE ).stdout.read().strip()
gccVersion = [ int( v ) for v in gccVersion.split( "." ) ]
# GCC 4.1.2 in conjunction with boost::flat_map produces crashes when
# using the -fstrict-aliasing optimisation (which defaults to on with -O2),
# so we turn the optimisation off here, only for that specific GCC version.
if gccVersion == [ 4, 1, 2 ] :
env.Append( CXXFLAGS = [ "-fno-strict-aliasing" ] )
# GCC emits spurious "assuming signed overflow does not occur"
# warnings, typically triggered by the comparisons in Box3f::isEmpty().
# Downgrade these back to warning status.
if gccVersion >= [ 4, 2 ] :
env.Append( CXXFLAGS = [ "-Wno-error=strict-overflow" ] )
if gccVersion >= [ 5, 1 ] :
env.Append( CXXFLAGS = [ "-D_GLIBCXX_USE_CXX11_ABI=0" ] )
env["GAFFER_PLATFORM"] = "linux"
env.Append( CXXFLAGS = [ "-std=$CXXSTD", "-fvisibility=hidden" ] )
if env["BUILD_TYPE"] == "DEBUG" :
env.Append( CXXFLAGS = ["-g", "-O0"] )
elif env["BUILD_TYPE"] == "RELEASE" :
env.Append( CXXFLAGS = ["-DNDEBUG", "-DBOOST_DISABLE_ASSERTS", "-O3"] )
elif env["BUILD_TYPE"] == "RELWITHDEBINFO" :
env.Append( CXXFLAGS = ["-DNDEBUG", "-DBOOST_DISABLE_ASSERTS", "-O3", "-g"] )
if env["WARNINGS_AS_ERRORS"] :
env.Append(
CXXFLAGS = [ "-Werror" ],
SHLINKFLAGS = [ "-Wl,-fatal_warnings" ],
)
if env["BUILD_CACHEDIR"] != "" :
CacheDir( env["BUILD_CACHEDIR"] )
###############################################################################################
# Check for inkscape and sphinx
###############################################################################################
def findOnPath( file, path ) :
if os.path.isabs( file ) :
return file if os.path.exists( file ) else None
else :
if isinstance( path, basestring ) :
path = path.split( os.pathsep )
for p in path :
f = os.path.join( p, file )
if os.path.exists( f ) :
return f
return None
def checkInkscape(context):
context.Message('Checking for Inkscape... ')
result = bool( findOnPath( context.sconf.env['INKSCAPE'], os.environ["PATH"] ) )
context.Result(result)
return result
def checkSphinx( context ) :
context.Message( "Checking for Sphinx..." )
result = bool( findOnPath( context.sconf.env["SPHINX"], context.sconf.env["ENV"]["PATH"] ) )
context.Result( result )
return result
def checkQtVersion( context ) :
context.Message( "Checking for Qt..." )
program = """
#include <iostream>
#include "QtCore/qconfig.h"
int main()
{
#ifdef QT_VERSION_MAJOR
std::cout << QT_VERSION_MAJOR;
#else
std::cout << 4;
#endif
return 0;
}
"""
result = context.TryRun( program, ".cpp" )
if result[0] :
context.sconf.env["QT_VERSION"] = result[1]
context.Result( result[0] )
return result[0]
conf = Configure(
env,
custom_tests = {
"checkInkscape" : checkInkscape,
"checkSphinx" : checkSphinx,
"checkQtVersion" : checkQtVersion,
}
)
haveInkscape = conf.checkInkscape()
if not haveInkscape and env["INKSCAPE"] != "disableGraphics" :
sys.stderr.write( "ERROR : Inkscape not found. Check INKSCAPE build variable.\n" )
Exit( 1 )
if not conf.checkQtVersion() :
sys.stderr.write( "Qt not found\n" )
Exit( 1 )
if "clang++" in os.path.basename( env["CXX"] ) and env["ASAN"] :
env.Append(
CXXFLAGS = ["-fsanitize=address", "-shared-libasan"],
LINKFLAGS = ["-fsanitize=address", "-shared-libasan"]
)
###############################################################################################
# An environment for running commands with access to the applications we've built
###############################################################################################
def split( stringOrList, separator = ":" ) :
if isinstance( stringOrList, list ) :
return stringOrList
else :
return stringOrList.split( separator )
commandEnv = env.Clone()
commandEnv["ENV"]["PATH"] = commandEnv.subst( "$BUILD_DIR/bin:" ) + commandEnv["ENV"]["PATH"]
if commandEnv["PLATFORM"]=="darwin" :
commandEnv["ENV"]["DYLD_LIBRARY_PATH"] = commandEnv.subst( ":".join( [ "$BUILD_DIR/lib" ] + split( commandEnv["LOCATE_DEPENDENCY_LIBPATH"] ) ) )
else :
commandEnv["ENV"]["LD_LIBRARY_PATH"] = commandEnv.subst( ":".join( [ "$BUILD_DIR/lib" ] + split( commandEnv["LOCATE_DEPENDENCY_LIBPATH"] ) ) )
commandEnv["ENV"]["PYTHONPATH"] = commandEnv.subst( ":".join( split( commandEnv["LOCATE_DEPENDENCY_PYTHONPATH"] ) ) )
def runCommand( command ) :
command = commandEnv.subst( command )
sys.stderr.write( command + "\n" )
subprocess.check_call( command, shell=True, env=commandEnv["ENV"] )
###############################################################################################
# Determine python version
###############################################################################################
pythonVersion = subprocess.Popen( [ "python", "--version" ], env=commandEnv["ENV"], stderr=subprocess.PIPE ).stderr.read().strip()
pythonVersion = pythonVersion.split()[1].rpartition( "." )[0]
env["PYTHON_VERSION"] = pythonVersion
###############################################################################################
# The basic environment for building libraries
###############################################################################################
baseLibEnv = env.Clone()
baseLibEnv.Append(
LIBS = [
"boost_signals$BOOST_LIB_SUFFIX",
"boost_iostreams$BOOST_LIB_SUFFIX",
"boost_filesystem$BOOST_LIB_SUFFIX",
"boost_date_time$BOOST_LIB_SUFFIX",
"boost_thread$BOOST_LIB_SUFFIX",
"boost_wave$BOOST_LIB_SUFFIX",
"boost_regex$BOOST_LIB_SUFFIX",
"boost_system$BOOST_LIB_SUFFIX",
"boost_chrono$BOOST_LIB_SUFFIX",
"tbb",
"Imath$OPENEXR_LIB_SUFFIX",
"IlmImf$OPENEXR_LIB_SUFFIX",
"IECore$CORTEX_LIB_SUFFIX",
],
)
###############################################################################################
# The basic environment for building python modules
###############################################################################################
basePythonEnv = baseLibEnv.Clone()
basePythonEnv.Append(
CPPFLAGS = [
"-DBOOST_PYTHON_MAX_ARITY=20",
],
LIBS = [
"boost_python$BOOST_LIB_SUFFIX",
"IECorePython$CORTEX_PYTHON_LIB_SUFFIX",
"Gaffer",
],
)
if basePythonEnv["PLATFORM"]=="darwin" :
basePythonEnv.Append(
CPPPATH = [ "$BUILD_DIR/lib/Python.framework/Versions/$PYTHON_VERSION/include/python$PYTHON_VERSION" ],
LIBPATH = [ "$BUILD_DIR/lib/Python.framework/Versions/$PYTHON_VERSION/lib/python$PYTHON_VERSION/config" ],
LIBS = [ "python$PYTHON_VERSION" ],
)
else :
basePythonEnv.Append(
CPPPATH = [ "$BUILD_DIR/include/python$PYTHON_VERSION" ]
)
###############################################################################################
# Definitions for the libraries we wish to build
###############################################################################################
vTuneRoot = env.subst("$VTUNE_ROOT")
gafferLib = {}
if os.path.exists( vTuneRoot ):
gafferLib = {
"envAppends" : {
"CXXFLAGS" : [ "-isystem", "$VTUNE_ROOT/include", "-DGAFFER_VTUNE"],
"LIBPATH" : [ "$VTUNE_ROOT/lib64" ],
"LIBS" : [ "ittnotify" ]
},
"pythonEnvAppends" : {
"CXXFLAGS" : [ "-DGAFFER_VTUNE"]
}
}
libraries = {
"Gaffer" : gafferLib,
"GafferTest" : {
"envAppends" : {
"LIBS" : [ "Gaffer" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferTest", "GafferBindings" ],
},
"additionalFiles" : glob.glob( "python/GafferTest/*/*" ) + glob.glob( "python/GafferTest/*/*/*" ),
},
"GafferUI" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "Iex$OPENEXR_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "IECoreImage$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "IECoreImage$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "GafferUI", "GafferBindings" ],
# Prevent Qt clashing with boost::signals - we can remove
# this if we move to boost::signals2.
"CXXFLAGS" : [ "-DQT_NO_KEYWORDS" ],
},
},
"GafferUITest" : {},
"GafferDispatch" : {
"envAppends" : {
"LIBS" : [ "Gaffer" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferBindings", "GafferDispatch" ],
},
},
"GafferDispatchTest" : {
"additionalFiles" : glob.glob( "python/GafferDispatchTest/*/*" ) + glob.glob( "python/GafferDispatchTest/*/*/*" ),
},
"GafferDispatchUI" : {},
"GafferDispatchUITest" : {},
"GafferCortex" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "GafferDispatch" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferBindings", "GafferCortex", "GafferDispatch" ],
},
},
"GafferCortexTest" : {
"additionalFiles" : glob.glob( "python/GafferCortexTest/*/*" ) + glob.glob( "python/GafferCortexTest/*/*/*" ) + glob.glob( "python/GafferCortexTest/images/*" ),
},
"GafferCortexUI" : {},
"GafferCortexUITest" : {},
"GafferScene" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "Iex$OPENEXR_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "IECoreImage$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX", "GafferImage", "GafferDispatch", "Half" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferBindings", "GafferScene", "GafferDispatch", "IECoreScene$CORTEX_LIB_SUFFIX" ],
},
"additionalFiles" : glob.glob( "glsl/*.frag" ) + glob.glob( "glsl/*.vert" ) + glob.glob( "include/GafferScene/Private/IECore*Preview/*.h" )
},
"GafferSceneTest" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "GafferDispatch", "GafferScene", "IECoreScene$CORTEX_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "Gaffer", "GafferDispatch", "GafferBindings", "GafferScene", "GafferSceneTest" ],
},
"additionalFiles" : glob.glob( "python/GafferSceneTest/*/*" ),
},
"GafferSceneUI" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "GafferUI", "GafferImage", "GafferImageUI", "GafferScene", "Iex$OPENEXR_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "IECoreImage$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "IECoreGL$CORTEX_LIB_SUFFIX", "GafferBindings", "GafferScene", "GafferUI", "GafferImageUI", "GafferSceneUI" ],
},
},
"GafferSceneUITest" : {},
"GafferImage" : {
"envAppends" : {
"CPPPATH" : [ "$BUILD_DIR/include/freetype2" ],
"LIBS" : [ "Gaffer", "GafferDispatch", "Iex$OPENEXR_LIB_SUFFIX", "IECoreImage$CORTEX_LIB_SUFFIX", "OpenImageIO$OIIO_LIB_SUFFIX", "OpenColorIO$OCIO_LIB_SUFFIX", "freetype" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferBindings", "GafferImage", "GafferDispatch", "IECoreImage$CORTEX_LIB_SUFFIX", ],
},
},
"GafferImageTest" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "GafferImage", "OpenImageIO$OIIO_LIB_SUFFIX", ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferImage" ],
},
"additionalFiles" : glob.glob( "python/GafferImageTest/scripts/*" ) + glob.glob( "python/GafferImageTest/images/*" ) + glob.glob( "python/GafferImageTest/openColorIO/luts/*" ) + glob.glob( "python/GafferImageTest/openColorIO/*" ),
},
"GafferImageUITest" : {},
"GafferImageUI" : {
"envAppends" : {
"LIBS" : [ "IECoreGL$CORTEX_LIB_SUFFIX", "Gaffer", "GafferImage", "GafferUI" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferBindings", "GafferUI", "GafferImage", "GafferImageUI" ],
},
},
"GafferArnold" : {
"envAppends" : {
"CPPPATH" : [ "$ARNOLD_ROOT/include" ],
"LIBPATH" : [ "$ARNOLD_ROOT/bin" ],
"LIBS" : [ "Gaffer", "GafferScene", "GafferDispatch", "ai", "GafferVDB", "openvdb$VDB_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreArnold$CORTEX_LIB_SUFFIX", "IECoreVDB$CORTEX_LIB_SUFFIX", "GafferOSL" ],
},
"pythonEnvAppends" : {
"CPPPATH" : [ "$ARNOLD_ROOT/include" ],
"LIBPATH" : [ "$ARNOLD_ROOT/bin" ],
"LIBS" : [ "Gaffer", "GafferScene", "GafferBindings", "GafferVDB", "GafferDispatch", "GafferArnold", "GafferOSL" ],
},
"requiredOptions" : [ "ARNOLD_ROOT" ],
"additionalFiles" : [ "arnold/plugins/gaffer.mtd" ],
},
"GafferArnoldTest" : {
"additionalFiles" : glob.glob( "python/GafferArnoldTest/volumes/*" ) + glob.glob( "python/GafferArnoldTest/metadata/*" ),
},
"GafferArnoldUI" : {
"envAppends" : {
"LIBS" : [ "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "GafferOSL", "GafferSceneUI" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferArnoldUI", "GafferSceneUI" ],
},
},
"GafferArnoldUITest" : {},
"GafferOSL" : {
"envAppends" : {
"CPPPATH" : [ "$OSLHOME/include/OSL" ],
"LIBS" : [ "Gaffer", "GafferScene", "GafferImage", "OpenImageIO$OIIO_LIB_SUFFIX", "oslquery$OSL_LIB_SUFFIX", "oslexec$OSL_LIB_SUFFIX", "Iex$OPENEXR_LIB_SUFFIX", "IECoreImage$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"CPPPATH" : [ "$OSLHOME/include/OSL" ],
"LIBS" : [ "GafferBindings", "GafferScene", "GafferImage", "GafferOSL", "Iex$OPENEXR_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX" ],
},
"oslHeaders" : glob.glob( "shaders/*/*.h" ),
"oslShaders" : glob.glob( "shaders/*/*.osl" ),
},
"GafferOSLUI" : {},
"GafferOSLTest" : {
"additionalFiles" : glob.glob( "python/GafferOSLTest/*/*" ),
},
"GafferOSLUITest" : {},
"GafferDelight" : {
"envAppends" : {
"CPPPATH" : [ "$DELIGHT_ROOT/include" ],
"LIBS" : [ "Gaffer", "GafferScene", "GafferDispatch", "IECoreScene$CORTEX_LIB_SUFFIX", "3delight" ],
"LIBPATH" : [ "$DELIGHT_ROOT/lib" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferBindings", "GafferScene", "GafferDispatch", "GafferDelight" ],
"LIBPATH" : [ "$DELIGHT_ROOT/lib" ],
},
"requiredOptions" : [ "DELIGHT_ROOT" ],
},
"GafferDelightTest" : {},
"GafferDelightUI" : {},
"GafferDelightUITest" : {},
"GafferAppleseed" : {
"envAppends" : {
"CXXFLAGS" : [ "-isystem", "$APPLESEED_ROOT/include", "-DAPPLESEED_ENABLE_IMATH_INTEROP", "-DAPPLESEED_USE_SSE" ],
"LIBPATH" : [ "$APPLESEED_ROOT/lib" ],
"LIBS" : [ "Gaffer", "GafferDispatch", "GafferScene", "appleseed", "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreAppleseed$CORTEX_LIB_SUFFIX", "OpenImageIO$OIIO_LIB_SUFFIX", "oslquery$OSL_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"CXXFLAGS" : [ "-isystem", "$APPLESEED_ROOT/include", "-DAPPLESEED_ENABLE_IMATH_INTEROP", "-DAPPLESEED_USE_SSE" ],
"LIBPATH" : [ "$APPLESEED_ROOT/lib" ],
"LIBS" : [ "Gaffer", "GafferDispatch", "GafferScene", "GafferBindings", "GafferAppleseed" ],
},
"requiredOptions" : [ "APPLESEED_ROOT" ],
},
"GafferAppleseedTest" : {
"additionalFiles" : glob.glob( "python/GafferAppleseedTest/*/*" ),
},
"GafferAppleseedUI" : {},
"GafferAppleseedUITest" : {},
"GafferTractor" : {},
"GafferTractorTest" : {},
"GafferTractorUI" : {},
"GafferTractorUITest" : {},
"GafferVDB" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "GafferScene", "Half", "openvdb$VDB_LIB_SUFFIX", "IECoreVDB$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferScene", "GafferVDB", "openvdb$VDB_LIB_SUFFIX", "IECoreVDB$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX"],
}
},
"GafferVDBTest" : {
"additionalFiles" : glob.glob( "python/GafferVDBTest/*/*" ),
},
"GafferVDBUI" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "GafferScene", "GafferSceneUI", "IECoreVDB$CORTEX_LIB_SUFFIX", "IECoreScene$CORTEX_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "GafferVDB", "openvdb$VDB_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferScene", "GafferVDB", "GafferVDBUI", "openvdb$VDB_LIB_SUFFIX" ],
}
},
"GafferVDBUITest" : {
"additionalFiles" : glob.glob( "python/GafferVDBUITest/*/*" ),
},
"apps" : {
"additionalFiles" : glob.glob( "apps/*/*-1.py" ),
},
"scripts" : {
"additionalFiles" : [ "bin/gaffer", "bin/gaffer.py" ],
},
"startupScripts" : {
"additionalFiles" : glob.glob( "startup/*/*.py" ),
},
"misc" : {
"additionalFiles" : [ "LICENSE" ],
},
"IECore" : {
"classStubs" : [
# files
( "SequenceLsOp", "ops/files/sequenceLs" ),
( "SequenceCpOp", "ops/files/sequenceCopy" ),
( "SequenceMvOp", "ops/files/sequenceMove" ),
( "SequenceRmOp", "ops/files/sequenceRemove" ),
( "SequenceRenumberOp", "ops/files/sequenceRenumber" ),
( "SequenceConvertOp", "ops/files/sequenceConvert" ),
],
},
"IECoreScene" : {
"classStubs" : [
( "ReadProcedural", "procedurals/read" ),
],
},
}
# Add on OpenGL libraries to definitions - these vary from platform to platform
for library in ( "GafferUI", "GafferScene", "GafferSceneUI", "GafferImageUI" ) :
if env["PLATFORM"] == "darwin" :
libraries[library]["envAppends"].setdefault( "FRAMEWORKS", [] ).append( "OpenGL" )
else :
libraries[library]["envAppends"]["LIBS"].append( "GL" )
libraries[library]["envAppends"]["LIBS"].append( "GLEW$GLEW_LIB_SUFFIX" )
# Add on Qt libraries to definitions - these vary from platform to platform
def addQtLibrary( library, qtLibrary ) :
if env["PLATFORM"] == "darwin" :
libraries[library]["pythonEnvAppends"].setdefault( "FRAMEWORKS", [] ).append( "Qt" + qtLibrary )
else :
prefix = "Qt" if int( env["QT_VERSION"] ) < 5 else "Qt${QT_VERSION}"
libraries[library]["pythonEnvAppends"]["LIBS"].append( prefix + qtLibrary )
for library in ( "GafferUI", ) :
addQtLibrary( library, "Core" )
addQtLibrary( library, "Gui" )
addQtLibrary( library, "OpenGL" )
if int( env["QT_VERSION"] ) > 4 :
addQtLibrary( library, "Widgets" )
###############################################################################################
# The stuff that actually builds the libraries and python modules
###############################################################################################
for libraryName, libraryDef in libraries.items() :
# skip this library if we don't have the config we need
haveRequiredOptions = True
for requiredOption in libraryDef.get( "requiredOptions", [] ) :
if not env[requiredOption] :
haveRequiredOptions = False
break
if not haveRequiredOptions :
continue
# environment
libEnv = baseLibEnv.Clone()
libEnv.Append( CXXFLAGS = "-D{0}_EXPORTS".format( libraryName ) )
libEnv.Append( **(libraryDef.get( "envAppends", {} )) )
# library
librarySource = sorted( glob.glob( "src/" + libraryName + "/*.cpp" ) + glob.glob( "src/" + libraryName + "/*/*.cpp" ) )
if librarySource :
library = libEnv.SharedLibrary( "lib/" + libraryName, librarySource )
libEnv.Default( library )
libraryInstall = libEnv.Install( "$BUILD_DIR/lib", library )
libEnv.Alias( "build", libraryInstall )
# header install
sedSubstitutions = "s/!GAFFER_MILESTONE_VERSION!/$GAFFER_MILESTONE_VERSION/g"
sedSubstitutions += "; s/!GAFFER_MAJOR_VERSION!/$GAFFER_MAJOR_VERSION/g"
sedSubstitutions += "; s/!GAFFER_MINOR_VERSION!/$GAFFER_MINOR_VERSION/g"
sedSubstitutions += "; s/!GAFFER_PATCH_VERSION!/$GAFFER_PATCH_VERSION/g"
headers = (
glob.glob( "include/" + libraryName + "/*.h" ) +
glob.glob( "include/" + libraryName + "/*.inl" ) +
glob.glob( "include/" + libraryName + "/*/*.h" ) +
glob.glob( "include/" + libraryName + "/*/*.inl" )
)
for header in headers :
headerInstall = env.Command( "$BUILD_DIR/" + header, header, "sed \"" + sedSubstitutions + "\" $SOURCE > $TARGET" )
libEnv.Alias( "build", headerInstall )