David
David

Reputation: 290

Verify that the version of a file is correct before Compiling

A file of Delphi's own LIBs has been changed, for a specific need. Since we have several programmers, I need to make sure everyone has this change, and in the future as well.

As the Delphi libs are installed and are not versioned, I need to verify that it is in the correct version.

I wanted to do this before compiling the version.

What I was able to do is create a hash of the file so I assure that it was not modified

{$IF  getMD5('C:\Delphi7\Lib\arquivo.dcu') = 'B1C1CBE80477S09AC4C1B39C28FE9619'}
    {$Message Fatal 'Version of file .dcu file in Delphi7 Lib is wrong..}
{$IFEND}

That way it does not work, because every moment returns the message of [Fatal Error]

Any idea?

Upvotes: 2

Views: 168

Answers (1)

dasmy
dasmy

Reputation: 597

My Delphi time was long ago, but my approach with C++ would be, to add a unique symbol to the lib, that the project depends on. Then, you will at least get a link time error if the symbol is missing (i.e. not your version of the lib is used).

How could this look like (not sure if this is feasible in Delphi)? In addition to your modifications to the LIB, you also add a function called "MyModificationSentinelABCDEF()" that is empty (the name is not important, just make sure it is unique). Then, instead of the $IF statement you proposed, you add a call to this function and a descriptive comment to explains why it is there and what has to be done if there is an error related to it.

If the function is missing, you should see a compile/link error.

Upvotes: 6

Related Questions