It is a lot of work to use DCC32 to build from the command line. MSBuild is far easier. The library path is stored in the registry, but the location depends on the Delphi version, for example (python code):
if BDSVER == '5.0':
CompanyText = 'Borland'
else:
CompanyText = 'CodeGear'
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,'Software\\' + CompanyText + '\\BDS\\' + BDSVER + '\\Library')
IncludePath = _winreg.QueryValueEx(key,'Search Path')[0]
# Then you must replace the environment vars $(BDS), $(BDSCOMMONDOR) etc
IncludePath = ReplaceEnvironVars(IncludePath)
And there is much more to do. You must also obtain the search path, and you must obtain conditional defines from the .dproj file, etc.
I wrote a complete automated build tool in python (for BDSVER >= 5), back when Delphi 2007 installed on XP x64 had a broken MSBuild. Later, it turned out that some required configuration files were not copied into the correct .NET folder by the Delphi installer. Copying these files to the correct location fixed the problem, and now I use MSBuild.