[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12155] trunk/blender/extern/ffmpeg/ SConscript: == FFMPEG ==
Peter Schlaile
peter at schlaile.de
Thu Sep 27 08:48:50 CEST 2007
Revision: 12155
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12155
Author: schlaile
Date: 2007-09-27 08:48:50 +0200 (Thu, 27 Sep 2007)
Log Message:
-----------
== FFMPEG ==
Scons support for internal ffmpeg.
Added Paths:
-----------
trunk/blender/extern/ffmpeg/SConscript
Added: trunk/blender/extern/ffmpeg/SConscript
===================================================================
--- trunk/blender/extern/ffmpeg/SConscript (rev 0)
+++ trunk/blender/extern/ffmpeg/SConscript 2007-09-27 06:48:50 UTC (rev 12155)
@@ -0,0 +1,144 @@
+#!/usr/bin/python
+
+all_libs = ['libavformat', 'libavcodec', 'libswscale', 'libavutil']
+root = "extern/ffmpeg"
+
+import sys
+import os
+import re
+import shutil
+
+from sets import Set
+
+Import('env')
+
+makevardef = re.compile('^([a-zA-Z0-9_-]+)[ \t]*(\+?)=(.*)')
+makevarsubst = re.compile('\$\(([^\)]+)\)')
+makeifeq = re.compile('if(n?)eq \(([^,]*),([^\)]*)\)')
+
+def makeparseblock(fp, variables):
+ pendingline = ''
+ while 1:
+ line = fp.readline()
+ if pendingline:
+ line = pendingline + line
+ pendingline = ''
+ if not line:
+ return
+ if line.endswith('\\\n'):
+ pendingline = line[:-2]
+ continue
+
+ i = line.find('#')
+ if i >= 0:
+ line = line[:i]
+
+ iter = makevarsubst.finditer(line[:])
+ for obj in iter:
+ (name) = obj.group(1)
+ s = ""
+ if name in variables:
+ s = variables[name]
+ line = line.replace('$(' + name + ')', s)
+
+ matchobj = makevardef.match(line)
+ if matchobj:
+ (name, op, value) = matchobj.group(1, 2, 3)
+
+ value = value.rstrip()
+
+ if op == '+' and name in variables:
+ variables[name] += value
+ else:
+ variables[name] = value
+ continue
+ matchobj = makeifeq.match(line)
+ if matchobj:
+ (op, name1, name2) = matchobj.group(1, 2, 3)
+ if (op == '' and name1 == name2) or (op == 'n' and name1 != name2):
+ makeparseblock(fp, variables)
+ else:
+ tempvars = {}
+ makeparseblock(fp, tempvars)
+ continue
+ line = line.strip()
+ if line == 'endif':
+ return
+
+def getmakevars(filenames):
+ variables = { }
+ for filename in filenames:
+ fp = open(filename)
+ print "Processing makefile: " + filename
+ try:
+ makeparseblock(fp, variables)
+ finally:
+ fp.close()
+
+ return variables
+
+print "Configuring ffmpeg..."
+
+if not os.path.isfile(root + "/config.mak"):
+ os.chdir(root);
+ os.system('./configure --disable-shared --enable-liba52bin --enable-gpl --disable-network --disable-zlib --disable-vhook --disable-ffserver --disable-ffplay --enable-swscaler --enable-pthreads >configure.out 2>&1')
+ os.chdir("../..");
+else:
+ print "(skipped, config.mak already exists)"
+
+if not os.path.isdir(root + "/include"):
+ os.mkdir(root + "/include");
+if not os.path.isdir(root + "/include/ffmpeg"):
+ os.mkdir(root + "/include/ffmpeg");
+
+
+for lib in all_libs:
+ vars = getmakevars([root + '/config.mak', root + "/" + lib + '/Makefile'])
+ objs = ""
+ if "OBJS-yes" in vars:
+ objs += vars['OBJS-yes']
+ if "OBJS" in vars:
+ objs += vars['OBJS']
+
+ objs += " "
+ objs = objs.replace(".o ", ".c ")
+
+ asm_objs = ""
+ if "ASM_OBJS" in vars:
+ asm_objs += vars["ASM_OBJS"]
+
+ asm_objs += " "
+ asm_objs = asm_objs.replace(".o ", ".S ")
+
+ objs += asm_objs;
+
+ sources = list(Set(objs.split()))
+ sources = [lib + "/" + x for x in sources]
+
+ defs = "HAVE_AV_CONFIG_H _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE _ISOC9X_SOURCE"
+ cflags = ""
+
+ if "CFLAGS" in vars:
+ cflags += " " + vars["CFLAGS"]
+ if "OPTFLAGS" in vars:
+ cflags += " " + vars["OPTFLAGS"]
+
+ headers = ""
+ if "HEADERS" in vars:
+ headers += vars["HEADERS"]
+
+ headers = headers.split()
+
+ for h in headers:
+ if not os.path.isfile(root + "/include/ffmpeg/" + h):
+ shutil.copyfile(root + "/" + lib + "/" + h,
+ root + "/include/ffmpeg/" + h)
+
+ env.BlenderLib (libname="extern_" + lib, sources=sources,
+ includes=["."] + all_libs,
+ defines=Split(defs),
+ libtype=['core', 'intern', 'player'],
+ priority = [5, 5, 10],
+ compileflags = Split(cflags))
+
+
More information about the Bf-blender-cvs
mailing list