HeidiSQL Logo

HeidiSQL - additional information file for developers


Table of contents

  1. Basic information
  2. Manual build
  3. Further development
  4. Troubleshooting
  5. Notes
  6. Finding the source line from a memory address
  7. Upgrading third-party packages
  8. Releasing

Basic information

For the basics, please refer to this document.

To table of contents


Manual build

We'll start by compiling and installing the components that HeidiSQL depends on and then HeidiSQL itself.

HeidiSQL has one directory named "packages" for each component and for HeidiSQL itself, this is where you'll find the project files.

Delphi has a distinction between "design-time components" and "run-time components". To compile HeidiSQL correctly, the designtime components that it depends on needs to be "Installed" into the Borland environment, otherwise Delphi will fail to compile HeidiSQL. You can Install a project by right-clicking the project in the "Project Manager" in Delphi and choosing "Install".

Open these projects in Delphi 2007 and perform the action listed.
Note: Before you can install components into the IDE, you will also need to either (a) copy the generated BPL files from the build folders to somewhere in your path, or (b) add the build folders to your Delphi PATH environment variable override. The override can be found under Tools --> Options --> Environment Options --> Environment Variables.

Relative path Action
components/edbimage/packages/delphi11/EDBImage.groupproj Build All + Install "DCLSer"
components/tntunictrls/packages/delphi11/TntUnicodeVcl.groupproj Build All + Install "TntUnicodeVcl_Design"
components/synedit/packages/delphi11/SynEdit.groupproj Build All + Install "SynEditD"
components/zeosdbo/packages/delphi11/ZeosDbo.groupproj Build All + Install "ZComponentDesign"
components/heidisql/packages/delphi11/HeidiComponents.groupproj Build All + Install "HeidiComponents"
components/virtualtreeview/packages/delphi11/VirtualTrees.groupproj Build All + Install "VirtualTreesD"

Once you're done, you are ready to compile HeidiSQL itself:

Relative path Action
packages/delphi11/heidisql.dproj Build All

You should end up with a "heidisql.exe" binary in the "out" folder.

Ta-ta! We're done ;-).

To table of contents


Further development

Once the initial build and installation process is complete, please refer to this document for more information regarding consequent building of the project.

To table of contents


Troubleshooting

"Error Reading Form" / "Class Not Found" error messages

You might have forgotten to Install some of the components.

First, make sure that you choose "Cancel" in this dialog! If you do not, BDS will make devastating changes to the source, and you'll need to revert those actions (fx. with SVN) before things are going to work again.

Go back to Getting started, and remember to Install the components where it says so ;-).

If you still have problems, you can also opt to start over.

"Unable to install component" error message

Remove the (already installed) component by going to Project --> Options --> Packages, selecting the relevant component and clicking "Remove".

Then try installing the component again.

Once you've successfully installed a design-time component, Delphi should reinstall it the next time you compile the package containing the component.

Component installation seemed to work, but components are still missing

Nuke all files in your package output directory, eg. "%ALLUSERSPROFILE%\Documents\RAD Studio\5.0\Bpl"

Then repeat the above step.

How can I completely clean my build environment?

If the HeidiSQL build process has changed, or you think you might have done something wrong during building, you might want to clean your build environment. You can do like this:

Now you can restart your build process.

Compiler-error: "FOO.pas: E2225 Never-build package BAR must be recompiled"

If you get this error while building any component, nuke all files in the "build"-folder of the package which causes the problem, then try to recompile.

At least for me that worked as I couldn't build the ZComponentDesign-package and got this message:
ZPropertyEditor.pas: E2225 Never-build package ZComponent must be recompiled

Compiler error F1026: "File not found: XYZ", although file exists

It seems that especially the file ZPlainMysql.inc in the package ZPlain is affected by this phenomen. This is a bug in BDS which has been reported in 2004, closed for version 10.0.2097.6343. See also http://qc.borland.com/wc/qcmain.aspx?d=9783: Charles Pope: (...) It looks like Error Insight is performing some kind of file locking preventing the compiler from being able to access the file. (...)

Workaround:

  1. Go to Tools > Options > Editor Options > Code Insight
  2. Uncheck at least "Error Insight"
  3. Restart Delphi

To table of contents


Notes

What's the difference between designtime and runtime components?

(Note: "a component" in this context equals "a project".)

Designtime components are meant to provide functionality to the Borland environment. For example, a designtime component often has a procedure named "Register", which will install the component into the Borland environment.

The idea of separating designtime and runtime is that designtime code does not need to be linked into the final executable, thus saving space. See this article for details:
http://community.borland.com/article/0,1410,27717,00.html

If in doubt, you can always choose "designtime and runtime". If you do designate a project as being "designtime only", but some code is really required at runtime, the linker seems to be clever enough to include the component in the final executable anyway.

