Ticket #1516: premake_flags.2.diff

File premake_flags.2.diff, 9.1 KB (added by leper, 12 years ago)
  • build/premake/premake4.lua

     
    1010newoption { trigger = "without-nvtt", description = "Disable use of NVTT" }
    1111newoption { trigger = "without-tests", description = "Disable generation of test projects" }
    1212newoption { trigger = "without-pch", description = "Disable generation and usage of precompiled headers" }
     13newoption { trigger = "minimal-flags", description = "Only set compiler/linker flags that are really needed" }
    1314newoption { trigger = "with-system-nvtt", description = "Search standard paths for nvidia-texture-tools library, instead of using bundled copy" }
    1415newoption { trigger = "with-system-enet", description = "Search standard paths for libenet, instead of using bundled copy" }
    1516newoption { trigger = "with-system-mozjs185", description = "Search standard paths for libmozjs185, instead of using bundled copy" }
     
    135136function project_set_build_flags()
    136137
    137138    flags { "Symbols", "NoEditAndContinue" }
    138     if not _OPTIONS["icc"] then
     139    if not _OPTIONS["icc"] and not _OPTIONS["minimal-flags"] then
    139140        -- adds the -Wall compiler flag
    140141        flags { "ExtraWarnings" } -- this causes far too many warnings/remarks on ICC
    141142    end
     
    144145        defines { "DEBUG" }
    145146
    146147    configuration "Release"
    147         flags { "OptimizeSpeed" }
     148        if not _OPTIONS["minimal-flags"] then
     149            flags { "OptimizeSpeed" }
     150        end
    148151        defines { "NDEBUG", "CONFIG_FINAL=1" }
    149152
    150153    configuration { }
     
    196199                linkoptions { "-multiply_defined","suppress" }
    197200            end
    198201        else
    199             buildoptions {
    200                 -- enable most of the standard warnings
    201                 "-Wno-switch",      -- enumeration value not handled in switch (this is sometimes useful, but results in lots of noise)
    202                 "-Wno-reorder",     -- order of initialization list in constructors (lots of noise)
    203                 "-Wno-invalid-offsetof",    -- offsetof on non-POD types (see comment in renderer/PatchRData.cpp)
    204 
    205                 "-Wextra",
    206                 "-Wno-missing-field-initializers",  -- (this is common in external headers we can't fix)
    207 
    208                 -- add some other useful warnings that need to be enabled explicitly
    209                 "-Wunused-parameter",
    210                 "-Wredundant-decls",    -- (useful for finding some multiply-included header files)
    211                 -- "-Wformat=2",        -- (useful sometimes, but a bit noisy, so skip it by default)
    212                 -- "-Wcast-qual",       -- (useful for checking const-correctness, but a bit noisy, so skip it by default)
    213                 "-Wnon-virtual-dtor",   -- (sometimes noisy but finds real bugs)
    214                 "-Wundef",              -- (useful for finding macro name typos)
    215 
    216                 -- enable security features (stack checking etc) that shouldn't have
    217                 -- a significant effect on performance and can catch bugs
    218                 "-fstack-protector-all",
    219                 "-D_FORTIFY_SOURCE=2",
    220 
    221                 -- always enable strict aliasing (useful in debug builds because of the warnings)
    222                 "-fstrict-aliasing",
    223 
    224                 -- do something (?) so that ccache can handle compilation with PCH enabled
    225                 "-fpch-preprocess",
    226 
    227                 -- don't omit frame pointers (for now), because performance will be impacted
    228                 -- negatively by the way this breaks profilers more than it will be impacted
    229                 -- positively by the optimisation
    230                 "-fno-omit-frame-pointer"
    231             }
     202            if not _OPTIONS["minimal-flags"] then
     203                buildoptions {
     204                    -- enable most of the standard warnings
     205                    "-Wno-switch",      -- enumeration value not handled in switch (this is sometimes useful, but results in lots of noise)
     206                    "-Wno-reorder",     -- order of initialization list in constructors (lots of noise)
     207                    "-Wno-invalid-offsetof",    -- offsetof on non-POD types (see comment in renderer/PatchRData.cpp)
     208
     209                    "-Wextra",
     210                    "-Wno-missing-field-initializers",  -- (this is common in external headers we can't fix)
     211
     212                    -- add some other useful warnings that need to be enabled explicitly
     213                    "-Wunused-parameter",
     214                    "-Wredundant-decls",    -- (useful for finding some multiply-included header files)
     215                    -- "-Wformat=2",        -- (useful sometimes, but a bit noisy, so skip it by default)
     216                    -- "-Wcast-qual",       -- (useful for checking const-correctness, but a bit noisy, so skip it by default)
     217                    "-Wnon-virtual-dtor",   -- (sometimes noisy but finds real bugs)
     218                    "-Wundef",              -- (useful for finding macro name typos)
     219
     220                    -- enable security features (stack checking etc) that shouldn't have
     221                    -- a significant effect on performance and can catch bugs
     222                    "-fstack-protector-all",
     223                    "-D_FORTIFY_SOURCE=2",
     224
     225                    -- always enable strict aliasing (useful in debug builds because of the warnings)
     226                    "-fstrict-aliasing",
     227
     228                    -- do something (?) so that ccache can handle compilation with PCH enabled
     229                    "-fpch-preprocess",
     230
     231                    -- don't omit frame pointers (for now), because performance will be impacted
     232                    -- negatively by the way this breaks profilers more than it will be impacted
     233                    -- positively by the optimisation
     234                    "-fno-omit-frame-pointer"
     235                }
     236            end
    232237
    233             if arch == "x86" or arch == "amd64" then
     238            if (arch == "x86" or arch == "amd64") and not _OPTIONS["minimal-flags"] then
    234239                buildoptions {
    235240                    -- enable SSE intrinsics
    236241                    "-msse"
     
    245250                buildoptions { "-mthumb -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp" }
    246251            end
    247252
    248             if os.is("linux") or os.is("bsd") then
     253            if (os.is("linux") or os.is("bsd")) and not _OPTIONS["minimal-flags"] then
    249254                linkoptions { "-Wl,--no-undefined", "-Wl,--as-needed" }
    250255            end
    251256
     
    256261
    257262            -- To support intrinsics like __sync_bool_compare_and_swap on x86
    258263            -- we need to set -march to something that supports them
    259             if arch == "x86" then
     264            if arch == "x86" and not _OPTIONS["minimal-flags"] then
    260265                buildoptions { "-march=i686" }
    261266            end
    262267
     
    267272            end
    268273        end
    269274
    270         buildoptions {
    271             -- Hide symbols in dynamic shared objects by default, for efficiency and for equivalence with
    272             -- Windows - they should be exported explicitly with __attribute__ ((visibility ("default")))
    273             "-fvisibility=hidden"
    274         }
     275        if not _OPTIONS["minimal-flags"] then
     276            buildoptions {
     277                -- Hide symbols in dynamic shared objects by default, for efficiency and for equivalence with
     278                -- Windows - they should be exported explicitly with __attribute__ ((visibility ("default")))
     279                "-fvisibility=hidden"
     280            }
     281        end
    275282
    276283        -- X11 includes may be installed in one of a gadzillion of three places
    277284        -- Famous last words: "You can't include too much! ;-)"
     
    292299            defines { "INSTALLED_LIBDIR=" .. _OPTIONS["libdir"] }
    293300        end
    294301
    295         if os.is("linux") or os.is("bsd") then
     302        -- TODO add "minimal-flags" here too?
     303        if (os.is("linux") or os.is("bsd")) and not _OPTIONS["with-system-mozjs185"] then
    296304            -- To use our local SpiderMonkey library, it needs to be part of the
    297305            -- runtime dynamic linker path. Add it with -rpath to make sure it gets found.
    298306            if _OPTIONS["libdir"] then
     
    325333
    326334    project_set_target(project_name)
    327335    project_set_build_flags()
     336
     337    if _OPTIONS["minimal-flags"] then
     338        flags { "Symbols" }
     339    end
    328340end
    329341
    330342
     
    841853        -- install_name settings aren't really supported yet by premake, but there are plans for the future.
    842854        -- we currently use this hack to work around some bugs with wrong install_names.
    843855        if target_type == "SharedLib" then
    844             linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" }       
     856            linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" }
    845857        end
    846858    end
    847859
     
    10291041        -- install_name settings aren't really supported yet by premake, but there are plans for the future.
    10301042        -- we currently use this hack to work around some bugs with wrong install_names.
    10311043        if target_type == "SharedLib" then
    1032             linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" }       
     1044            linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" }
    10331045        end
    10341046
    10351047        buildoptions { "-fno-strict-aliasing" }
  • build/workspaces/update-workspaces.sh

     
    8282
    8383# Now build premake and run it to create the makefiles
    8484cd ../premake/premake4
    85 # Fix the premake makefile to work on BSDs
     85# Fix the premake makefile to work on BSDs/OS X
    8686case "`uname -s`" in
    8787  "GNU/kFreeBSD" )
    8888    # This needs -ldl as we have a GNU userland and libc
     
    9696    sed -e 's/ -ldl/ /g' build/gmake.unix/Premake4.make.bak > build/gmake.unix/Premake4.make
    9797   ;;
    9898  "Darwin" )
    99     # Remove the obsolete -s and the unused -rdynamic parameter and
    100     # link with the CoreServices framework.
    101     sed -e 's/^\([ ]*LDFLAGS[ ]*+=[ ]*\)\(\( [^ ]*\)*\) -s\(\( [^ ]*\)*\)$/\1\2\4/' \
     99    # Replace the obsolete -s with -Wl,-x
     100    # Remove the unused -rdynamic parameter.
     101    # Link with the CoreServices framework.
     102    sed -e 's/^\([ ]*LDFLAGS[ ]*+=[ ]*\)\(\( [^ ]*\)*\) -s\(\( [^ ]*\)*\)$/\1\2 -Wl,-x\4/' \
    102103        -e 's/^\([ ]*LDFLAGS[ ]*+=[ ]*\)\(\( [^ ]*\)*\) -rdynamic\(\( [^ ]*\)*\)$/\1\2\4/' \
    103104        -e 's/^\([ ]*LIBS[ ]*+=[ ]*\)\(\( [^ ]*\)*\)$/\1\2 -framework CoreServices /' \
    104105        -i.bak build/gmake.unix/Premake4.make