Sepehr Taghdisian avatar Sepehr Taghdisian committed bacbba2

no comment

Comments (0)

Files changed (1)

wscript

-#! /usr/bin/env python
-
-###################################################################################################
-# dar-hammer main build file (waf-build) - copyright 2013 
-# Davide 
-# Sepehr
-# http://www.hmrengine.com
-###################################################################################################
-
-import sys
-import os
-import string
-import platform
-from waflib import Logs
-
-#########################
-# main global variables
-VERSION = "0.4.5"
-APPNAME = "dark-hammer"
-
-top = "."
-out = "build"
-ROOTDIR = os.path.abspath(top)
-
-class CompilerFlags:
-    def __init__(self, cfg):
-        # main preprocessors
-        self.defines = []
-        self.flags_link = []
-        
-        self.defines.extend(["_{0}_".format(cfg.env.PLATFORM), cfg.env.PLATFORM])
-        if cfg.env.DEBUG:
-            self.defines.extend(["_DEBUG", "__Debug__"])
-            self.defines.extend(["_DEBUG_"])
-        else:
-            self.defines.extend(["NDEBUG"])
-            
-        if cfg.env.PROFILE:
-            self.defines.extend(["_PROFILE_"])
-        if cfg.env.ASSERT:
-            self.defines.extend(["_ENABLEASSERT_"])
-        if cfg.env.RETAIL:
-            self.defines.extend(["_RETAIL_"])
-        
-        if cfg.env.PLATFORM == "OSX":
-            # C compiler
-            self.flags_c = [
-                "-arch x86_64",
-                "-std=gnu99",
-                "-fms-extensions",
-                "-msse",
-                "-msse2",
-                "-msse4.1",
-                "-ffast-math",
-                "-malign-double"]
-                
-            # C++ compiler
-            self.flags_cpp = [
-                "-arch x86_64",
-                "-fms-extensions",
-                "-msse",
-                "-msse2",
-                "-msse4.1",
-                "-ffast-math",
-                "-malign-double",
-                "-fno-exceptions",
-                "-fno-rtti"]
-            
-            if cfg.env.DEBUG:
-                self.flags_c.extend(["-g"])
-                self.flags_cpp.extend(["-g"])
-            else:
-                self.flags_c.extend(["-O2"])
-                self.flags_cpp.extend(["-O2"])
-                
-            #defines
-            self.defines.extend(["_SIMD_SSE_"])
-            
-        elif cfg.env.PLATFORM == "LINUX":
-            # C compiler
-            self.flags_c = [
-                "-arch x86_64",
-                "-std=gnu99",
-                "-msse",
-                "-msse2",
-                "-msse4.1",
-                "-ffast-math",
-                "-malign-double",
-                "-fPIC"]
-
-            # C++ compiler
-            self.flags_cpp = [
-                "-arch x86_64",
-                "-msse",
-                "-msse2",
-                "-msse4.1",
-                "-ffast-math",
-                "-malign-double",
-                "-fno-exceptions",
-                "-fno-rtti",
-                "-fPIC"]
-                
-            if cfg.env.DEBUG:
-                self.flags_c.extend(["-g"])
-                self.flags_cpp.extend(["-g"])
-            else:
-                self.flags_c.extend(["-O2"])
-                self.flags_cpp.extend(["-O2"])
-
-            # defines
-            self.defines.extend(["_SIMD_SSE_"])
-
-        elif cfg.env.PLATFORM == "WIN":
-            self.flags_c = [
-                "/nologo",
-                "/FC"]
-            self.flags_cpp = [
-                "/EHsc",
-                "/nologo",
-                "/GR",
-                "/FC"]
-
-            if self.env.DEBUG:
-                self.flags_c.extend([
-                    "/Z7",
-                    "/W4",
-                    "/Od",
-                    "/MDd"])
-                self.flags_cpp.extend([
-                    "/Z7",
-                    "/W4",
-                    "/Od",
-                    "/MDd"])
-                self.flags_link.extend(["/DEBUG"])
-            else:
-                self.flags_c.extend([
-                    "/W1",
-                    "/O2",
-                    "/Ot",
-                    "/MD"])
-                self.flags_cpp.extend([
-                    "/W1",
-                    "/O2",
-                    "/Ot",
-                    "/MD"])
-                self.flags_link.extend(["/RELEASE"])
-
-            self.defines.extend([
-                "_SIMD_SSE_", 
-                "WIN32", 
-                "_MBCS",
-                "_CRT_SECURE_NO_WARNINGS"])
-                
-    
-def check_gfxdevice(cfg):
-    if cfg.env.PLATFORM != "WIN" and cfg.options.gfxdevice == "d3d":
-        cfg.fatal("--gfx-device=d3d cannot be applied to non-MS platforms")
-    return cfg.options.gfxdevice.upper()        
-
-def check_buildmode(cfg):
-    if cfg.options.debug and cfg.options.pymodule:
-        cfg.fatal("--debug and --pymodule flags cannot be used together")
-    
-    if (cfg.options.enable_assert or cfg.options.profile or cfg.options.debug) and \
-        cfg.options.retail:
-        cfg.fatal("--retail flag should not be used with any non-retail flags")
-
-#######################
-# return values
-# Linux: LINUX
-# MacOS 10.8+: OSX
-# Windows: WIN
-def check_platform(cfg):
-    os = platform.system()
-    
-    if os == "Windows":
-        os = "Win"
-        
-    if os == "Darwin":
-        os = "OSX"
-
-    os_str = os
-    if os == "Linux":
-        os_str += ": " + string.join(platform.linux_distribution(), ", ")
-        
-    if os == "OSX":
-        mac_ver = platform.mac_ver()[0].split(".")
-        os_str += ": " + platform.mac_ver()[0]
-        if int(mac_ver[0]) < 10 or int(mac_ver[1]) < 8:
-            Logs.warn("Warning: Unsupported OSX version '{0}'".format(platform.mac_ver()[0]))
-            
-    cfg.start_msg("Platform")
-    cfg.end_msg(os_str)
-    
-    return os.upper()        
-
-#######################
-# options command
-def options(opt):
-    opt.load("compiler_c compiler_cxx")
-
-    opt.add_option("--debug", action="store_true", default=False, dest="debug", help="Debug build")
-    opt.add_option("--pymodule", action="store_true", default=False, dest="pymodule", 
-        help="Build python module")
-    opt.add_option("--assert", action="store_true", default=False, dest="enable_assert", 
-        help="Enable assertions")
-    opt.add_option("--retail", action="store_true", default=False, dest="retail",
-        help="Retail build")
-    opt.add_option("--profile", action="store_true", default=False, dest="profile",
-        help="Profile build")
-    opt.add_option("--gfxdevice", action="store", default="gl", dest="gfxdevice", type="choice",
-        help="Graphics device", choices=["d3d", "gl"])
-    opt.add_option("--physx", action="store", default="", dest="physxroot",
-        help="Physx SDK root directory")
-
-def check_3rdpartylib(cfg, libname):
-    path = cfg.env.ROOTDIR + "/3rdparty/" + libname
-    if not os.path.isdir(path):
-        Logs.warn("Not found")
-        return ""
-    else:
-        return "3rdparty/" + libname
-        
-def check_physx(cfg):
-    if not os.path.isdir(cfg.env.PHYSX_ROOT):
-        Logs.warn("Not found, recheck --physx flag")
-        return ""
-                
-    filepath = os.path.normpath(cfg.env.PHYSX_ROOT + "/version-PhysX.txt")
-    if not os.path.exists(filepath):
-        Logs.warn("Not found, (no-version-file) recheck --physx flag")
-        return ""
-        
-    f = open(filepath, "r")
-    vstr = f.read()
-    f.close()
-
-    vstr1 = vstr.split("-")
-    if vstr1[0] != "PhysX":
-        Logs.warn("Invalid SDK, version file not valid")
-        return ""
-    vstr2 = vstr1[1].split(".")
-    if len(vstr2) < 2 or int(vstr2[0]) < 3 or int(vstr2[1]) < 2:
-        Logs.warn("SDK not up-to-date {0})".format(string.join(vstr2, ".")))
-        return ""
-    
-    return cfg.env.PHYSX_ROOT
-    
-########################
-# configure command
-def configure(cfg):
-    cfg.check_waf_version(mini="1.7.11")
-    cfg.load("compiler_c compiler_cxx")
-    
-    # detect platform/cpu/...
-    cfg.start_msg("Processor")
-    cfg.end_msg(platform.processor())
-    
-    # setup initial variables
-    check_buildmode(cfg)
-    
-    cfg.env.PLATFORM = check_platform(cfg)
-    cfg.env.DEBUG = cfg.options.debug
-    cfg.env.PYMODULE = cfg.options.pymodule
-    cfg.env.RETAIL = cfg.options.retail
-    cfg.env.PROFILE = cfg.options.profile
-    cfg.env.ASSERT = cfg.options.enable_assert
-    cfg.env.GFX_DEVICE = check_gfxdevice(cfg)
-    cfg.env.ROOTDIR = ROOTDIR
-    cfg.env.PHYSX_ROOT = os.path.normpath(cfg.options.physxroot)
-    
-    # external libraries (3rdparty)
-    cfg.start_msg("Checking for assimp")
-    cfg.end_msg(check_3rdpartylib(cfg, "assimp"))
-    
-    cfg.start_msg("Checking for cjson")
-    cfg.end_msg(check_3rdpartylib(cfg, "cjson"))
-    
-    cfg.start_msg("Checking for efsw")
-    cfg.end_msg(check_3rdpartylib(cfg, "efsw"))
-    
-    cfg.start_msg("Checking for ezxml")
-    cfg.end_msg(check_3rdpartylib(cfg, "ezxml"))
-    
-    cfg.start_msg("Checking for lua")
-    cfg.end_msg(check_3rdpartylib(cfg, "lua"))
-    
-    cfg.start_msg("Checking for mongoose")
-    cfg.end_msg(check_3rdpartylib(cfg, "mongoose"))
-    
-    cfg.start_msg("Checking for nvtt")
-    cfg.end_msg(check_3rdpartylib(cfg, "nvtt"))
-
-    cfg.start_msg("Checking for sfmt")
-    cfg.end_msg(check_3rdpartylib(cfg, "sfmt"))
-
-    cfg.start_msg("Checking for stb_image")
-    cfg.end_msg(check_3rdpartylib(cfg, "stb_image"))
-
-    cfg.start_msg("Checking for zlib")
-    cfg.end_msg(check_3rdpartylib(cfg, "zlib"))
-    
-    # SDKs
-    cfg.start_msg("Checking for Physx3 SDK")
-    cfg.end_msg(check_physx(cfg))
-    
-    # compiler/linker flags (c/c++)
-    compiler_flags = CompilerFlags(cfg)
-    cfg.env.append_unique("DEFINES", compiler_flags.defines)
-    cfg.env.append_unique("CFLAGS", compiler_flags.flags_c)
-    cfg.env.append_unique("CXXFLAGS", compiler_flags.flags_cpp)
-    cfg.env.append_unique("LINKFLAGS", compiler_flags.flags_link)
-    
-    print cfg.env.DEFINES
-    print cfg.env.CFLAGS
-    
-def build(bld):
-	pass
-
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.