123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- {
- Copyright (C) <avx-testfile-generator> <Torsten Grundke>
- This source is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2 of the License, or (at your option)
- any later version.
- This code is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
- A copy of the GNU General Public License is available on the World Wide Web
- at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
- to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
- }
- {$mode objfpc}
- unit options;
- interface
- type
- { TOptions }
- TOptions = class(TObject)
- private
- FAVX512: boolean;
- FHelp: boolean;
- FX64: boolean;
- FOutputFormat: Char;
- FPath: string;
- public
- constructor Create;
- procedure LoadParams;
- property Help: boolean read FHelp write FHelp;
- property OutputFormat: Char read FOutputFormat write FOutputFormat;
- property X64: boolean read FX64 write FX64;
- property AVX512: boolean read FAVX512 write FAVX512;
- property Path: string read FPath write FPath;
- end;
- implementation
- uses SysUtils;
- { TOptions }
- constructor TOptions.Create;
- begin
- FHelp := false;
- FX64 := false;
- FAVX512 := false;
- FOutputFormat := '?';
- FPath := '';
- end;
- procedure TOptions.LoadParams;
- var
- i: integer;
- sParam: Char;
- sValue: String;
- IsInvalidParam: boolean;
- begin
- if ParamCount = 0 then FHelp := true
- else FHelp := false;
- FX64 := false;
- FOutputFormat := 'f'; // default = fpc
- FPath := IncludeTrailingBackslash(GetCurrentDir);
- for i := 1 to ParamCount do
- begin
- if copy(ParamStr(i), 1, 1) = '-' then
- begin
- sParam := copy(ParamStr(i) + ' ', 2, 1)[1];
- sValue := copy(ParamStr(i), 3, length(ParamStr(i)));
- IsInvalidParam := false;
- case sParam of
- 'h': FHelp := true;
- 'f': if sValue = 'fpc' then FOutputFormat := 'f'
- else if sValue = 'nasm' then FOutputFormat := 'n'
- else if sValue = 'fasm' then FOutputFormat := 'F'
- else if sValue = 'fpcinc' then FOutputFormat := 'I'
- else IsInvalidParam := true;
- 'p': if sValue = 'x8664' then
- begin
- Fx64 := true;
- end
- else IsInvalidParam := true;
- 'z': FAVX512 := true;
- 'o': if sValue <> '' then
- begin
- FPath := IncludeTrailingBackslash(sValue);
- end
- else
- begin
- FPath := '';
- end;
- else begin
- FHelp := true;
- writeln(format('invalid param "%s"', [ParamStr(i)]));
- end;
- end;
- end
- else IsInvalidParam := true;
- if IsInvalidParam then
- begin
- FHelp := true;
- writeln(format('invalid param "%s"', [ParamStr(i)]));
- end;
- end;
- end;
- end.
|