Runtime components are meant to be included in the final executable. Runtime components can probably not be "Installed" into the Borland environment. Runtime components can be compiled into BPL files, which is a sort of fancy DLL.

You can Google for more information about components here:
borland.public.delphi.vcl usenet groups
borland.public.cppbuilder.vcl usenet groups

How do I find out what's changed in a ".res" file?

I have no clue. If you find out, please update this readme.
Supposedly, one can use textual RC files instead of binary RES files, and by adding the RC files to a project, Delphi should compile them into RES files on demand. That's probably what we should do.

(Hint: Delphi comes with two resource compilers, brc32.exe and brcc32.exe. The Delphi compiler can be called with --drc to generate text resource files at compile time (?).)

What tool is practical for editing the multi-icon bitmap in /res/icons8bit.bmp?

While this file is a simple windows-bitmap (.bmp) with 256 colors, one way is to use "Paint" from within the Windows accessories - it has everything you need for this task. But obviously design-people would prefer a more powerful software like Photoshop or something similar. However, a good and free alternative for beginners and intermediate designers is Paint.NET.

What should I do before editing this readme?

You need to put yourself in the shoes of a newbie, and make sure that the method you're proposing actually works.

To table of contents


Finding the source line from a memory address

Preparation

Finding a source line from a memory address is useful when a runtime exception occurs while the development environment is not running, for example on a user system. There are two methods to translate to a source address given a memory address, they are listed below.

For either method to work, Delphi must be able to find a map of memory addresses and function names. With the correct project settings, these are automatically generated when the project is compiled.

When debugging a problem, first svn update to the revision in which the problem occurred. Also run the build_everything script so that the binaries and map files are generated.

Using the "Modules" window

Activate the "Modules" window by selecting View -> Debug Windows -> Modules from the main menu.

The Modules window seems functional, but is completely empty (and thus useless) until you actually start the program. Only then will the relevant procedure names and addresses be filled into the otherwise void window. No error message is shown, so you need to know that the program must be started for this feature to work correctly. If modules are loaded on demand, it may also be necessary to progress to a certain point in the application, for example by opening a connection profile.

In here, you can find the method responsible for an exception from a long list of methods. First click the "Base Address" header to sort by base address. Then select the module with the base address that is closest to, but not higher than, the memory address you're seeking. A list of entry points on the right-hand side gets filled. Select the "Address" header in this list to sort by address. Now, from the list of entry points, find the function by looking for the closest match that doesn't exceed the memory address sought.

Using the "Disassembly" window

Activate the "Disassembly" window by selecting View -> Debug Windows -> CPU Windows -> Disassembly from the main menu. In the default configuration, the CPU window also pops up when the program is paused. In that case it may be enough to simply pause the running program to show this window.

Before the Disassembly window can be shown, the program must be running, suspended and attached to the IDE debugger. This can be accomplished by running the program from within the IDE and pressing the "Pause" button.

Make sure that names of procedures are printed in the Disassembly view. This is enabled by ticking the "mixed source" menu item in the context menu that pops up when you right-click inside the Disassembly window. Note that it is easy to disable this by accident by pressing CTRL-X.

The Disassembly window contains a "go to address" function, which is activated by right-clicking inside the window and choosing "Goto Address" from the context menu that pops up. Enter an address in Pascal hexadecimal notation, for example $65C6DB, to scroll to the relevant memory address. Make sure that "mixed source" is enabled (see above). Browse upwards in the disassembly view until a function name along with a line number is visible in the Disassembly view. Double-click the line number to go directly to the source code file.

To table of contents


Upgrading third-party packages

There are two methods to do this. One uses "svn update" purely, the other uses the automatic merging feature in Subversion.

Updating a vendor package using purely "svn update".

This is the old method, which was required before Subversion supported automatic merging.

  1. Run "svn log" on the package's top folder and find the first vendor revision.
    This step finds a "base" revision where the source code in our repository matches that of the vendor"s.

  2. Run "svn update -r<XXX>".
    This step "updates" the local working copy to the revision found above.
    The correct terminology would be "downdate", except that downdate is not a proper English word.

  3. Copy the updated vendor code on top of package folder.

  4. Run "svn update" to update to HEAD again.
    This step re-applies all the changes from the HeidiSQL repository.
    Files that have been deleted or renamed in HeidiSQL are deleted or renamed in the local working copy.
    Subversion has an automatic merge algorithm that merges the changes already performed in the HeidiSQL repository (because of earlier upgrades of the vendor package) with the upgrades found in the difference between the current revision from step 2 and the HEAD revision. These double updates are silently applied to the local working copy, so they no longer appear as changes. Subversion also applies locally the changes which are specific to the HeidiSQL project's source code. After this step, only the changes made by the vendor since the last upgrade of the vendor package should be visible as changes in the local working copy.

  5. Resolve conflicts if any.
    Subversion does not have a perfect merge algorithm. Therefore it may be necessary to manually resolve some conflicts. Knowing or figuring out why a particulate conflict occurs can be helpful in this step. In particular, a number of spurious conflicts may arise because Subversion cannot figure out how to automatically silence some upgrades that have been performed already.

  6. Run "svn commit" to commit the changes.
    This step creates a repository revision with the updated vendor package.

