gendef.pas 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. {
  2. $Id$
  3. Copyright (c) 1996-98 by Florian Klaempfl
  4. Generation of a .def file for needed for Os2/Win32
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  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. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit gendef;
  19. interface
  20. uses cobjects;
  21. type
  22. pdeffile=^tdeffile;
  23. tdeffile=object
  24. fname : string;
  25. exportlist,
  26. importlist : tstringcontainer;
  27. constructor init(const fn:string);
  28. destructor done;
  29. procedure addexport(const s:string);
  30. procedure addimport(const s:string);
  31. procedure writefile;
  32. end;
  33. var
  34. deffile : tdeffile;
  35. implementation
  36. uses
  37. systems,globals;
  38. {******************************************************************************
  39. TDefFile
  40. ******************************************************************************}
  41. constructor tdeffile.init(const fn:string);
  42. begin
  43. fname:=fn;
  44. importlist.init;
  45. exportlist.init;
  46. end;
  47. destructor tdeffile.done;
  48. begin
  49. importlist.done;
  50. exportlist.done;
  51. end;
  52. procedure tdeffile.addexport(const s:string);
  53. begin
  54. exportlist.insert(s);
  55. end;
  56. procedure tdeffile.addimport(const s:string);
  57. begin
  58. importlist.insert(s);
  59. end;
  60. procedure tdeffile.writefile;
  61. var
  62. t : text;
  63. begin
  64. assign(t,fname);
  65. {$I+}
  66. rewrite(t);
  67. {$I-}
  68. if ioresult<>0 then
  69. exit;
  70. {$ifdef i386}
  71. case target_info.target of
  72. target_Os2 : begin
  73. write(t,'NAME '+inputfile);
  74. if usewindowapi then
  75. write(t,' WINDOWAPI');
  76. writeln(t,'');
  77. writeln(t,'PROTMODE');
  78. writeln(t,'DESCRIPTION '+''''+description+'''');
  79. writeln(t,'DATA'#9'MULTIPLE');
  80. writeln(t,'STACKSIZE'#9+tostr(stacksize));
  81. writeln(t,'HEAPSIZE'#9+tostr(heapsize));
  82. end;
  83. end;
  84. {$endif}
  85. {write imports}
  86. if not importlist.empty then
  87. begin
  88. writeln(t,'');
  89. writeln(t,'IMPORTS');
  90. while not importlist.empty do
  91. writeln(t,#9+importlist.get);
  92. end;
  93. {write exports}
  94. if not exportlist.empty then
  95. begin
  96. writeln(t,'');
  97. writeln(t,'EXPORTS');
  98. while not exportlist.empty do
  99. writeln(t,#9+exportlist.get);
  100. end;
  101. close(t);
  102. end;
  103. end.
  104. {
  105. $Log$
  106. Revision 1.1 1998-06-04 23:51:39 peter
  107. * m68k compiles
  108. + .def file creation moved to gendef.pas so it could also be used
  109. for win32
  110. }