How do I change the VCL code?

I need (do some quick and dirty tests) to change the code Variants

and SysUtils

.

What do I need to do to "compile" the changes?

I can of course open these units in the IDE, but if I change them and I build the project again, I don't see these units recompiled.

What should be done?

+2


source to share


4 answers


The problem is that you will need to compile ALL RTL / VCL against the "new" units.



Instead, modify a copy of the units in question and add them to your project when you want to use them. Delphi has to use them versus RTL / VCL.

+6


source


If you don't change part of the interface

device (that is, you only change the side implementation

), you can create your own version of RTL blocks (the only exception is System.pas

and SysInit.pas

, but this is not in your area - see our blog site for some improvements to these units).

You need to put your own version Variants.pas

and SysUtils.pas

in the search path of your project. They will be counted instead of the default RTL.

But keep in mind that you can easily break anything.



For testing purposes this is fine, but if you want to take advantage of these changes, you'd better use some automated regression tests and know exactly what you are doing.

Note that you can use the "debug" version of the RTL blocks (from the project options) and then the debugger step in the official source code. This can help you find problems without touching the source.

If you change part of the interface

device, you have to recompile all the blocks that call the modified block - for SysUtils and Variants, that's almost all RTL.

+3


source


DCU Delphi is precompiled. It would be a waste of time to compile them on every build.

If the code you are trying to change is a method of an inline class, then a class helper can help:

http://docwiki.embarcadero.com/RADStudio/en/Class_and_Record_Helpers

So the question is, what part of the code do you want to change at runtime?

+2


source


If you really want to recompile RTL, you can do so (make a backup first!). Delphi versions prior to Delphi 2010 had a makefile in the source folder that could be run from the command line to restore rtl / vcl. I don't know for sure (I'm still using D2009), but from what I've heard, this file is no longer present in newer versions. Hopefully there is an alternative. Otherwise, you would spend a lot of time trying to guess what the compiler settings are for each device.


If you want to "fix" a rtl bug for your project, you can copy the block you want to change to your project folder and make the changes. If the device using your revision is used in RTL / VCL, you can copy multiple dependent units into your project folder so they can compile.

If this slows down the compilation time for your project significantly, you can always run your original compiler and then remove the "fixed" units, leaving dcus compiling.

0


source







All Articles