Skip to content

Commit 7a9f966

Browse files
Merge pull request #67 from cchampet/build_windows
Build windows
2 parents dcc32da + 261a9db commit 7a9f966

File tree

2 files changed

+89
-52
lines changed

2 files changed

+89
-52
lines changed

SConstruct

Lines changed: 75 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ config.read( [
1616
'scons.cfg',
1717
] )
1818

19-
icommonInclude = []
19+
commonInclude = []
2020
commonLibDir = []
2121
installPrefix = "/usr/local"
2222

@@ -44,20 +44,23 @@ if not config.has_section( 'PYTHON' ):
4444

4545

4646
javaInclude = config.get( 'JAVA', 'inc' ).split( splitChar )
47+
4748
pyInclude = config.get( 'PYTHON', 'inc' ).split( splitChar )
49+
pyLibrary = []
50+
if config.has_option( 'PYTHON', 'libdir' ):
51+
pyLibrary = config.get( 'PYTHON', 'libdir' ).split( splitChar )
52+
4853
libavInclude = config.get( 'LIBAV', 'inc' ).split( splitChar )
4954
libavLibDir = config.get( 'LIBAV', 'libdir' ).split( splitChar )
5055

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

5558
# C++ environment
5659
env.Append(
5760
CPPPATH = [
5861
libavInclude,
5962
"#src",
60-
],
63+
] + commonInclude,
6164
CXXFLAGS = [
6265
'-Wall',
6366
'-fPIC',
@@ -66,88 +69,108 @@ env.Append(
6669
libavLibDir,
6770
"#src",
6871
"#build/src"
69-
],
72+
] + commonLibDir,
7073
)
7174

75+
if os.name == "nt" and sys.platform.startswith("win"): # detect windows plateform
76+
env.AppendUnique( CPPDEFINES = 'WIN' )
77+
env.AppendUnique( CPPDEFINES = 'WIN32' )
78+
env.AppendUnique( CPPDEFINES = 'WINDOWS' )
79+
env.AppendUnique( CPPDEFINES = '_WINDOWS' )
80+
env.AppendUnique( CPPDEFINES = '__WINDOWS__' )
81+
env.AppendUnique( CPPDEFINES = '__STDC_CONSTANT_MACROS' )
82+
bits = 64
83+
if 'PROGRAMFILES(X86)' not in os.environ:
84+
bits = 32
85+
env.AppendUnique( CPPDEFINES = 'WIN'+str(bits) )
86+
env.AppendUnique( TMP = os.environ['TMP'].split( splitChar ) )
87+
88+
if 'LIB' not in os.environ or 'LIBPATH' not in os.environ :
89+
print "Compiler environment not set."
90+
sys.exit( -1 )
91+
env.AppendUnique( LIB = os.environ['LIB'].split( splitChar ) )
92+
env.AppendUnique( LIBPATH = os.environ['LIBPATH'].split( splitChar ) )
93+
env.AppendUnique( TMP = os.environ['TMP'].split( splitChar ) )
94+
else:
95+
env.AppendUnique( CPPDEFINES = 'UNIX' )
96+
env.AppendUnique( CPPDEFINES = '__UNIX__' )
97+
if sys.platform.startswith( "darwin" ): # for disabling macros such as check, verify, require ... ( AssertMacros.h )
98+
env.AppendUnique( CPPDEFINES = '__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0' )
99+
100+
envJava = env.Clone()
101+
envPy = env.Clone()
102+
72103
# Java environment
73104
envJava.Replace(
74-
CPPPATH = [
75-
javaInclude,
76-
libavInclude,
77-
".",
78-
],
79105
SWIGCXXFILESUFFIX= '_wrapJava$CXXFILESUFFIX',
80-
CXXFLAGS = [
81-
'-Wall',
82-
],
83106
SWIGFLAGS = [
84107
'-java',
85108
'-c++',
86109
'-fcompact',
87110
],
88-
LINKFLAGS = [
89-
],
90-
LIBPATH = [
91-
libavLibDir,
92-
"#src",
93-
],
94-
JARCHDIR = env.Dir('#build/'+mymode+'/src/AvTranscoder').get_abspath(),
95111
)
96-
97-
envJava.Append(
112+
envJava.AppendUnique(
113+
CPPPATH = javaInclude,
98114
SWIGPATH = envJava['CPPPATH'],
99115
SWIGFLAGS = [ '-package', 'org.AvTranscoder' ],
100-
)
116+
JARCHDIR = env.Dir('#build/'+mymode+'/src/AvTranscoder').get_abspath(),
117+
)
101118

