Clément 148 Posted March 14 (edited) Hi, I'm compiling a project (Delphi XE) with several millions lines and hundreds of units. Somehow a specific unit got called in that project, and I must discover which unit is dragging it in. It might be a direct reference or indirect reference (Since I'm a very lucky guy, it must be a deep indirect reference). In any case, I have to deal with it. Is there any tool that can help me track a specific unit linkage into a project? TIA, Clément Edited March 14 by Clément Share this post Link to post
DelphiUdIT 176 Posted March 14 May the be graph attached in that post ? https://en.delphipraxis.net/topic/10229-unit-dependency-viwer/?do=findComment&comment=81286 1 Share this post Link to post
Lars Fosdal 1791 Posted March 14 Peganza is another possible tool to find out which unit that drags in another unit. Share this post Link to post
Uwe Raabe 2057 Posted March 14 You can check the map file. In case you are already using MMX, its Analyze Unit Dependencies feature might help, too. Share this post Link to post
Alexander Sviridenkov 356 Posted March 14 1 hour ago, DelphiUdIT said: May the be graph attached in that post ? https://en.delphipraxis.net/topic/10229-unit-dependency-viwer/?do=findComment&comment=81286 Link to latest build: https://delphihtmlcomponents.com/graph.zip 1 2 Share this post Link to post
Stano 143 Posted March 14 (edited) CnPack has a function to remove unused units. to check it is laborious it is not what you require But a miracle can happen Edited March 14 by Stano Share this post Link to post
Kas Ob. 121 Posted March 14 6 hours ago, Clément said: Is there any tool that can help me track a specific unit linkage into a project? Rename that unit, then build. 2 Share this post Link to post
Clément 148 Posted March 15 22 hours ago, Lars Fosdal said: Peganza is another possible tool to find out which unit that drags in another unit. I installed the free edition, ran it, but could'nt figure out how to check the units... I need to spend some more time to figure out if it can help Share this post Link to post
Clément 148 Posted March 15 22 hours ago, Uwe Raabe said: You can check the map file. In case you are already using MMX, its Analyze Unit Dependencies feature might help, too. I'm using a map file. the unit is there, but I cannot track how it ended up in this project. I wasn't able to install MMX under XE. Share this post Link to post
Clément 148 Posted March 15 21 hours ago, Alexander Sviridenkov said: Link to latest build: https://delphihtmlcomponents.com/graph.zip Very nice tool! But it didn't display the unit I'm looking for. The unit is not directly linked in the project file, instead it is in a folder defined in the IDE environment. I would have to add folders to a list of folders to look for. Is it possible with the latest version you made available? Share this post Link to post
Lajos Juhász 293 Posted March 15 10 minutes ago, Clément said: Very nice tool! But it didn't display the unit I'm looking for. The unit is not directly linked in the project file, instead it is in a folder defined in the IDE environment. I would have to add folders to a list of folders to look for. Is it possible with the latest version you made available? Just do a find in files. Share this post Link to post
Clément 148 Posted March 15 17 hours ago, Kas Ob. said: Rename that unit, then build. This is driving me nuts... I renamed the unit, the project stopped compiling as expected, but I can track that unit down. I can see it there, still unable to figure out which unit brings it in. I even removed the folder from the IDE environment. The project also stop compiling, but with this time with units it really needs. I am adding those one by one. As I thought it would be simpler to track it down ( stupid me ), I was working in the production .DPR, I had to undo everything, to be able to release a patch to a customer... 🤪 This project uses a very old in-house library (pre-2000) that migrated from Delphi 4 up to XE. Share this post Link to post
Clément 148 Posted March 15 (edited) 8 minutes ago, Lajos Juhász said: Just do a find in files. I will instead create a new DPR project in the "root" , forcing a scan of all sub-folder, including the one I know this library is. My problem is tracking down which unit is dragging "this unwanted unit" in the project. Once I find the "unit responsible for dragging it in the project", I have to assess the best way to remove it from the project. Hopefully removing it from a "uses" clause will be enough, but I don't feel that lucky Edited March 15 by Clément Share this post Link to post
Uwe Raabe 2057 Posted March 15 31 minutes ago, Clément said: I wasn't able to install MMX under XE. You need Version 13.1.0.2220 for that. Share this post Link to post
Pat Foley 51 Posted March 15 (edited) Why not put a break point in it and use the call stack to see who needs it since you found the unit. Or comment out half the enums or settings in it. If it's only a dcu--view in a text editor. The graph tool does have a build order output that could in help placing a breakpoint when compiling when unit is renamed. Edited March 15 by Pat Foley added suggestion Share this post Link to post
Kas Ob. 121 Posted March 15 I witnessed such behavior, in few times was not a pas unit but in dcu file referring to some ghost unit that i don't have reference in the code. And it was a removed referenced unit after refactoring, so searching for the name of needed unit will return no result, while the dcu still having the reference. Try to rename the folders with your DCU's, also when it dcu tracking then Process Monitor will show some extra information about this. Share this post Link to post
Alexander Sviridenkov 356 Posted March 15 (edited) 33 minutes ago, Clément said: Very nice tool! But it didn't display the unit I'm looking for. The unit is not directly linked in the project file, instead it is in a folder defined in the IDE environment. I would have to add folders to a list of folders to look for. Is it possible with the latest version you made available? Last version should show all files used in application, not only ones mentioned in .dpr. It starts from .dpr units and recursively find all units listed in inteface and implementation sections. Of course IDE Library path and projects paths settings are used when scanning. BTW it can extract interface and implementation units even if only .dcu is available. Edited March 15 by Alexander Sviridenkov Share this post Link to post
Attila Kovacs 629 Posted March 15 just rename that unit temprarily and do a build? huh? Share this post Link to post
Attila Kovacs 629 Posted March 15 22 minutes ago, Kas Ob. said: I witnessed such behavior, in few times was not a pas unit but in dcu file referring to some ghost unit that i don't have reference in the code. or opened in the IDE 😄 Build outside. Share this post Link to post
Clément 148 Posted March 15 2 hours ago, Alexander Sviridenkov said: Last version should show all files used in application, not only ones mentioned in .dpr. It starts from .dpr units and recursively find all units listed in inteface and implementation sections. Of course IDE Library path and projects paths settings are used when scanning. BTW it can extract interface and implementation units even if only .dcu is available. The unit I'm tracking does not appear in the graph. If I remove the path or rename the unit the project doesn't compile. I deleted all dcus from the library root to be sure only valid ".pas" files are compiled. Share this post Link to post
DelphiUdIT 176 Posted March 15 But use the "grep" tool on command line to check where the unit are related, in all files (in all disk if necessary 😉) ? Share this post Link to post
Alexander Sviridenkov 356 Posted March 15 16 minutes ago, Clément said: The unit I'm tracking does not appear in the graph. If I remove the path or rename the unit the project doesn't compile. I deleted all dcus from the library root to be sure only valid ".pas" files are compiled. This is quite strange. Does unit map looks correct (all other units are present)? Share this post Link to post
Kas Ob. 121 Posted March 15 33 minutes ago, Clément said: If I remove the path or rename the unit the project doesn't compile. I think i can pin point it ! Just remembered another situation when the project wasn't using specific 3rd party library library, namely AlphaSkins and acPng dcu kept popping in compiled while it wasn't referenced in that project, the project wasn't even using AlphaSkins but the standard VCL TImage, this happen on my IDE and my PC not the client (owner of the source), i solved it by simply disabling or removing that package form the IDE when working on that project. Share this post Link to post
JonRobertson 72 Posted March 15 (edited) 4 hours ago, Clément said: If I [...] rename the unit the project doesn't compile. That is why I would rename the unit. When the project fails to compile, the error should occur in the unit that is "using" the unwanted unit. Note that it often requires a Build rather than just a Compile to locate the unit containing the reference. Edited March 15 by JonRobertson Share this post Link to post
Attila Kovacs 629 Posted March 15 4 hours ago, Clément said: If I remove the path or rename the unit the project doesn't compile. Of course not, but you should execute a build and not compile it. Share this post Link to post