# -*- mode: python; -*- import re import textwrap Import("env debugBuild") Import("get_option") env = env.Clone() env.InjectThirdPartyIncludePaths(libraries=['snappy', 'zlib']) env.Append(CPPPATH=[ "src/include", ]) # Enable asserts in debug builds if debugBuild: env.Append(CPPDEFINES=[ "HAVE_DIAGNOSTIC", ]) # Enable optional rich logging env.Append(CPPDEFINES=["HAVE_VERBOSE"]) conf = Configure(env) if conf.CheckFunc("fallocate"): env.Append(CPPDEFINES=[ "HAVE_FALLOCATE" ]) if conf.CheckFunc("sync_file_range"): env.Append(CPPDEFINES=[ "HAVE_SYNC_FILE_RANGE" ]) if conf.CheckCHeader('x86intrin.h'): env.Append(CPPDEFINES=[ "HAVE_X86INTRIN_H" ]) if env.TargetOSIs('windows'): env.Append(CPPPATH=["build_win"]) env.Append(CFLAGS=[ "/wd4090" # Ignore warning about mismatched const qualifiers ]) if get_option('allocator') == 'tcmalloc': env.InjectThirdPartyIncludePaths(libraries=['gperftools']) env.Append(CPPDEFINES=['HAVE_LIBTCMALLOC']) elif env.TargetOSIs('osx'): env.Append(CPPPATH=["build_darwin"]) elif env.TargetOSIs('solaris'): env.Append(CPPPATH=["build_solaris"]) elif env.TargetOSIs('freebsd'): env.Append(CPPPATH=["build_freebsd"]) elif env.TargetOSIs('openbsd'): env.Append(CPPPATH=["build_openbsd"]) elif env.TargetOSIs('linux'): env.Append(CPPPATH=["build_linux"]) env.Append(CPPDEFINES=["_GNU_SOURCE"]) else: print("Wiredtiger is not supported on this platform. " + "Please generate an approriate wiredtiger_config.h") Exit(1) useZlib = True useSnappy = True version_file = 'build_posix/aclocal/version-set.m4' VERSION_MAJOR = None VERSION_MINOR = None VERSION_PATCH = None VERSION_STRING = None # Read the version information from the version-set.m4 file for l in open(File(version_file).srcnode().abspath): if re.match(r'^VERSION_[A-Z]+', l): exec(l) if (VERSION_MAJOR == None or VERSION_MINOR == None or VERSION_PATCH == None or VERSION_STRING == None): print "Failed to find version variables in " + version_file Exit(1) wiredtiger_includes = """ #include #ifndef _WIN32 #include #endif #include #include #include """ wiredtiger_includes = textwrap.dedent(wiredtiger_includes) replacements = { '@VERSION_MAJOR@' : VERSION_MAJOR, '@VERSION_MINOR@' : VERSION_MINOR, '@VERSION_PATCH@' : VERSION_PATCH, '@VERSION_STRING@' : VERSION_STRING, '@uintmax_t_decl@': "", '@uintptr_t_decl@': "", '@off_t_decl@' : 'typedef int64_t wt_off_t;' if env.TargetOSIs('windows') else "typedef off_t wt_off_t;", '@wiredtiger_includes_decl@': wiredtiger_includes } env.Substfile( target='wiredtiger.h', source=[ 'src/include/wiredtiger.in', ], SUBST_DICT=replacements) env.Alias('generated-sources', "wiredtiger.h") # # WiredTiger library # filelistfile = "build_win/filelist.win" if env.TargetOSIs('windows') else 'dist/filelist' wtsources = [] with open(File(filelistfile).srcnode().abspath) as filelist: wtsources = [line.strip() for line in filelist if not line.startswith("#") and len(line.strip()) >= 1] if useZlib: env.Append(CPPDEFINES=['HAVE_BUILTIN_EXTENSION_ZLIB']) wtsources.append("ext/compressors/zlib/zlib_compress.c") if useSnappy: env.Append(CPPDEFINES=['HAVE_BUILTIN_EXTENSION_SNAPPY']) wtsources.append("ext/compressors/snappy/snappy_compress.c") wtlib = env.Library( target="wiredtiger", source=wtsources, LIBDEPS=[ '$BUILD_DIR/third_party/shim_snappy', '$BUILD_DIR/third_party/shim_zlib', ], ) env.Depends(wtlib, [filelistfile, version_file])