102119
# Python environment
103120
envPy.Replace(
104-
CPPPATH = [
105-
pyInclude,
106-
libavInclude,
107-
".",
108-
],
109121
SWIGCXXFILESUFFIX= '_wrapPython$CXXFILESUFFIX',
110122
SHLIBPREFIX= '_',
111-
CXXFLAGS = [
112-
'-Wall',
113-
],
114123
SWIGFLAGS = [
115124
'-python',
116125
'-c++',
117126
'-fcompact',
118127
],
119-
LINKFLAGS = [
120-
],
121-
LIBPATH = [
122-
libavLibDir,
123-
"#src",
124-
],
125128
)
126-
127-
envPy.Append( SWIGPATH = envPy['CPPPATH'] )
129+
envPy.AppendUnique(
130+
CPPPATH = pyInclude,
131+
LIBPATH = pyLibrary,
132+
SWIGPATH = envPy['CPPPATH']
133+
)
128134

129135
conf = Configure( env )
130136

131137
resampleLibraryFlag = '-DAV_RESAMPLE_LIBRARY'
132138
resampleLibraryName = 'avresample'
133139

134-
if not conf.CheckLibWithHeader('avutil', 'libavutil/avutil.h', 'c'):
135-
sys.exit( 0 )
140+
if os.name == "nt" and sys.platform.startswith("win"): # detect windows plateform
141+
if not conf.CheckLibWithHeader('avutil', 'libavutil/avutil.h', 'c++'):
142+
sys.exit( -1 )
143+
144+
if not conf.CheckLibWithHeader('avcodec', 'libavcodec/avcodec.h', 'c++'):
145+
sys.exit( -1 )
146+
147+
if not conf.CheckLibWithHeader('avformat', 'libavformat/avformat.h', 'c++'):
148+
sys.exit( -1 )
149+
150+
if not conf.CheckLibWithHeader('swscale', 'libswscale/swscale.h', 'c++'):
151+
sys.exit( -1 )
136152

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'
153+
if not conf.CheckLibWithHeader('avresample', 'libavresample/avresample.h', 'c++'):
154+
if conf.CheckLibWithHeader('swresample', 'libswresample/swresample.h', 'c++'):
155+
resampleLibraryFlag = '-DFF_RESAMPLE_LIBRARY'
156+
resampleLibraryName = 'swresample'
157+
else:
158+
if not conf.CheckCHeader('libavutil/avutil.h'):
159+
sys.exit( -1 )
141160

142-
if not conf.CheckLibWithHeader('avcodec', 'libavcodec/avcodec.h', 'c'):
143-
sys.exit( 0 )
161+
if not conf.CheckCHeader('libavcodec/avcodec.h'):
162+
sys.exit( -1 )
144163

145-
if not conf.CheckLibWithHeader('avformat', 'libavformat/avformat.h', 'c'):
146-
sys.exit( 0 )
164+
if not conf.CheckCHeader('libavformat/avformat.h'):
165+
sys.exit( -1 )
147166

148-
if not conf.CheckLibWithHeader('swscale', 'libswscale/swscale.h', 'c'):
149-
sys.exit( 0 )
167+
if not conf.CheckCHeader('libswscale/swscale.h'):
168+
sys.exit( -1 )
150169

170+
if not conf.CheckCHeader('libavresample/avresample.h'):
171+
if conf.CheckCHeader('libswresample/swresample.h'):
172+
resampleLibraryFlag = '-DFF_RESAMPLE_LIBRARY'
173+
resampleLibraryName = 'swresample'
151174

152175
env.Append(
153176
CXXFLAGS = resampleLibraryFlag

tools/scons.windows7.cfg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[COMMON]
2+
inc=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\msinttypes;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include
3+
libdir=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
4+
5+
[LIBAV]
6+
inc=C:\local_build\build-ffmpeg-2.3\include
7+
libdir=C:\local_build\build-ffmpeg-2.3\bin;C:\local_build\build-ffmpeg-2.3\lib
8+
9+
[PYTHON]
10+
inc=C:\Python27\include
11+
libdir=C:\Python27\libs
12+
13+
[JAVA]
14+
inc=C:\Program Files (x86)\Java\jdk1.7.0_51\include;C:\Program Files (x86)\Java\jdk1.7.0_51\include\win32

0 commit comments

Comments
 (0)