From 3ce7e25f59b0741b4b20b1f943d9f82d20bb94a0 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Tue, 19 Aug 2014 15:07:19 +0200 Subject: [PATCH 1/8] Scons tool: add windows7 scons example --- tools/scons.windows7.cfg | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tools/scons.windows7.cfg diff --git a/tools/scons.windows7.cfg b/tools/scons.windows7.cfg new file mode 100644 index 00000000..fe203c22 --- /dev/null +++ b/tools/scons.windows7.cfg @@ -0,0 +1,14 @@ +[COMMON] +inc=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\msinttypes;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include +libdir=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib + +[LIBAV] +inc=C:\local_build\build-ffmpeg-2.3\include +libdir=C:\local_build\build-ffmpeg-2.3\bin;C:\local_build\build-ffmpeg-2.3\lib + +[PYTHON] +inc=C:\Python27\include +libdir=C:\Python27\libs + +[JAVA] +inc=C:\Program Files (x86)\Java\jdk1.7.0_51\include;C:\Program Files (x86)\Java\jdk1.7.0_51\include\win32 From 709a56a1c2939ca61ba293338c50ab571a2b8122 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Tue, 19 Aug 2014 15:12:24 +0200 Subject: [PATCH 2/8] SConscript: fix script if config has section 'COMMON' --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index f3ffbb90..8d32ee24 100644 --- a/SConstruct +++ b/SConstruct @@ -16,7 +16,7 @@ config.read( [ 'scons.cfg', ] ) -icommonInclude = [] +commonInclude = [] commonLibDir = [] installPrefix = "/usr/local" From d91487a7328e33389c9eb66ce06be11a82b4595a Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 21 Aug 2014 13:15:44 +0200 Subject: [PATCH 3/8] SConstruct: add common paths to env --- SConstruct | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 8d32ee24..8aae1586 100644 --- a/SConstruct +++ b/SConstruct @@ -57,7 +57,7 @@ env.Append( CPPPATH = [ libavInclude, "#src", - ], + ] + commonInclude, CXXFLAGS = [ '-Wall', '-fPIC', @@ -66,7 +66,7 @@ env.Append( libavLibDir, "#src", "#build/src" - ], + ] + commonLibDir, ) # Java environment From 83590309186dabceec40a4d2391f6924143dc845 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 21 Aug 2014 13:38:56 +0200 Subject: [PATCH 4/8] SConstruct: manage C++ environment for win --- SConstruct | 80 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/SConstruct b/SConstruct index 8aae1586..2e253db5 100644 --- a/SConstruct +++ b/SConstruct @@ -48,9 +48,7 @@ pyInclude = config.get( 'PYTHON', 'inc' ).split( splitChar ) libavInclude = config.get( 'LIBAV', 'inc' ).split( splitChar ) libavLibDir = config.get( 'LIBAV', 'libdir' ).split( splitChar ) -env = Environment().Clone() -envJava = Environment().Clone() -envPy = Environment().Clone() +env = Environment( ENV = { 'PATH' : os.environ[ 'PATH' ] } ) # C++ environment env.Append( @@ -69,8 +67,37 @@ env.Append( ] + commonLibDir, ) +if os.name == "nt" and sys.platform.startswith("win"): # detect windows plateform + env.AppendUnique( CPPDEFINES = 'WIN' ) + env.AppendUnique( CPPDEFINES = 'WIN32' ) + env.AppendUnique( CPPDEFINES = 'WINDOWS' ) + env.AppendUnique( CPPDEFINES = '_WINDOWS' ) + env.AppendUnique( CPPDEFINES = '__WINDOWS__' ) + env.AppendUnique( CPPDEFINES = '__STDC_CONSTANT_MACROS' ) + bits = 64 + if 'PROGRAMFILES(X86)' not in os.environ: + bits = 32 + env.AppendUnique( CPPDEFINES = 'WIN'+str(bits) ) + env.AppendUnique( TMP = os.environ['TMP'].split( splitChar ) ) + + if 'LIB' not in os.environ or 'LIBPATH' not in os.environ : + print "Compiler environment not set." + sys.exit( -1 ) + env.AppendUnique( LIB = os.environ['LIB'].split( splitChar ) ) + env.AppendUnique( LIBPATH = os.environ['LIBPATH'].split( splitChar ) ) + env.AppendUnique( TMP = os.environ['TMP'].split( splitChar ) ) +else: + env.AppendUnique( CPPDEFINES = 'UNIX' ) + env.AppendUnique( CPPDEFINES = '__UNIX__' ) + env.AppendUnique( CXXFLAGS = '-fPIC' ), + if sys.platform.startswith( "darwin" ): # for disabling macros such as check, verify, require ... ( AssertMacros.h ) + env.AppendUnique( CPPDEFINES = '__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0' ) + +envJava = Environment().Clone() +envPy = Environment().Clone() + # Java environment -envJava.Replace( +envJava.AppendUnique( CPPPATH = [ javaInclude, libavInclude, @@ -93,11 +120,10 @@ envJava.Replace( ], JARCHDIR = env.Dir('#build/'+mymode+'/src/AvTranscoder').get_abspath(), ) - envJava.Append( SWIGPATH = envJava['CPPPATH'], SWIGFLAGS = [ '-package', 'org.AvTranscoder' ], - ) +) # Python environment envPy.Replace( @@ -123,7 +149,6 @@ envPy.Replace( "#src", ], ) - envPy.Append( SWIGPATH = envPy['CPPPATH'] ) conf = Configure( env ) @@ -131,23 +156,40 @@ conf = Configure( env ) resampleLibraryFlag = '-DAV_RESAMPLE_LIBRARY' resampleLibraryName = 'avresample' -if not conf.CheckLibWithHeader('avutil', 'libavutil/avutil.h', 'c'): - sys.exit( 0 ) +if os.name == "nt" and sys.platform.startswith("win"): # detect windows plateform + if not conf.CheckLibWithHeader('avutil', 'libavutil/avutil.h', 'c++'): + sys.exit( -1 ) + + if not conf.CheckLibWithHeader('avcodec', 'libavcodec/avcodec.h', 'c++'): + sys.exit( -1 ) + + if not conf.CheckLibWithHeader('avformat', 'libavformat/avformat.h', 'c++'): + sys.exit( -1 ) + + if not conf.CheckLibWithHeader('swscale', 'libswscale/swscale.h', 'c++'): + sys.exit( -1 ) -if not conf.CheckLibWithHeader('avresample', 'libavresample/avresample.h', 'c'): - if conf.CheckLibWithHeader('swresample', 'libswresample/swresample.h', 'c'): - resampleLibraryFlag = '-DFF_RESAMPLE_LIBRARY' - resampleLibraryName = 'swresample' + if not conf.CheckLibWithHeader('avresample', 'libavresample/avresample.h', 'c++'): + if conf.CheckLibWithHeader('swresample', 'libswresample/swresample.h', 'c++'): + resampleLibraryFlag = '-DFF_RESAMPLE_LIBRARY' + resampleLibraryName = 'swresample' +else: + if not conf.CheckLibWithHeader('avutil', 'libavutil/avutil.h', 'c'): + sys.exit( -1 ) -if not conf.CheckLibWithHeader('avcodec', 'libavcodec/avcodec.h', 'c'): - sys.exit( 0 ) + if not conf.CheckLibWithHeader('avcodec', 'libavcodec/avcodec.h', 'c'): + sys.exit( -1 ) -if not conf.CheckLibWithHeader('avformat', 'libavformat/avformat.h', 'c'): - sys.exit( 0 ) + if not conf.CheckLibWithHeader('avformat', 'libavformat/avformat.h', 'c'): + sys.exit( -1 ) -if not conf.CheckLibWithHeader('swscale', 'libswscale/swscale.h', 'c'): - sys.exit( 0 ) + if not conf.CheckLibWithHeader('swscale', 'libswscale/swscale.h', 'c'): + sys.exit( -1 ) + if not conf.CheckLibWithHeader('avresample', 'libavresample/avresample.h', 'c'): + if conf.CheckLibWithHeader('swresample', 'libswresample/swresample.h', 'c'): + resampleLibraryFlag = '-DFF_RESAMPLE_LIBRARY' + resampleLibraryName = 'swresample' env.Append( CXXFLAGS = resampleLibraryFlag From 6a806030b9bbf113c06b7cbae6f889f246114ac0 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 21 Aug 2014 14:50:21 +0200 Subject: [PATCH 5/8] Sconscript: base envJava and envPy on C++ environment Create java and python environments is simplier. --- SConstruct | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/SConstruct b/SConstruct index 2e253db5..85ce038a 100644 --- a/SConstruct +++ b/SConstruct @@ -93,63 +93,39 @@ else: if sys.platform.startswith( "darwin" ): # for disabling macros such as check, verify, require ... ( AssertMacros.h ) env.AppendUnique( CPPDEFINES = '__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0' ) -envJava = Environment().Clone() -envPy = Environment().Clone() +envJava = env.Clone() +envPy = env.Clone() # Java environment -envJava.AppendUnique( - CPPPATH = [ - javaInclude, - libavInclude, - ".", - ], +envJava.Replace( SWIGCXXFILESUFFIX= '_wrapJava$CXXFILESUFFIX', - CXXFLAGS = [ - '-Wall', - ], SWIGFLAGS = [ '-java', '-c++', '-fcompact', ], - LINKFLAGS = [ - ], - LIBPATH = [ - libavLibDir, - "#src", - ], - JARCHDIR = env.Dir('#build/'+mymode+'/src/AvTranscoder').get_abspath(), ) -envJava.Append( +envJava.AppendUnique( + CPPPATH = javaInclude, SWIGPATH = envJava['CPPPATH'], SWIGFLAGS = [ '-package', 'org.AvTranscoder' ], + JARCHDIR = env.Dir('#build/'+mymode+'/src/AvTranscoder').get_abspath(), ) # Python environment envPy.Replace( - CPPPATH = [ - pyInclude, - libavInclude, - ".", - ], SWIGCXXFILESUFFIX= '_wrapPython$CXXFILESUFFIX', SHLIBPREFIX= '_', - CXXFLAGS = [ - '-Wall', - ], SWIGFLAGS = [ '-python', '-c++', '-fcompact', ], - LINKFLAGS = [ - ], - LIBPATH = [ - libavLibDir, - "#src", - ], ) -envPy.Append( SWIGPATH = envPy['CPPPATH'] ) +envPy.AppendUnique( + CPPPATH = pyInclude, + SWIGPATH = envPy['CPPPATH'] +) conf = Configure( env ) From 013c278d42858ea97e64956b51ad4d11e9247d58 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 21 Aug 2014 15:07:32 +0200 Subject: [PATCH 6/8] SConstruct: fix win build by adding python to LIBPATH --- SConstruct | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SConstruct b/SConstruct index 85ce038a..00923c60 100644 --- a/SConstruct +++ b/SConstruct @@ -44,7 +44,12 @@ if not config.has_section( 'PYTHON' ): javaInclude = config.get( 'JAVA', 'inc' ).split( splitChar ) + pyInclude = config.get( 'PYTHON', 'inc' ).split( splitChar ) +pyLibrary = [] +if config.has_option( 'PYTHON', 'libdir' ): + pyLibrary = config.get( 'PYTHON', 'libdir' ).split( splitChar ) + libavInclude = config.get( 'LIBAV', 'inc' ).split( splitChar ) libavLibDir = config.get( 'LIBAV', 'libdir' ).split( splitChar ) @@ -124,6 +129,7 @@ envPy.Replace( ) envPy.AppendUnique( CPPPATH = pyInclude, + LIBPATH = pyLibrary, SWIGPATH = envPy['CPPPATH'] ) From 58444f76bffd9e9894f2e25efc297d4edc840dc4 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 21 Aug 2014 15:34:35 +0200 Subject: [PATCH 7/8] SConscript: clean Remove duplicate variable on C++ environment. --- SConstruct | 1 - 1 file changed, 1 deletion(-) diff --git a/SConstruct b/SConstruct index 00923c60..fae2c9ad 100644 --- a/SConstruct +++ b/SConstruct @@ -94,7 +94,6 @@ if os.name == "nt" and sys.platform.startswith("win"): # detect windows platefor else: env.AppendUnique( CPPDEFINES = 'UNIX' ) env.AppendUnique( CPPDEFINES = '__UNIX__' ) - env.AppendUnique( CXXFLAGS = '-fPIC' ), if sys.platform.startswith( "darwin" ): # for disabling macros such as check, verify, require ... ( AssertMacros.h ) env.AppendUnique( CPPDEFINES = '__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0' ) From 261a9dbc3cc66c0e9e862432e9c5c75e728ca782 Mon Sep 17 00:00:00 2001 From: Clement Champetier Date: Thu, 21 Aug 2014 15:41:25 +0200 Subject: [PATCH 8/8] SConscript: clean how to check libav when unix --- SConstruct | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SConstruct b/SConstruct index fae2c9ad..9f154411 100644 --- a/SConstruct +++ b/SConstruct @@ -155,20 +155,20 @@ if os.name == "nt" and sys.platform.startswith("win"): # detect windows platefor resampleLibraryFlag = '-DFF_RESAMPLE_LIBRARY' resampleLibraryName = 'swresample' else: - if not conf.CheckLibWithHeader('avutil', 'libavutil/avutil.h', 'c'): + if not conf.CheckCHeader('libavutil/avutil.h'): sys.exit( -1 ) - if not conf.CheckLibWithHeader('avcodec', 'libavcodec/avcodec.h', 'c'): + if not conf.CheckCHeader('libavcodec/avcodec.h'): sys.exit( -1 ) - if not conf.CheckLibWithHeader('avformat', 'libavformat/avformat.h', 'c'): + if not conf.CheckCHeader('libavformat/avformat.h'): sys.exit( -1 ) - if not conf.CheckLibWithHeader('swscale', 'libswscale/swscale.h', 'c'): + if not conf.CheckCHeader('libswscale/swscale.h'): sys.exit( -1 ) - if not conf.CheckLibWithHeader('avresample', 'libavresample/avresample.h', 'c'): - if conf.CheckLibWithHeader('swresample', 'libswresample/swresample.h', 'c'): + if not conf.CheckCHeader('libavresample/avresample.h'): + if conf.CheckCHeader('libswresample/swresample.h'): resampleLibraryFlag = '-DFF_RESAMPLE_LIBRARY' resampleLibraryName = 'swresample'