genunitnames.pp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. {
  2. This file is part of the Free Component Library
  3. Copyright (c) 2022 by Michael Van Canneyt, [email protected]
  4. Read a list of unit file transformations and generate a list of unit names for use in a Makefile.
  5. The output consists of a XYZUNIT variable for each unit in the file list, twice: once dotted, once not dotted.
  6. The variables can be used in target definitions and dependency lists.
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. program genunitnames;
  14. uses sysutils, classes, types, namespacetool, prefixer;
  15. var
  16. L,Dotted,NDotted : TStrings;
  17. aLine, aNewUnit, aFN,aRule,aLastDir,aLastRule : String;
  18. aOpts : TStringDynArray;
  19. begin
  20. Dotted:=Nil;
  21. NDotted:=nil;
  22. L:=TStringList.Create;
  23. try
  24. Dotted:=TStringList.Create;
  25. NDotted:=TStringList.Create;
  26. L.LoadFromFile(paramstr(1));
  27. for aLine in L do
  28. begin
  29. TNamespaceTool.SplitRuleLine(aLine,aFN,aRule,aLastDir,aLastRule,aOPts);
  30. aNewUnit:=TPrefixer.ApplyRule(aFN,aRule,aRule<>'');
  31. NDotted.Add(UpperCase(aFN)+'UNIT='+aFn);
  32. Dotted.Add(UpperCase(aFN)+'UNIT='+aNewUnit);
  33. end;
  34. Writeln('ifdef FPC_DOTTEDUNITS');
  35. For aLine in Dotted do
  36. Writeln(aLine);
  37. Writeln('else');
  38. For aLine in NDotted do
  39. Writeln(aLine);
  40. Writeln('endif');
  41. finally
  42. Dotted.Free;
  43. NDotted.Free;
  44. L.Free;
  45. end;
  46. end.