Skip to content

Commit 8359030

Browse files
author
Clement Champetier
committed
SConstruct: manage C++ environment for win
1 parent d91487a commit 8359030

File tree

1 file changed

+61
-19
lines changed

1 file changed

+61
-19
lines changed

SConstruct

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ pyInclude = config.get( 'PYTHON', 'inc' ).split( splitChar )
4848
libavInclude = config.get( 'LIBAV', 'inc' ).split( splitChar )
4949
libavLibDir = config.get( 'LIBAV', 'libdir' ).split( splitChar )
5050

51-
env = Environment().Clone()
52-
envJava = Environment().Clone()
53-
envPy = Environment().Clone()
51+
env = Environment( ENV = { 'PATH' : os.environ[ 'PATH' ] } )
5452

5553
# C++ environment
5654
env.Append(
@@ -69,8 +67,37 @@ env.Append(
6967
] + commonLibDir,
7068
)
7169

70+
if os.name == "nt" and sys.platform.startswith("win"): # detect windows plateform
71+
env.AppendUnique( CPPDEFINES = 'WIN' )
72+
env.AppendUnique( CPPDEFINES = 'WIN32' )
73+
env.AppendUnique( CPPDEFINES = 'WINDOWS' )
74+
env.AppendUnique( CPPDEFINES = '_WINDOWS' )
75+
env.AppendUnique( CPPDEFINES = '__WINDOWS__' )
76+
env.AppendUnique( CPPDEFINES = '__STDC_CONSTANT_MACROS' )
77+
bits = 64
78+
if 'PROGRAMFILES(X86)' not in os.environ:
79+
bits = 32
80+
env.AppendUnique( CPPDEFINES = 'WIN'+str(bits) )
81+
env.AppendUnique( TMP = os.environ['TMP'].split( splitChar ) )
82+
83+
if 'LIB' not in os.environ or 'LIBPATH' not in os.environ :
84+
print "Compiler environment not set."
85+
sys.exit( -1 )
86+
env.AppendUnique( LIB = os.environ['LIB'].split( splitChar ) )
87+
env.AppendUnique( LIBPATH = os.environ['LIBPATH'].split( splitChar ) )
88+
env.AppendUnique( TMP = os.environ['TMP'].split( splitChar ) )
89+
else:
90+
env.AppendUnique( CPPDEFINES = 'UNIX' )
91+
env.AppendUnique( CPPDEFINES = '__UNIX__' )
92+
env.AppendUnique( CXXFLAGS = '-fPIC' ),
93+
if sys.platform.startswith( "darwin" ): # for disabling macros such as check, verify, require ... ( AssertMacros.h )
94+
env.AppendUnique( CPPDEFINES = '__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0' )
95+
96+
envJava = Environment().Clone()
97+
envPy = Environment().Clone()
98+
7299
# Java environment
73-
envJava.Replace(
100+
envJava.AppendUnique(
74101
CPPPATH = [
75102
javaInclude,
76103
libavInclude,
@@ -93,11 +120,10 @@ envJava.Replace(
93120
],
94121
JARCHDIR = env.Dir('#build/'+mymode+'/src/AvTranscoder').get_abspath(),
95122
)
96-
97123
envJava.Append(
98124
SWIGPATH = envJava['CPPPATH'],
99125
SWIGFLAGS = [ '-package', 'org.AvTranscoder' ],
100-
)
126+
)
101127

102128
# Python environment
103129
envPy.Replace(
@@ -123,31 +149,47 @@ envPy.Replace(
123149
"#src",
124150
],
125151
)
126-
127152
envPy.Append( SWIGPATH = envPy['CPPPATH'] )
128153

129154
conf = Configure( env )
130155

131156
resampleLibraryFlag = '-DAV_RESAMPLE_LIBRARY'
132157
resampleLibraryName = 'avresample'
133158

134-
if not conf.CheckLibWithHeader('avutil', 'libavutil/avutil.h', 'c'):
135-
sys.exit( 0 )
159+
if os.name == "nt" and sys.platform.startswith("win"): # detect windows plateform
160+
if not conf.CheckLibWithHeader('avutil', 'libavutil/avutil.h', 'c++'):
161+
sys.exit( -1 )
162+
163+
if not conf.CheckLibWithHeader('avcodec', 'libavcodec/avcodec.h', 'c++'):
164+
sys.exit( -1 )
165+
166+
if not conf.CheckLibWithHeader('avformat', 'libavformat/avformat.h', 'c++'):
167+
sys.exit( -1 )
168+
169+
if not conf.CheckLibWithHeader('swscale', 'libswscale/swscale.h', 'c++'):
170+
sys.exit( -1 )
136171

137-
if not conf.CheckLibWithHeader('avresample', 'libavresample/avresample.h', 'c'):
138-
if conf.CheckLibWithHeader('swresample', 'libswresample/swresample.h', 'c'):
139-
resampleLibraryFlag = '-DFF_RESAMPLE_LIBRARY'
140-
resampleLibraryName = 'swresample'
172+
if not conf.CheckLibWithHeader('avresample', 'libavresample/avresample.h', 'c++'):
173+
if conf.CheckLibWithHeader('swresample', 'libswresample/swresample.h', 'c++'):
174+
resampleLibraryFlag = '-DFF_RESAMPLE_LIBRARY'
175+
resampleLibraryName = 'swresample'
176+
else:
177+
if not conf.CheckLibWithHeader('avutil', 'libavutil/avutil.h', 'c'):
178+
sys.exit( -1 )
141179

142-
if not conf.CheckLibWithHeader('avcodec', 'libavcodec/avcodec.h', 'c'):
143-
sys.exit( 0 )
180+
if not conf.CheckLibWithHeader('avcodec', 'libavcodec/avcodec.h', 'c'):
181+
sys.exit( -1 )
144182

145-
if not conf.CheckLibWithHeader('avformat', 'libavformat/avformat.h', 'c'):
146-
sys.exit( 0 )
183+
if not conf.CheckLibWithHeader('avformat', 'libavformat/avformat.h', 'c'):
184+
sys.exit( -1 )
147185

148-
if not conf.CheckLibWithHeader('swscale', 'libswscale/swscale.h', 'c'):
149-
sys.exit( 0 )
186+
if not conf.CheckLibWithHeader('swscale', 'libswscale/swscale.h', 'c'):
187+
sys.exit( -1 )
150188

189+
if not conf.CheckLibWithHeader('avresample', 'libavresample/avresample.h', 'c'):
190+
if conf.CheckLibWithHeader('swresample', 'libswresample/swresample.h', 'c'):
191+
resampleLibraryFlag = '-DFF_RESAMPLE_LIBRARY'
192+
resampleLibraryName = 'swresample'
151193

152194
env.Append(
153195
CXXFLAGS = resampleLibraryFlag

0 commit comments

Comments
 (0)