Updating a vendor package using automatic merging.

Historically, we've used the method above to update vendor code. Since version 1.5, Subversion now supports automatic merging. We can use this if the project is updated to have a vendor branch. In this example, the vendor branch will live in a folder named /3rdparty/ in the repository.

  1. Copy the new vendor code on top of the old in /3rdparty/<package>.
    The new vendor code can come from a compressed source package, or via another approach: A script can be set up that automatically pulls the HEAD of vendor's trunk down periodically and commits each revision.

  2. Run "svn commit" to commit the changes.
    This step creates a repository revision with the updated vendor package.
    If an automated script is used (see above), this is done automatically for each vendor revision.

  3. Switch to the /trunk/components/<package> folder.

  4. Run "svn merge <repository>/3rdparty/<package> ./".
    This step takes the changes from the revision created above, and merges them into the project space. While doing this, Subversion automatically marks the revisions that has been merged, so that the next time around it will not attempt to merge these changes again. Files that have already been deleted, moved or otherwise modified keeps their changes as a natural effect of the update(s) being applied on top of the HEAD revision.

  5. Resolve conflicts if any.
    Subversion does not have a perfect merge algorithm. Using this method, however, is much less likely to produce conflicts compared to the previous method, because it is much easier for Subversion to figure out what actually needs to be applied. Some resolving may be needed, particularly in places where the vendor has decided to modify code that has already been modified in HeidiSQL, but in a different way.

  6. Run "svn commit" to commit the changes.
    This step creates a repository revision, adding the vendor updates to the project.

To table of contents


Releasing a new version

In order to keep version numbers in the repository and the released executables in sync, it is important to perform releases using an established method.

Note: All steps are important!

Note: Order is important!

Todo: Extract the sed code that alters %WCVER% from build_everything.cmd and put it in a separate file. Run this file in a post-compile step whenever the HeidiSQL project is compiled.

  1. Make sure your working copy contains both "trunk" and "tags" from repository.
    If you need to check out "tags", you may put a tick in "checkout top folder only" to spare bandwidth.

  2. Run "svn update -rHEAD" on the trunk folder.
    This step ensures that all files copied in the next step are at the same source revision.
    Using the TortoiseSVN "svn update" command is fine too.

  3. Run "svn copy trunk tags/4.0rc1".
    This step creates an exact duplicate of the current HEAD revision of trunk.

  4. Edit the release code variable "appversion" in tags/4.0rc1/main.pas.
    This step modifies above duplicate so it is now different from trunk.

  5. Edit the AppVerName, AppVersion, VersionInfoVersion and OutputBaseFilename variables in tags/4.0rc1/out/heidisql.iss.
    (TODO: At some point, the ISS file should be modified to only contain one version number variable.)
    (TODO: Get the revision number in there somewhere.)

  6. Edit the MajorVer, MinorVer, FileVersion and ProductVersion variables in tags/4.0rc1/packages/heidisql.dproj.
    (TODO: Find out if there is a way to automate this.)
    (TODO: Get the revision number in there somewhere.)

  7. Edit the FILEVERSION variable in tags/4.0rc1/res/version.rc.
    (TODO: Find out if it is really necessary to do both this and the above step; both looks like they will end up in the final exe.)
    (TODO: Get the revision number in there somewhere.)

  8. Run "svn commit tags" to commit "tags" and all subitems.
    This step creates a repository revision containing the copy with the new appversion.
    This step also writes the new revision number of this change into $Revision$ in main.pas.
    Point of no return! After this step, the version number is final.

  9. Clean your build environment.
    This step prevents old binary components from being included in the new version.

  10. Build HeidiSQL from tags/4.0rc1.
    (Under some circumstances it is OK to use one of the superpackages instead of this and the previous step. If in doubt, don"t ;-).)

  11. Build installer in the tags/4.0rc1 directory.
    Use the build_everything.cmd script for this, so the version number in main.pas is updated correctly.
    Make sure that the version number does not end in "M" for "Mixed", if it does then you did something wrong further up.

  12. Upload!
    Please the file in the download section on the Google Code site as the preferred version, deprecate older versions.

  13. Update the autoupdater configuration that www.heidisql.com publishes.
    Clients configured to automatically update HeidiSQL will pull down a new client when they see the changed version from here. Publish a new version by creating a new row in a MySQL database in the table heidisql_versions.

To table of contents


Revision of this file: $Rev$
Last changed: $Date$
Last author: $Author$