User forums > Using Code::Blocks

Automaticlly building all files in folder without a custom makefile?

<< < (2/4) > >>

Eriond:
Hmm. Well, I guess I'll look into using makefiles then; I've been trying to put it off for as long as possible, but I guess there's no more delaying of the inevitable.

The thing about generating the include directives, is that if I have a large amount of these files, this should increase compile time, as far as I can figure; by forcing the system recompile literally all the generated files every time one is changed; I'd like to avoid that if possible.

As for what's being generated, it's a few things. Among others, it's additional class information that a perl script scrapes from the header files; I put in a bunch of defines that mimic Unreal Engine style .uc files, so that classes that inherit from a particular one define a super, automatically serialize certain variables that aren't marked 'transient', automatically serialize pointers to anything else that inherits from the base class properly so that I don't have to do any of the dirty work every time I create a class, am able to have some richer reflexive information than would otherwise be possible, etc..

mirai:
Interesting. Is your project an open source project?

Eriond:
Unfortunately no; I do have plans at some point to actually sell something made off it (not incompatible with open-source, I know!), but I haven't actually gotten around choosing a license or anything yet, so I am somewhat hesitant to make the whole thing public. It's likely at a future point in time, the engine itself will be made open-source, while the games which link with it will be closed-source.

That being said, if you're interested, I'd be glad to share some of the codebase, though I'll be honest with you, some of the perl and C++ is not very clean :p

mirai:
I just thought that looking at the code might help to produce a better idea of how to solve your problem, but that's not really necessary. An example of data conversion scheme (which files become which other files for which purpose) and a couple of use cases would be enough. Besides, I don't use Perl, so I can't dig into it anyway :) By saying "interesting" I meant that it is interesting what ideas might have lead to the very existence of the problem you're facing now.

Eriond:
Ah, I see, lol.

Well, essentially the script rescursively goes through every *.h file in the source directory, and essentially generates one file per *.h that has at least 1 line which contains the macro "REGISTER_...". From there, it parses information about the rest of the class, and generates a .cpp in a subfolder off the root source directory, which contain static functions to initialize the class information, as well as one static member function inside the program's main class that calls the entire set of initialization functions.

For example, this, in "Source/CaeBackdrop.h"

--- Code: ---class Backdrop : public Base {
        REGISTER_CLASS(Backdrop, Base);

        Sky* Parent;

        float3 Position;
        bool Visible;
        float Scale;
        Texture* Image;
        float4 Color;

        Backdrop(Sky* Parent);
        virtual ~Backdrop();

        virtual void Draw(const Camera* Eye) const;
        virtual void Step(float Delta);
};
--- End code ---

Must generate this, in "Source/Generated/CaeBackdropGenerated.cpp"

--- Code: ---void Backdrop::InitializeClassAttributes()
{
if (Properties)
return;
ClassProperties* ParentProperties = Super::GetClassProperties();
Properties = &Base::RuntimeDatabase->Classes["Backdrop"];
if (ParentProperties)
Properties->Inherit(ParentProperties);
Properties->Variables["Parent"] = BaseProperty("Parent", TYPE_BASE, __builtin_offsetof(Backdrop, Parent), BaseProperty::FLAG_NONE);
Properties->Variables["Position"] = BaseProperty("Position", TYPE_FLOAT3, __builtin_offsetof(Backdrop, Position), BaseProperty::FLAG_NONE);
Properties->Variables["Visible"] = BaseProperty("Visible", TYPE_BOOL, __builtin_offsetof(Backdrop, Visible), BaseProperty::FLAG_NONE);
Properties->Variables["Scale"] = BaseProperty("Scale", TYPE_FLOAT, __builtin_offsetof(Backdrop, Scale), BaseProperty::FLAG_NONE);
Properties->Variables["Image"] = BaseProperty("Image", TYPE_ASSET, __builtin_offsetof(Backdrop, Image), BaseProperty::FLAG_NONE);
Properties->Variables["Color"] = BaseProperty("Color", TYPE_FLOAT4, __builtin_offsetof(Backdrop, Color), BaseProperty::FLAG_NONE);
InitializeClassMacro();
}

IMPLEMENT_CLASS(Backdrop);
--- End code ---

My issue is that if I create a new class in a new header with a REGISTER_... macro, or delete an old header which has a macro in it, the generated folder will be updated to reflect this, but the actual C::B project will not be; this is where the problem really stems from. I can't quite think of another way to really add this generated code in any other way into the build list, without inducing somewhat more severe and unparallelizable recompile times (as would be the case in some sort of #include scheme), beyond actually using a custom makefile and putting in something to the effect of 'compile every cpp in this folder.'

I hope that makes things somewhat more clear; sorry.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version