options.pas 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. public
  29. constructor Create;
  30. procedure LoadParams;
  31. property Help: boolean read FHelp write FHelp;
  32. property OutputFormat: Char read FOutputFormat write FOutputFormat;
  33. property X64: boolean read FX64 write FX64;
  34. property AVX512: boolean read FAVX512 write FAVX512;
  35. property Path: string read FPath write FPath;
  36. end;
  37. implementation
  38. uses SysUtils;
  39. { TOptions }
  40. constructor TOptions.Create;
  41. begin
  42. FHelp := false;
  43. FX64 := false;
  44. FAVX512 := false;
  45. FOutputFormat := '?';
  46. FPath := '';
  47. end;
  48. procedure TOptions.LoadParams;
  49. var
  50. i: integer;
  51. sParam: Char;
  52. sValue: String;
  53. IsInvalidParam: boolean;
  54. begin
  55. if ParamCount = 0 then FHelp := true
  56. else FHelp := false;
  57. FX64 := false;
  58. FOutputFormat := 'f'; // default = fpc
  59. FPath := IncludeTrailingBackslash(GetCurrentDir);
  60. for i := 1 to ParamCount do
  61. begin
  62. if copy(ParamStr(i), 1, 1) = '-' then
  63. begin
  64. sParam := copy(ParamStr(i) + ' ', 2, 1)[1];
  65. sValue := copy(ParamStr(i), 3, length(ParamStr(i)));
  66. IsInvalidParam := false;
  67. case sParam of
  68. 'h': FHelp := true;
  69. 'f': if sValue = 'fpc' then FOutputFormat := 'f'
  70. else if sValue = 'nasm' then FOutputFormat := 'n'
  71. else if sValue = 'fasm' then FOutputFormat := 'F'
  72. else if sValue = 'fpcinc' then FOutputFormat := 'I'
  73. else IsInvalidParam := true;
  74. 'p': if sValue = 'x8664' then
  75. begin
  76. Fx64 := true;
  77. end
  78. else IsInvalidParam := true;
  79. 'z': FAVX512 := true;
  80. 'o': if sValue <> '' then
  81. begin
  82. FPath := IncludeTrailingBackslash(sValue);
  83. end
  84. else
  85. begin
  86. FPath := '';
  87. end;
  88. else begin
  89. FHelp := true;
  90. writeln(format('invalid param "%s"', [ParamStr(i)]));
  91. end;
  92. end;
  93. end
  94. else IsInvalidParam := true;
  95. if IsInvalidParam then
  96. begin
  97. FHelp := true;
  98. writeln(format('invalid param "%s"', [ParamStr(i)]));
  99. end;
  100. end;
  101. end;
  102. end.