options.pas 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 = 'gas' then FOutputFormat := 'g'
  78. else if sValue = 'fasm' then FOutputFormat := 'F'
  79. else if sValue = 'fpcinc' then FOutputFormat := 'I'
  80. else if sValue = 'fpcmref' then FOutputFormat := 'm'
  81. else if sValue = 'fpccd8' then FOutputFormat := 'd'
  82. else IsInvalidParam := true;
  83. 'p': if sValue = 'x8664' then
  84. begin
  85. Fx64 := true;
  86. end
  87. else IsInvalidParam := true;
  88. 'l': FOutputFormat := 'l';
  89. 'z': FAVX512 := true;
  90. 'm': FFilemask := sValue;
  91. 'o': if sValue <> '' then
  92. begin
  93. FPath := IncludeTrailingBackslash(sValue);
  94. end
  95. else
  96. begin
  97. FPath := '';
  98. end;
  99. else begin
  100. FHelp := true;
  101. writeln(format('invalid param "%s"', [ParamStr(i)]));
  102. end;
  103. end;
  104. end
  105. else IsInvalidParam := true;
  106. if IsInvalidParam then
  107. begin
  108. FHelp := true;
  109. writeln(format('invalid param "%s"', [ParamStr(i)]));
  110. end;
  111. end;
  112. end;
  113. end.