forked from GafferHQ/gaffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
1456 lines (1156 loc) · 46.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-2012, John Haddon. All rights reserved.
# Copyright (c) 2011-2013, 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 py_compile
import subprocess
###############################################################################################
# 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.",
"g++",
)
options.Add(
"CXXFLAGS",
"The extra flags to pass to the C++ compiler during compilation.",
[ "-pipe", "-Wall", "-Werror", "-O2", "-DNDEBUG", "-DBOOST_DISABLE_ASSERTS" ]
)
options.Add(
"LINKFLAGS",
"The extra flags to pass to the C++ linker during compilation.",
"",
)
options.Add(
"BUILD_DIR",
"The destination directory in which the build will be made.",
"./build/gaffer-${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_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(
BoolVariable( "BUILD_DEPENDENCIES", "Set this to build all the library dependencies gaffer has.", False )
)
# variables related to building all the dependencies for gaffer. these are mutually exclusive
# with the LOCATE_* below, which are about finding the dependencies in existing locations.
# use the BUILD_* options to make a completely standalone package and the other options to
# make a build to integrate into an existing setup where the dependencies have been installed
# somewhere centrally.
options.Add(
"DEPENDENCIES_SRC_DIR",
"The location of a directory holding dependencies.",
"/home/john/dev/gafferDependencies",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_PYTHON", "Set this to build python.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"PYTHON_SRC_DIR",
"The location of the python source to be used if BUILD_DEPENDENCY_PYTHON is specified.",
"$DEPENDENCIES_SRC_DIR/Python-2.7.5",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_BOOST", "Set this to build boost.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"BOOST_SRC_DIR",
"The location of the boost source to be used if BUILD_DEPENDENCY_BOOST is specified.",
"$DEPENDENCIES_SRC_DIR/boost_1_43_0",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_TBB", "Set this to build tbb.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"TBB_SRC_DIR",
"The location of the tbb source to be used if BUILD_DEPENDENCY_TBB is specified.",
"$DEPENDENCIES_SRC_DIR/tbb41_20130613oss",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_OPENEXR", "Set this to build openexr.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"ILMBASE_SRC_DIR",
"The location of the ilmbase source to be used if BUILD_DEPENDENCY_OPENEXR is specified.",
"$DEPENDENCIES_SRC_DIR/ilmbase-1.0.3",
)
options.Add(
"OPENEXR_SRC_DIR",
"The location of the exr source to be used if BUILD_DEPENDENCY_OPENEXR is specified.",
"$DEPENDENCIES_SRC_DIR/openexr-1.7.1",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_JPEG", "Set this to build the jpeg library.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"JPEG_SRC_DIR",
"The location of the jpeg source to be used if BUILD_DEPENDENCY_JPEG is specified.",
"$DEPENDENCIES_SRC_DIR/jpeg-8c",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_TIFF", "Set this to build the tiff library.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"TIFF_SRC_DIR",
"The location of the tiff source to be used if BUILD_DEPENDENCY_TIFF is specified.",
"$DEPENDENCIES_SRC_DIR/tiff-3.8.2",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_PNG", "Set this to build the png library.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"PNG_SRC_DIR",
"The location of the png source to be used if BUILD_DEPENDENCY_PNG is specified.",
"$DEPENDENCIES_SRC_DIR/libpng-1.6.3",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_FREETYPE", "Set this to build freetype.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"FREETYPE_SRC_DIR",
"The location of the freetype source to be used if BUILD_DEPENDENCY_FREETYPE is specified.",
"$DEPENDENCIES_SRC_DIR/freetype-2.4.12",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_GLEW", "Set this to build GLEW.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"GLEW_SRC_DIR",
"The location of the glew source to be used if BUILD_DEPENDENCY_GLEW is specified.",
"$DEPENDENCIES_SRC_DIR/glew-1.7.0",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_OCIO", "Set this to build OCIO", "$BUILD_DEPENDENCIES" )
)
options.Add(
"OCIO_SRC_DIR",
"The location of the OCIO source to be used if BUILD_DEPENDENCY_OCIO is specified.",
"$DEPENDENCIES_SRC_DIR/imageworks-OpenColorIO-8883824",
)
options.Add(
"OCIO_CONFIG_DIR",
"The location of the OCIO config files to install with Gaffer.",
"$DEPENDENCIES_SRC_DIR/imageworks-OpenColorIO-Configs-f931d77/nuke-default",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_OIIO", "Set this to build OIIO.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"OIIO_SRC_DIR",
"The location of the OIIO source to be used if BUILD_DEPENDENCY_OIIO is specified.",
"$DEPENDENCIES_SRC_DIR/oiio-Release-1.2.1",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_HDF5", "Set this to build HDF5.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"HDF5_SRC_DIR",
"The location of the HDF5 source to be used if BUILD_DEPENDENCY_HDF5 is specified.",
"$DEPENDENCIES_SRC_DIR/hdf5-1.8.11",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_ALEMBIC", "Set this to build Alembic.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"ALEMBIC_SRC_DIR",
"The location of the Alembic source to be used if BUILD_DEPENDENCY_ALEMBIC is specified.",
"$DEPENDENCIES_SRC_DIR/Alembic_1.5.0_2013072300",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_CORTEX", "Set this to build cortex.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"CORTEX_SRC_DIR",
"The location of the boost source to be used if BUILD_DEPENDENCY_CORTEX is specified.",
"$DEPENDENCIES_SRC_DIR/cortex",
)
options.Add(
"CORTEX_BUILD_ARGS",
"Additional arguments to be passed when building Cortex.",
"",
)
options.Add(
"CORTEX_POINTDISTRIBUTION_TILESET",
"The tile set file to be used with the IECore::PointDistribution class.",
"$DEPENDENCIES_SRC_DIR/tileset_2048.dat",
)
options.Add(
"RMAN_ROOT",
"The directory in which your RenderMan renderer is installed. Used to build GafferRenderMan.",
"",
)
options.Add(
"ARNOLD_ROOT",
"The directory in which Arnold is installed. Used to build GafferArnold",
"",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_PKGCONFIG", "Set this to build the pkgconfig library.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"PKGCONFIG_SRC_DIR",
"The location of the pkg-config source to be used if BUILD_DEPENDENCY_PKGCONFIG is specified.",
"$DEPENDENCIES_SRC_DIR/pkg-config-0.23",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_GL", "Set this to build PyOpenGL.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"PYOPENGL_SRC_DIR",
"The location of the PyOpenGL source to be used if BUILD_DEPENDENCY_GL is specified.",
"$DEPENDENCIES_SRC_DIR/PyOpenGL-3.0.2",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_QT", "Set this to build QT.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"QT_SRC_DIR",
"The location of QT.",
"$DEPENDENCIES_SRC_DIR/qt-everywhere-opensource-src-4.8.5",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_PYSIDE", "Set this to build PySide.", "$BUILD_DEPENDENCIES" )
)
options.Add(
"SHIBOKEN_SRC_DIR",
"The location of QT.",
"$DEPENDENCIES_SRC_DIR/shiboken-1.2.0",
)
options.Add(
"PYSIDE_SRC_DIR",
"The location of QT.",
"$DEPENDENCIES_SRC_DIR/pyside-qt4.8+1.2.0",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_PYQT", "Set this to build PyQt.", False )
)
options.Add(
"SIP_SRC_DIR",
"The location of SIP.",
"$DEPENDENCIES_SRC_DIR/sip-4.12.3",
)
options.Add(
"PYQT_SRC_DIR",
"The location of SIP.",
"$DEPENDENCIES_SRC_DIR/PyQt-x11-gpl-4.8.4",
)
options.Add(
BoolVariable( "BUILD_DEPENDENCY_FONTS", "", "$BUILD_DEPENDENCIES" )
)
options.Add(
"FONTS_DIR",
"The location of fonts.",
"$DEPENDENCIES_SRC_DIR/ttf-bitstream-vera-1.10",
)
# variables to be used when making a build which will use dependencies previously
# installed in some central location. these are mutually exclusive with the BUILD_*
# variables above, which are all about building the dependencies and packaging them
# with gaffer.
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(
"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.",
"-1",
)
options.Add(
"OCIO_LIB_SUFFIX",
"The suffix used when locating the OpenColorIO 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(
"DOXYGEN",
"Where to find the doxygen binary",
"doxygen",
)
options.Add(
"INKSCAPE",
"Where to find the inkscape binary",
"inkscape",
)
###############################################################################################
# Basic environment object. All the other environments will be based on this.
###############################################################################################
env = Environment(
options = options,
GAFFER_MAJOR_VERSION = "0",
GAFFER_MINOR_VERSION = "81",
GAFFER_PATCH_VERSION = "0",
)
for e in env["ENV_VARS_TO_IMPORT"].split() :
if e in os.environ :
env["ENV"][e] = os.environ[e]
if env["PLATFORM"] == "darwin" :
env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = "10.4"
env.Append( CXXFLAGS = [ "-D__USE_ISOC99" ] )
env["GAFFER_PLATFORM"] = "osx"
elif env["PLATFORM"] == "posix" :
## We really want to not have the -Wno-strict-aliasing flag, but it's necessary to stop boost
# python warnings that don't seem to be prevented by including boost via -isystem even. Better to
# be able to have -Werror but be missing one warning than to have no -Werror.
## \todo This is probably only necessary for specific gcc versions where -isystem doesn't
# fully work. Reenable when we encounter versions that work correctly.
env.Append( CXXFLAGS = [ "-Wno-strict-aliasing" ] )
env["GAFFER_PLATFORM"] = "linux"
if env["BUILD_CACHEDIR"] != "" :
CacheDir( env["BUILD_CACHEDIR"] )
###############################################################################################
# Verify that we're either trying to build and package the dependencies with gaffer, /or/
# trying to build against libraries installed elsewhere, but not both.
###############################################################################################
buildingDependencies = False
locatingDependencies = False
for o in options.options :
if o.key.startswith( "BUILD_DEPENDENC" ) and str( env.subst( "$" + o.key ) ) != str( env.subst( o.default ) ) :
buildingDependencies = True
elif o.key.startswith( "LOCATE_DEPENDENCY" ) and len( env.subst( "$" + o.key ) ) :
locatingDependencies = True
if buildingDependencies and locatingDependencies :
raise RuntimeError( "Cannot specify BUILD_DEPENDENCY_* variables and LOCATE_DEPENDENCY* variables." )
###############################################################################################
# Dependencies
# They doesn't fit into the SCons way of things too well so we just build them directly when
# the script runs.
###############################################################################################
depEnv = env.Clone()
depEnv["ENV"].update(
{
"PATH" : depEnv.subst( "$BUILD_DIR/bin:" + os.environ["PATH"] ),
"PYTHONPATH" : depEnv.subst( "$BUILD_DIR/python" ),
"M4PATH" : depEnv.subst( "$BUILD_DIR/share/aclocal" ),
"PKG_CONFIG_PATH" : depEnv.subst( "$BUILD_DIR/lib/pkgconfig" ),
"CMAKE_PREFIX_PATH" : depEnv.subst( "$BUILD_DIR" ),
"HOME" : os.environ["HOME"],
"CPPFLAGS" : depEnv.subst( "-I$BUILD_DIR/include" ),
"LDFLAGS" : depEnv.subst( "-L$BUILD_DIR/lib" ),
}
)
if depEnv["PLATFORM"]=="darwin" :
depEnv["ENV"]["DYLD_LIBRARY_PATH"] = depEnv.subst( "/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Resources:$BUILD_DIR/lib" )
depEnv["ENV"]["DYLD_FALLBACK_FRAMEWORK_PATH"] = depEnv.subst( "$BUILD_DIR/lib" )
else :
depEnv["ENV"]["LD_LIBRARY_PATH"] = depEnv.subst( "$BUILD_DIR/lib" )
def runCommand( command ) :
command = depEnv.subst( command )
sys.stderr.write( command + "\n" )
subprocess.check_call( command, shell=True, env=depEnv["ENV"] )
if depEnv["BUILD_DEPENDENCY_PKGCONFIG"] :
runCommand( "cd $PKGCONFIG_SRC_DIR && ./configure --prefix=$BUILD_DIR && make clean && make && make install" )
if depEnv["BUILD_DEPENDENCY_PYTHON"] :
if depEnv["PLATFORM"]=="darwin" :
runCommand( "cd $PYTHON_SRC_DIR; ./configure --prefix=$BUILD_DIR --enable-framework=$BUILD_DIR/lib --enable-unicode=ucs4 && make clean && make && make install" )
runCommand( "cd $BUILD_DIR/bin && ln -fsh ../lib/Python.framework/Versions/Current/bin/python python" )
else :
runCommand( "cd $PYTHON_SRC_DIR; ./configure --prefix=$BUILD_DIR --enable-shared --enable-unicode=ucs4 && make clean && make -j 4 && make install" )
# get information about the python we just built
pythonVersion = subprocess.Popen( [ "python", "--version" ], env=depEnv["ENV"], stderr=subprocess.PIPE ).stderr.read().strip()
pythonVersion = pythonVersion.split()[1].rpartition( "." )[0]
pythonLinkFlags = ""
try :
pythonLinkFlags = subprocess.Popen( [ "python-config", "--ldflags" ], env=depEnv["ENV"], stdout=subprocess.PIPE ).stdout.read().strip()
except OSError :
# this should only occur when building gaffer without an integrated python build, and on linux
# at least, it's ok to ignore the warning. basically this is just here for ie's funky setup.
sys.stderr.write( "WARNING : unable to determine python link flags\n" )
pythonLinkFlags = pythonLinkFlags.replace( "Python.framework/Versions/" + pythonVersion + "/Python", "" )
depEnv["PYTHON_LINK_FLAGS"] = pythonLinkFlags
env["PYTHON_LINK_FLAGS"] = pythonLinkFlags
depEnv["PYTHON_VERSION"] = pythonVersion
env["PYTHON_VERSION"] = pythonVersion
if depEnv["BUILD_DEPENDENCY_JPEG"] :
runCommand( "cd $JPEG_SRC_DIR && ./configure --prefix=$BUILD_DIR && make clean && make && make install" )
if depEnv["BUILD_DEPENDENCY_TIFF"] :
runCommand( "cd $TIFF_SRC_DIR && ./configure --prefix=$BUILD_DIR && make clean && make && make install" )
if depEnv["BUILD_DEPENDENCY_PNG"] :
runCommand( "cd $PNG_SRC_DIR && ./configure --prefix=$BUILD_DIR && make clean && make && make install" )
if depEnv["BUILD_DEPENDENCY_FREETYPE"] :
runCommand( "cd $FREETYPE_SRC_DIR && ./configure --prefix=$BUILD_DIR && make clean && make && make install" )
if depEnv["BUILD_DEPENDENCY_BOOST"] :
runCommand( "cd $BOOST_SRC_DIR; ./bootstrap.sh --prefix=$BUILD_DIR --with-python=$BUILD_DIR/bin/python --with-python-root=$BUILD_DIR && ./bjam -d+2 variant=release link=shared threading=multi install" )
if depEnv["BUILD_DEPENDENCY_TBB"] :
runCommand( "cd $TBB_SRC_DIR; make clean; make" )
if depEnv["PLATFORM"]=="darwin" :
runCommand( "cd $TBB_SRC_DIR; cp build/macos_*_release/*.dylib $BUILD_DIR/lib; cp -r include/tbb $BUILD_DIR/include" )
else :
runCommand( "cd $TBB_SRC_DIR; cp build/*_release/*.so* $BUILD_DIR/lib; cp -r include/tbb $BUILD_DIR/include" )
if depEnv["BUILD_DEPENDENCY_OPENEXR"] :
runCommand( "cd $ILMBASE_SRC_DIR && ./configure --prefix=$BUILD_DIR && make clean && make && make install" )
runCommand( "cd $OPENEXR_SRC_DIR && ./configure --prefix=$BUILD_DIR && make clean && make && make install" )
if depEnv["BUILD_DEPENDENCY_FONTS"] :
runCommand( "mkdir -p $BUILD_DIR/fonts && cp $FONTS_DIR/*.ttf $BUILD_DIR/fonts" )
if depEnv["BUILD_DEPENDENCY_GLEW"] :
if depEnv["PLATFORM"]=="posix" :
runCommand( "mkdir -p $BUILD_DIR/lib64/pkgconfig" )
runCommand( "cd $GLEW_SRC_DIR && make clean && make install GLEW_DEST=$BUILD_DIR LIBDIR=$BUILD_DIR/lib" )
if depEnv["BUILD_DEPENDENCY_OCIO"] :
runCommand( "cd $OCIO_SRC_DIR && cmake -DCMAKE_INSTALL_PREFIX=$BUILD_DIR -DOCIO_BUILD_TRUELIGHT=OFF -DOCIO_BUILD_APPS=OFF -DOCIO_BUILD_NUKE=OFF && make clean && make -j 4 && make install" )
runCommand( "mkdir -p $BUILD_DIR/python" )
runCommand( "mv $BUILD_DIR/lib/python$PYTHON_VERSION/site-packages/PyOpenColorIO* $BUILD_DIR/python" )
runCommand( "mkdir -p $BUILD_DIR/openColorIO" )
runCommand( "cp $OCIO_CONFIG_DIR/config.ocio $BUILD_DIR/openColorIO" )
runCommand( "cp -r $OCIO_CONFIG_DIR/luts $BUILD_DIR/openColorIO" )
if depEnv["BUILD_DEPENDENCY_OIIO"] :
runCommand( "cd $OIIO_SRC_DIR && make clean && make THIRD_PARTY_TOOLS_HOME=$BUILD_DIR OCIO_PATH=$BUILD_DIR USE_OPENJPEG=0" )
if depEnv["PLATFORM"]=="darwin" :
runCommand( "cd $OIIO_SRC_DIR && cp -r dist/macosx/* $BUILD_DIR" )
## \todo Come up with something better.
# move the library to a new name so it doesn't conflict with the libOpenImageIO that arnold uses.
# Ideally they'd both use the same one but currently Arnold is using a pre-version-1 version.
runCommand( "mv $BUILD_DIR/lib/libOpenImageIO.dylib $BUILD_DIR/lib/libOpenImageIO-1.dylib" )
else :
runCommand( "cd $OIIO_SRC_DIR && cp -r dist/linux64/* $BUILD_DIR" )
runCommand( "mv $BUILD_DIR/lib/libOpenImageIO.so $BUILD_DIR/lib/libOpenImageIO-1.so" )
if depEnv["BUILD_DEPENDENCY_HDF5"] :
runCommand( "cd $HDF5_SRC_DIR && ./configure --prefix=$BUILD_DIR --enable-threadsafe --with-pthread=/usr/include && make clean && make -j 4 && make install" )
if depEnv["BUILD_DEPENDENCY_ALEMBIC"] :
# may need to hand edit build/AlembicBoost.cmake in the alembic distribution to remove Boost_USE_STATIC_LIBS.
runCommand( "cd $ALEMBIC_SRC_DIR && rm -f CMakeCache.txt && cmake -DCMAKE_INSTALL_PREFIX=$BUILD_DIR -DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_NO_BOOST_CMAKE=TRUE -DBOOST_ROOT=$BUILD_DIR -DILMBASE_ROOT=$BUILD_DIR -DUSE_PYILMBASE=FALSE -DUSE_PYALEMBIC=FALSE && make clean && make -j 4 && make install" )
runCommand( "mv $BUILD_DIR/alembic-*/include/* $BUILD_DIR/include" )
runCommand( "mv $BUILD_DIR/alembic-*/lib/static/* $BUILD_DIR/lib" )
if depEnv["BUILD_DEPENDENCY_CORTEX"] :
runCommand( "cd $CORTEX_SRC_DIR && rm -rf .sconsign.dblite .sconf_temp" )
runCommand(
"cd $CORTEX_SRC_DIR;"
"scons install installDoc -j 3 BUILD_CACHEDIR=$BUILD_CACHEDIR "
"INSTALL_PREFIX=$BUILD_DIR "
"INSTALL_DOC_DIR=$BUILD_DIR/doc/cortex "
"INSTALL_RMANPROCEDURAL_NAME=$BUILD_DIR/renderMan/procedurals/iePython "
"INSTALL_RMANDISPLAY_NAME=$BUILD_DIR/renderMan/displayDrivers/ieDisplay "
"INSTALL_PYTHON_DIR=$BUILD_DIR/python "
"INSTALL_ARNOLDPROCEDURAL_NAME=$BUILD_DIR/arnold/procedurals/ieProcedural.so "
"INSTALL_ARNOLDOUTPUTDRIVER_NAME=$BUILD_DIR/arnold/outputDrivers/ieOutputDriver.so "
"INSTALL_IECORE_OPS='' "
"PYTHON_CONFIG=$BUILD_DIR/bin/python-config "
"BOOST_INCLUDE_PATH=$BUILD_DIR/include/boost "
"LIBPATH=$BUILD_DIR/lib "
"BOOST_LIB_SUFFIX='' "
"OPENEXR_INCLUDE_PATH=$BUILD_DIR/include "
"FREETYPE_INCLUDE_PATH=$BUILD_DIR/include/freetype2 "
"RMAN_ROOT=$DELIGHT "
"WITH_GL=1 "
"GLEW_INCLUDE_PATH=$BUILD_DIR/include/GL "
"RMAN_ROOT=$RMAN_ROOT "
"NUKE_ROOT=$NUKE_ROOT "
"ARNOLD_ROOT=$ARNOLD_ROOT "
"OPTIONS='' "
"DOXYGEN=$DOXYGEN "
"ENV_VARS_TO_IMPORT='LD_LIBRARY_PATH' "
"SAVE_OPTIONS=gaffer.options "
"$CORTEX_BUILD_ARGS"
)
runCommand( "mkdir -p $BUILD_DIR/resources/cortex" )
runCommand( "cp $CORTEX_POINTDISTRIBUTION_TILESET $BUILD_DIR/resources/cortex" )
if depEnv["BUILD_DEPENDENCY_GL"] :
runCommand( "cd $PYOPENGL_SRC_DIR && python setup.py install --prefix $BUILD_DIR --install-lib $BUILD_DIR/python" )
if depEnv["BUILD_DEPENDENCY_QT"] :
runCommand(
"cd $QT_SRC_DIR && ./configure "
"-prefix $BUILD_DIR "
"-opensource -confirm-license "
"-no-rpath -no-declarative -no-gtkstyle -no-qt3support " # these are definitely ok
"-no-multimedia -no-audio-backend -no-webkit -no-script -no-dbus -no-declarative -no-svg " # these might not be
"-nomake examples -nomake demos -nomake tools " # i hope these are
"-I $BUILD_DIR/include -L $BUILD_DIR/lib "
"&& make -j 4 && make install"
)
if depEnv["BUILD_DEPENDENCY_PYQT"] :
runCommand( "cd $SIP_SRC_DIR && python configure.py -d $BUILD_DIR/python && make clean && make && make install" )
runCommand( "cd $PYQT_SRC_DIR && python configure.py -d $BUILD_DIR/python --confirm-license && make && make install" )
# having MACOS_DEPLOYMENT_TARGET set breaks the pyside build for some reason
if "MACOSX_DEPLOYMENT_TARGET" in depEnv["ENV"] :
del depEnv["ENV"]["MACOSX_DEPLOYMENT_TARGET"]
if depEnv["BUILD_DEPENDENCY_PYSIDE"] :
if depEnv["PLATFORM"]=="darwin" :
runCommand(
"cd $SHIBOKEN_SRC_DIR && "
"rm -rf build && mkdir build && cd build && "
"cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_SITE_PACKAGES=$BUILD_DIR/python -DCMAKE_INSTALL_PREFIX=$BUILD_DIR -DPYTHON_INCLUDE_DIR=$BUILD_DIR/lib/Python.framework/Headers -DPYTHON_EXECUTABLE=$BUILD_DIR/bin/python -DPYTHON_LIBRARY=$BUILD_DIR/Python.framework/Versions/$PYTHON_VERSION/libpython${PYTHON_VERSION}.dylib && "
"make clean && make -j 4 && make install"
)
runCommand(
"cd $PYSIDE_SRC_DIR && "
"rm -rf build && mkdir build && cd build && "
"cmake .. -DCMAKE_BUILD_TYPE=Release -DSITE_PACKAGE=$BUILD_DIR/python -DCMAKE_INSTALL_PREFIX=$BUILD_DIR -DALTERNATIVE_QT_INCLUDE_DIR=$BUILD_DIR/include && "
"make clean && make -j 4 && make install"
)
else :
runCommand(
"cd $SHIBOKEN_SRC_DIR && "
"rm -rf build && mkdir build && cd build && "
"cmake .. -DCMAKE_BUILD_TYPE=Release -DPYTHON_SITE_PACKAGES=$BUILD_DIR/python -DCMAKE_INSTALL_PREFIX=$BUILD_DIR -DPYTHON_INCLUDE_DIR=$BUILD_DIR/include/python$PYTHON_VERSION && "
"make clean && make -j 4 && make install"
)
runCommand(
"cd $PYSIDE_SRC_DIR && cmake "
"-DSITE_PACKAGE=$BUILD_DIR/python -DCMAKE_INSTALL_PREFIX=$BUILD_DIR "
"&& make clean && make -j 4 && make install"
)
###############################################################################################
# The basic environment for building libraries
###############################################################################################
if buildingDependencies :
boostLibSuffix = ""
else :
boostLibSuffix = env["BOOST_LIB_SUFFIX"]
baseLibEnv = env.Clone()
baseLibEnv.Append(
CPPPATH = [
"include",
] + env["LOCATE_DEPENDENCY_CPPPATH"],
CPPFLAGS = [
"-DBOOST_FILESYSTEM_VERSION=3",
],
LIBPATH = [
"./lib",
"$BUILD_DIR/lib",
"$LOCATE_DEPENDENCY_LIBPATH",
],
LIBS = [
"boost_signals" + boostLibSuffix,
"boost_iostreams" + boostLibSuffix,
"boost_filesystem" + boostLibSuffix,
"boost_date_time" + boostLibSuffix,
"boost_thread" + boostLibSuffix,
"boost_wave" + boostLibSuffix,
"boost_regex" + boostLibSuffix,
"boost_system" + boostLibSuffix,
"tbb",
"Imath$OPENEXR_LIB_SUFFIX",
"IlmImf$OPENEXR_LIB_SUFFIX",
"IECore$CORTEX_LIB_SUFFIX",
],
)
# include 3rd party headers with -isystem rather than -I.
# this should turns 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 - note that
# we're still having to turn off strict aliasing warnings in the
# default CXXFLAGS because somehow they creep out of boost python
# and past the defences.
for path in [
"$BUILD_DIR/include",
"$BUILD_DIR/include/python$PYTHON_VERSION",
"$BUILD_DIR/include/OpenEXR",
"$BUILD_DIR/include/GL",
] + env["LOCATE_DEPENDENCY_SYSTEMPATH"] :
baseLibEnv.Append(
CXXFLAGS = [ "-isystem", path ]
)
###############################################################################################
# The basic environment for building python modules
###############################################################################################
basePythonEnv = baseLibEnv.Clone()
basePythonEnv.Append(
CPPFLAGS = [
"-DBOOST_PYTHON_MAX_ARITY=20",
],
LIBS = [
"boost_python" + boostLibSuffix,
"IECorePython$CORTEX_PYTHON_LIB_SUFFIX",
"Gaffer",
],
)
basePythonEnv.Append(
CPPFLAGS = os.popen( basePythonEnv.subst( "$BUILD_DIR/bin/python$PYTHON_VERSION-config --includes" ) ).read().split(),
SHLINKFLAGS = "$PYTHON_LINK_FLAGS",
)
if basePythonEnv["PLATFORM"]=="darwin" :
basePythonEnv.Append( SHLINKFLAGS = "-single_module" )
###############################################################################################
# Definitions for the libraries we wish to build
###############################################################################################
libraries = {
"Gaffer" : {
},
"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", "GLEW$GLEW_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "IECoreGL$CORTEX_LIB_SUFFIX", "GafferUI", "GafferBindings" ],
},
},
"GafferUITest" : {},
"GafferScene" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "Iex$OPENEXR_LIB_SUFFIX", "IECoreGL$CORTEX_LIB_SUFFIX", "IECoreAlembic$CORTEX_LIB_SUFFIX", "GafferImage" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferBindings", "GafferScene" ],
},
"classStubs" : [
( "ScriptProcedural", "procedurals/gaffer/script" ),
],
"additionalFiles" : glob.glob( "glsl/*.frag" ) + glob.glob( "glsl/*.vert" ),
},
"GafferSceneTest" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "GafferScene" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "Gaffer", "GafferBindings", "GafferScene", "GafferSceneTest" ],
},
"additionalFiles" : glob.glob( "python/GafferSceneTest/*/*" ),
},
"GafferSceneUI" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "GafferUI", "GafferScene" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferUI", "GafferSceneUI" ],
},
},
"GafferImage" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "Iex$OPENEXR_LIB_SUFFIX", "OpenImageIO$OIIO_LIB_SUFFIX", "OpenColorIO$OCIO_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferBindings", "GafferImage" ],
},
"requiredOptions" : [ "OIIO_SRC_DIR", "OCIO_SRC_DIR" ],
},
"GafferImageTest" : {},
"GafferImageUITest" : {},
"GafferImageUI" : {
"envAppends" : {
"LIBS" : [ "IECoreGL$CORTEX_LIB_SUFFIX", "Gaffer", "GafferImage", "GafferUI", "GLEW$GLEW_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferUI", "GafferImageUI" ],
},
},
"GafferArnold" : {
"envAppends" : {
"CPPPATH" : [ "$ARNOLD_ROOT/include" ],
"LIBPATH" : [ "$ARNOLD_ROOT/bin" ],
"LIBS" : [ "Gaffer", "GafferScene", "ai", "IECoreArnold$CORTEX_LIB_SUFFIX" ],
},
"pythonEnvAppends" : {
"CPPPATH" : [ "$ARNOLD_ROOT/include" ],
"LIBPATH" : [ "$ARNOLD_ROOT/bin" ],
"LIBS" : [ "Gaffer", "GafferScene", "GafferBindings", "GafferArnold" ],
},
"requiredOptions" : [ "ARNOLD_ROOT" ],
},
"GafferArnoldTest" : {},
"GafferArnoldUI" : {},
"GafferRenderMan" : {
"envAppends" : {
"LIBS" : [ "Gaffer", "GafferScene", "IECoreRI$CORTEX_LIB_SUFFIX" ],
"LIBPATH" : [ "$RMAN_ROOT/lib" ],
},
"pythonEnvAppends" : {
"LIBS" : [ "GafferBindings", "GafferScene", "GafferRenderMan" ],
"LIBPATH" : [ "$RMAN_ROOT/lib" ],
},
"requiredOptions" : [ "RMAN_ROOT" ],
},
"GafferRenderManUI" : {},
"GafferRenderManTest" : {
"additionalFiles" : glob.glob( "python/GafferRenderManTest/*/*" ),
},
"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" : [
# images
( "ImageThinner", "ops/image/thinner" ),
( "Grade", "ops/image/composite" ),
( "ImagePremultiplyOp", "ops/image/premultiply" ),
( "ImageUnpremultiplyOp", "ops/image/unpremultiply" ),
( "Grade", "ops/image/grade" ),
( "CurveTracer", "ops/image/traceCurves" ),
# curves
( "CurveExtrudeOp", "ops/curves/extrude" ),
( "CurveLineariser", "ops/curves/linearise" ),
( "CurvesMergeOp", "ops/curves/merge" ),
( "CurveTangentsOp", "ops/curves/tangents" ),
# meshes
( "TriangulateOp", "ops/mesh/triangulate" ),
( "FaceAreaOp", "ops/mesh/faceArea" ),
( "MeshMergeOp", "ops/mesh/merge" ),
( "MeshNormalsOp", "ops/mesh/normals" ),
# primitives
( "TransformOp", "ops/primitive/transform" ),
( "RenamePrimitiveVariables", "ops/primitive/renameVariables" ),
# 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" ),
# procedurals
( "ReadProcedural", "procedurals/read" ),
],
},
"IECoreAlembic" : {
"classStubs" : [
( "ABCToMDC", "ops/files/abcToMDC" ),
],