If you are a power IDE user (Visual Studio, etc) then you are used to setting your own compiler switches, linker switches, pre-processor macros and many other C++ compiler/linker related options. If so you might have wondered what switches does Lumberyard build uses and where can you set your own or remove existing ones?
Your first step ought to be to get to know Lumberyard’s build system – WAF. See its official documentation here. It lays the high level description but is lacking some down and dirty details. Despite that a lot of the options can be discovered by searching existing code base and existing example usage in wscript files and some “secret” internal WAF python files.
Here are some easy Windows Visual Studio settings can be set directly in WSCRIPT file that builds your code. If you are familiar with the basics of compiler and linker switches, the following should be obvious to you. I’m providing them here as an example of what you can do with WAF.
Note, these options typically appear under def build(bld): method in your wscript files. For example:
def build(bld):
bld.DefineGem(
….
)
Example Preprocessor in Wscript
win_defines = [‘DEFINE_A’,’SOME_OTHER_DEFINE’,’ETC’],
Adding Compiler Options
Adding Linker Options in Wscript
win_linkflags = [‘/NODEFAULTLIB:libcmt.lib’],
win_lib = [‘wininet’, ‘Shell32’, ‘Ole32’, ‘Gdi32’, ‘ws2_32’],
Once you search for similar options, you will find a bunch of example in Lumberyard throughout, such as platform specific options: msvc_cxx_flags, etc. That should get you quite far.
Removing Default Options from WAF Build
But let’s say you watch to remove a default option that WAF sets for you. You should know what you are doing here and track the changes you make with your source control tool. But regardless here is the power to shoot your own foot.
If you search for dev\Tools\build\waf-1.7.13\lmbrwaflib (you might have a different version of WAF on your build, adjust the path accordingly) you will find an interesting file:
dev\Tools\build\waf-1.7.13\lmbrwaflib\compile_settings_msvc.py
Look for methods such as load_profile_msvc_settings(conf) and you will find the default compiler and linker flags in there. There you can see what exactly what default ever present switches are set for each build type on each platform.