[Request] Wildcards in .waf_files

Hi,

As I’m building out the starting point of my game I’m constantly adding/removing/moving files around in .waf_files. It would be really helpful if there was a way to specify a directory and have all files in that directory automatically be added to the project, where each folder would become its own filter in the VS solution. E.g, instead of:

    {
"none": {
"Source": [
"Source/StdAfx.cpp",
"Source/StdAfx.h"
]
},
"auto": {
"Include": [
"Include/MyGame/MyGameBus.h"
],
"Source": [
"Source/MyGameModule.cpp",
"Source/MyGameSystemComponent.cpp",
"Source/MyGameSystemComponent.h"
],
"Source/Game": [
"Source/Game/Actor.cpp",
"Source/Game/Actor.h"
],
"Source/Game/Components/World": [
"Source/Game/Components/World/WorldComponent.cpp",
"Source/Game/Components/World/WorldComponent.h"
],
"Source/System": [
"Source/System/GameStartup.cpp",
"Source/System/GameStartup.h"
]
}
}

I would like to specify:

    {
"none": {
"Source": [
"Source/StdAfx.cpp",
"Source/StdAfx.h"
]
},
"auto": {
"Include": [
"Include/MyGame/MyGameBus.h"
],
"Source": [
"**/*.h",
"**/*.c*"
]
}
}

In this manner, whenever I add new source to the directory, I can just re-run lmbr_waf msvs and have the solution updated.

The downside, of course, is that this could include source that I DON’T want in my game, but I’ve found that occurrence to be relatively rare (and very obvious when it happens).

(Note: I checked the other .waf_files files in LY, didn’t see any wildcard specifications, leading me to believe this does not yet exist.)

+1

I was almost sure to have used wildcards with WAF, but after your post, I just realized that the build system supporting wildcards I remember is not WAF, but Scons or Marmalade SDK one.

If this hasn’t been implemented yet it may represent a good example of Lumberyard workflow needing more automation.

Lumberyard use has to get truly frictionless.

Excellent points @Twolewis and @Gamely – I’ve added this to our FR list for further action :slight_smile:

Thank ya much!

Hi, @Twolewis,

You may include the following code in the wscript then it will automatically generate the waf_files for you. After Lumbeyard supports the wildcard then you don’t need this anymore :slight_smile: It just generate the waf_files according to your source files in the directory.

    import json
import fnmatch
import os
gempath = bld.Path('Gems/YourGame/Code')
filedef = {"none" : {"Source":["Source/StdAfx.cpp","Source/StdAfx.h"]}, "auto": {}}
for root, dirnames, filenames in os.walk(gempath):
for filename in fnmatch.filter(filenames, '*.*'):
filepath = os.path.join(root, filename).replace(gempath, "").replace("\\","/")[1:]
filename, file_extension = os.path.splitext(filepath) dirname = os.path.dirname(filepath)
if (file_extension == ".h" or file_extension == ".cpp") and "Tests" not in filepath and "StdAfx" not in filepath:
if dirname not in filedef["auto"]:
filedef["auto"][dirname] = []
filedef["auto"][dirname].append(filepath)
f = open(os.path.join(gempath, "yourgame.waf_files"), "w") f.write(json.dumps(filedef, sort_keys=True, indent=4))
f.close()

No problems @Gamely. Please just put as eca if you like :slight_smile:

Great resource thanks for sharing.As I’m planning to start soon an unofficial Lumberyard wiki , are you ok if I will add it there on your behalf?if so tell me how do you like to get credited.