Ticket #1516: premake_flags.diff
File premake_flags.diff, 9.5 KB (added by , 12 years ago) |
---|
-
build/premake/premake4.lua
10 10 newoption { trigger = "without-nvtt", description = "Disable use of NVTT" } 11 11 newoption { trigger = "without-tests", description = "Disable generation of test projects" } 12 12 newoption { trigger = "without-pch", description = "Disable generation and usage of precompiled headers" } 13 newoption { trigger = "minimal-flags", description = "Only set compiler/linker flags that are really needed" } 14 newoption { trigger = "disable-preset-flags", description = "Disable all preset compiler/linker flags" } 13 15 newoption { trigger = "with-system-nvtt", description = "Search standard paths for nvidia-texture-tools library, instead of using bundled copy" } 14 16 newoption { trigger = "with-system-enet", description = "Search standard paths for libenet, instead of using bundled copy" } 15 17 newoption { trigger = "with-system-mozjs185", description = "Search standard paths for libmozjs185, instead of using bundled copy" } … … 135 137 function project_set_build_flags() 136 138 137 139 flags { "Symbols", "NoEditAndContinue" } 138 if not _OPTIONS["icc"] then140 if not _OPTIONS["icc"] and not (_OPTIONS["minimal-flags"] or _OPTIONS["disable-preset-flags"]) then 139 141 -- adds the -Wall compiler flag 140 142 flags { "ExtraWarnings" } -- this causes far too many warnings/remarks on ICC 141 143 end … … 144 146 defines { "DEBUG" } 145 147 146 148 configuration "Release" 147 flags { "OptimizeSpeed" } 149 if not (_OPTIONS["minimal-flags"] or _OPTIONS["disable-preset-flags"]) then 150 flags { "OptimizeSpeed" } 151 end 148 152 defines { "NDEBUG", "CONFIG_FINAL=1" } 149 153 150 154 configuration { } … … 176 180 flags { "NativeWChar" } 177 181 178 182 else -- *nix 179 if _OPTIONS["icc"] then183 if _OPTIONS["icc"] and not (_OPTIONS["minimal-flags"] or _OPTIONS["disable-preset-flags"]) then 180 184 buildoptions { 181 185 "-w1", 182 186 -- "-Wabi", … … 190 194 "-wd1292" -- avoid lots of 'attribute "__nonnull__" ignored' 191 195 } 192 196 configuration "Debug" 193 buildoptions { "-O0" } -- ICC defaults to -O2 197 if not (_OPTIONS["minimal-flags"] or _OPTIONS["disable-preset-flags"]) then 198 buildoptions { "-O0" } -- ICC defaults to -O2 199 end 194 200 configuration { } 195 201 if os.is("macosx") then 196 202 linkoptions { "-multiply_defined","suppress" } 197 203 end 198 204 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 } 205 -- TODO maybe move some of them out of there 206 if not (_OPTIONS["minimal-flags"] or _OPTIONS["disable-preset-flags"]) then 207 buildoptions { 208 -- enable most of the standard warnings 209 "-Wno-switch", -- enumeration value not handled in switch (this is sometimes useful, but results in lots of noise) 210 "-Wno-reorder", -- order of initialization list in constructors (lots of noise) 211 "-Wno-invalid-offsetof", -- offsetof on non-POD types (see comment in renderer/PatchRData.cpp) 212 213 "-Wextra", 214 "-Wno-missing-field-initializers", -- (this is common in external headers we can't fix) 215 216 -- add some other useful warnings that need to be enabled explicitly 217 "-Wunused-parameter", 218 "-Wredundant-decls", -- (useful for finding some multiply-included header files) 219 -- "-Wformat=2", -- (useful sometimes, but a bit noisy, so skip it by default) 220 -- "-Wcast-qual", -- (useful for checking const-correctness, but a bit noisy, so skip it by default) 221 "-Wnon-virtual-dtor", -- (sometimes noisy but finds real bugs) 222 "-Wundef", -- (useful for finding macro name typos) 223 224 -- enable security features (stack checking etc) that shouldn't have 225 -- a significant effect on performance and can catch bugs 226 "-fstack-protector-all", 227 "-D_FORTIFY_SOURCE=2", 228 229 -- always enable strict aliasing (useful in debug builds because of the warnings) 230 "-fstrict-aliasing", 231 232 -- do something (?) so that ccache can handle compilation with PCH enabled 233 "-fpch-preprocess", 234 235 -- don't omit frame pointers (for now), because performance will be impacted 236 -- negatively by the way this breaks profilers more than it will be impacted 237 -- positively by the optimisation 238 "-fno-omit-frame-pointer" 239 } 240 end 232 241 233 if arch == "x86" or arch == "amd64"then242 if (arch == "x86" or arch == "amd64") and not (_OPTIONS["minimal-flags"] or _OPTIONS["disable-preset-flags"]) then 234 243 buildoptions { 235 244 -- enable SSE intrinsics 236 245 "-msse" … … 245 254 buildoptions { "-mthumb -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp" } 246 255 end 247 256 248 if os.is("linux") or os.is("bsd") then257 if (os.is("linux") or os.is("bsd")) and not (_OPTIONS["minimal-flags"] or _OPTIONS["disable-preset-flags"]) then 249 258 linkoptions { "-Wl,--no-undefined", "-Wl,--as-needed" } 250 259 end 251 260 … … 256 265 257 266 -- To support intrinsics like __sync_bool_compare_and_swap on x86 258 267 -- we need to set -march to something that supports them 259 if arch == "x86" then268 if arch == "x86" and not (_OPTIONS["minimal-flags"] or _OPTIONS["disable-preset-flags"]) then 260 269 buildoptions { "-march=i686" } 261 270 end 262 271 … … 267 276 end 268 277 end 269 278 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 } 279 if not (_OPTIONS["minimal-flags"] or _OPTIONS["disable-preset-flags"]) then 280 buildoptions { 281 -- Hide symbols in dynamic shared objects by default, for efficiency and for equivalence with 282 -- Windows - they should be exported explicitly with __attribute__ ((visibility ("default"))) 283 "-fvisibility=hidden" 284 } 285 end 275 286 276 287 -- X11 includes may be installed in one of a gadzillion of three places 277 288 -- Famous last words: "You can't include too much! ;-)" … … 292 303 defines { "INSTALLED_LIBDIR=" .. _OPTIONS["libdir"] } 293 304 end 294 305 295 if os.is("linux") or os.is("bsd") then 306 if (os.is("linux") or os.is("bsd")) and not _OPTIONS["with-system-mozjs185"] then 307 -- TODO add "minimal-flags" and/or "disable-preset-flags" here 296 308 -- To use our local SpiderMonkey library, it needs to be part of the 297 309 -- runtime dynamic linker path. Add it with -rpath to make sure it gets found. 298 310 if _OPTIONS["libdir"] then … … 841 853 -- install_name settings aren't really supported yet by premake, but there are plans for the future. 842 854 -- we currently use this hack to work around some bugs with wrong install_names. 843 855 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" } 845 857 end 846 858 end 847 859 … … 1008 1020 1009 1021 -- FCollada is not aliasing-safe, so disallow dangerous optimisations 1010 1022 -- (TODO: It'd be nice to fix FCollada, but that looks hard) 1011 buildoptions { "-fno-strict-aliasing" } 1023 if not _OPTIONS["disable-preset-flags"] then 1024 buildoptions { "-fno-strict-aliasing" } 1025 end 1012 1026 1013 1027 buildoptions { "-rdynamic" } 1014 1028 linkoptions { "-rdynamic" } … … 1018 1032 links { "c", } 1019 1033 end 1020 1034 1021 buildoptions { "-fno-strict-aliasing" } 1035 if not _OPTIONS["disable-preset-flags"] then 1036 buildoptions { "-fno-strict-aliasing" } 1037 end 1022 1038 1023 1039 buildoptions { "-rdynamic" } 1024 1040 linkoptions { "-rdynamic" } … … 1029 1045 -- install_name settings aren't really supported yet by premake, but there are plans for the future. 1030 1046 -- we currently use this hack to work around some bugs with wrong install_names. 1031 1047 if target_type == "SharedLib" then 1032 linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" } 1048 linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" } 1033 1049 end 1034 1050 1035 buildoptions { "-fno-strict-aliasing" } 1051 if not _OPTIONS["disable-preset-flags"] then 1052 buildoptions { "-fno-strict-aliasing" } 1053 end 1036 1054 1037 1055 -- On OSX, fcollada uses a few utility functions from coreservices 1038 1056 linkoptions { "-framework CoreServices" }