mirror of
https://github.com/axiomatic-systems/Bento4.git
synced 2026-01-12 00:18:59 +08:00
129 lines
4.6 KiB
Plaintext
129 lines
4.6 KiB
Plaintext
import sys
|
|
import os
|
|
from glob import glob
|
|
|
|
#######################################################
|
|
# reusable functions and data structures
|
|
#######################################################
|
|
def GlobSources(dir, patterns):
|
|
root = GetBuildPath('#'+SOURCE_ROOT)+'/'+dir+'/'
|
|
files = []
|
|
for pattern in patterns:
|
|
files += glob(root+pattern)
|
|
return [dir+'/'+os.path.basename(x) for x in files]
|
|
|
|
def GetDirPath(dir):
|
|
return '#'+SOURCE_ROOT+'/'+dir
|
|
|
|
def DeclareBuildDir(dir):
|
|
env.BuildDir(dir, GetDirPath(dir), duplicate=0)
|
|
|
|
def GetModule(name):
|
|
return Modules[name]
|
|
|
|
def GetIncludeDirs(modules, exclude=None):
|
|
dirs = []
|
|
for module in Split(modules):
|
|
if Modules.has_key(module) and not module == exclude:
|
|
dirs += Modules[module].GetIncludeDirs()
|
|
else:
|
|
dirs += [GetDirPath(module)]
|
|
return dirs
|
|
|
|
def GetLibraries(modules):
|
|
return [GetModule(module).GetLibraries() for module in Split(modules)]
|
|
|
|
Modules = {}
|
|
class Module:
|
|
def __init__(self, name, included_modules = [], linked_modules = []):
|
|
self.included_modules = included_modules
|
|
self.linked_modules = linked_modules
|
|
self.product = []
|
|
|
|
def GetLibraries(self):
|
|
return self.product+GetLibraries(self.linked_modules)
|
|
|
|
def GetIncludeDirs(self):
|
|
return GetIncludeDirs(self.included_modules, self.name)
|
|
|
|
class LibraryModule(Module):
|
|
def __init__(self, name,
|
|
build_source_dirs,
|
|
build_source_pattern=['*.c', '*.cpp'],
|
|
build_include_dirs = [],
|
|
included_modules = [],
|
|
linked_modules = []) :
|
|
Module.__init__(self, name, Split(included_modules)+Split(build_source_dirs), linked_modules)
|
|
self.env = env.Copy()
|
|
self.name = name
|
|
self.build_source_dirs = build_source_dirs
|
|
self.build_include_dirs = build_include_dirs
|
|
|
|
# store this new object in the module dictionary
|
|
Modules[name] = self
|
|
|
|
# for each source dir to build, create a BuildDir
|
|
# to say where we want the object files to be built,
|
|
# and compute the list of source files to build
|
|
sources = []
|
|
for dir in Split(self.build_source_dirs):
|
|
DeclareBuildDir(dir)
|
|
sources += GlobSources(dir, build_source_pattern)
|
|
|
|
# calculate our build include path
|
|
cpp_path = GetIncludeDirs(Split(build_include_dirs) + Split(build_source_dirs) + Split(included_modules))
|
|
|
|
# calculate our preprocessor defines for this module
|
|
cpp_defines={}
|
|
|
|
# the product is a library
|
|
print "LIBRARAY:", name, "sources=", sources, "includes=", cpp_path
|
|
self.env.AppendUnique(CPPDEFINES=cpp_defines)
|
|
self.env.AppendUnique(CPPPATH=cpp_path)
|
|
self.product = self.env.Library(target=name, source=sources)
|
|
Alias(name, self.product)
|
|
|
|
def Application(name, extra_deps=[]):
|
|
dir = 'Apps/'+name
|
|
DeclareBuildDir(dir)
|
|
sdk = ['Core', 'System'] + Split(extra_deps)
|
|
libs = GetLibraries(sdk)
|
|
cpp_path = GetIncludeDirs(sdk)
|
|
|
|
prog = env.Program(name,
|
|
GlobSources(dir, ['*.cpp']),
|
|
LIBS=libs, CPPPATH=cpp_path)
|
|
Alias(name, prog)
|
|
|
|
#######################################################
|
|
# Main Build
|
|
#######################################################
|
|
Import("env")
|
|
SOURCE_ROOT='Source/C++'
|
|
|
|
### try to read in any target specific configuration
|
|
#try:
|
|
if os.path.exists('../Config.scons'):
|
|
# Load the target-specific config file
|
|
execfile('../Config.scons')
|
|
print '@@@ Loaded target configuration @@@'
|
|
|
|
#######################################################
|
|
# modules
|
|
#######################################################
|
|
LibraryModule(name = 'Core',
|
|
build_source_dirs = ['Core', 'Crypto', 'MetaData'],
|
|
included_modules = 'Config')
|
|
|
|
LibraryModule(name = 'System',
|
|
build_source_dirs = 'System/StdC',
|
|
included_modules = 'Core')
|
|
|
|
LibraryModule(name = 'Codecs',
|
|
build_source_dirs = ['Codecs'],
|
|
included_modules = 'Core')
|
|
|
|
for name in ['Mp4Dump', 'Mp4Info', 'Mp4Edit', 'Mp4Encrypt', 'Mp4Decrypt', 'Mp4Tag', 'Mp4Extract', 'Mp4RtpHintInfo', 'Mp42Aac']:
|
|
Application(name)
|
|
|
|
Application('Aac2Mp4', 'Codecs') |