options.pas 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. {
  2. Copyright (C) <avx-testfile-generator> <Torsten Grundke>
  3. This source is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU General Public License as published by the Free
  5. Software Foundation; either version 2 of the License, or (at your option)
  6. any later version.
  7. This code is distributed in the hope that it will be useful, but WITHOUT ANY
  8. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. details.
  11. A copy of the GNU General Public License is available on the World Wide Web
  12. at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
  13. to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  14. MA 02110-1301, USA.
  15. }
  16. {$mode objfpc}
  17. unit options;
  18. interface
  19. type
  20. { TOptions }
  21. TOptions = class(TObject)
  22. private
  23. FAVX512: boolean;
  24. FHelp: boolean;
  25. FX64: boolean;
  26. FOutputFormat: Char;
  27. FPath: string;
  28. FMemRef: boolean;
  29. FFilemask: string;
  30. public
  31. constructor Create;
  32. procedure LoadParams;
  33. property Help: boolean read FHelp write FHelp;
  34. property OutputFormat: Char read FOutputFormat write FOutputFormat;
  35. property X64: boolean read FX64 write FX64;
  36. property AVX512: boolean read FAVX512 write FAVX512;
  37. property Path: string read FPath write FPath;
  38. property MemRef: boolean read FMemref write FMemRef;
  39. property Filemask: string read FFilemask write FFilemask;
  40. end;
  41. implementation
  42. uses SysUtils;
  43. { TOptions }
  44. constructor TOptions.Create;
  45. begin
  46. FHelp := false;
  47. FX64 := false;
  48. FAVX512 := false;
  49. FOutputFormat := '?';
  50. FPath := '';
  51. FMemRef := false;
  52. FFilemask := '';
  53. end;
  54. procedure TOptions.LoadParams;
  55. var
  56. i: integer;
  57. sParam: Char;
  58. sValue: String;
  59. IsInvalidParam: boolean;
  60. begin
  61. if ParamCount = 0 then FHelp := true
  62. else FHelp := false;
  63. FX64 := false;
  64. FOutputFormat := 'f'; // default = fpc
  65. FPath := IncludeTrailingBackslash(GetCurrentDir);
  66. for i := 1 to ParamCount do
  67. begin
  68. if copy(ParamStr(i), 1, 1) = '-' then
  69. begin
  70. sParam := copy(ParamStr(i) + ' ', 2, 1)[1];
  71. sValue := copy(ParamStr(i), 3, length(ParamStr(i)));
  72. IsInvalidParam := false;
  73. case sParam of
  74. 'h': FHelp := true;
  75. 'f': if sValue = 'fpc' then FOutputFormat := 'f'
  76. else if sValue = 'nasm' then FOutputFormat := 'n'
  77. else if sValue = 'fasm' then FOutputFormat := 'F'
  78. else if sValue = 'fpcinc' then FOutputFormat := 'I'
  79. else if sValue = 'fpcmref' then FOutputFormat := 'm'
  80. else if sValue = 'fpccd8' then FOutputFormat := 'd'
  81. else IsInvalidParam := true;
  82. 'p': if sValue = 'x8664' then
  83. begin
  84. Fx64 := true;
  85. end
  86. else IsInvalidParam := true;
  87. 'l': FOutputFormat := 'l';
  88. 'z': FAVX512 := true;
  89. 'm': FFilemask := sValue;
  90. 'o': if sValue <> '' then
  91. begin
  92. FPath := IncludeTrailingBackslash(sValue);
  93. end
  94. else
  95. begin
  96. FPath := '';
  97. end;
  98. else begin
  99. FHelp := true;
  100. writeln(format('invalid param "%s"', [ParamStr(i)]));
  101. end;
  102. end;
  103. end
  104. else IsInvalidParam := true;
  105. if IsInvalidParam then
  106. begin
  107. FHelp := true;
  108. writeln(format('invalid param "%s"', [ParamStr(i)]));
  109. end;
  110. end;
  111. end;
  112. end.