1 (* M2DriverOptions.mod provides procedures to handle driver options.
3 Copyright (C) 2011-2022 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
22 IMPLEMENTATION MODULE M2DriverOptions ;
24 FROM DynamicStrings IMPORT String, Length, InitString, Mark, Slice, EqualArray,
25 InitStringCharStar, ConCatChar, ConCat, KillString,
26 PushAllocation, PopAllocationExemption, char ;
28 FROM SArgs IMPORT GetArg, Narg ;
29 FROM M2Options IMPORT CppRemember ;
33 CppArgument - some options might have arguments, remember these as well.
36 PROCEDURE CppArgument (i: CARDINAL; option: String) : CARDINAL ;
40 IF GetArg (arg, i+1) AND (char (arg, 0) # '-')
42 (* arg exists and is not an option and might be an argument to a specific option. *)
43 IF EqualArray (option, '-I')
46 CppRemember (arg) (* arg will be a path for -I. *)
47 ELSIF EqualArray (option, '-D')
50 CppRemember (arg) (* arg will be define for -D. *)
51 ELSIF EqualArray (option, '-isystem')
54 CppRemember (arg) (* arg will be a path for -isystem. *)
55 ELSIF EqualArray (option, '-imultiarch')
58 CppRemember (arg) (* arg will be a definition for -imultiarch. *)
66 ScanCppArgs - scans the cpp arguments and builds up the cpp command line.
69 PROCEDURE ScanCppArgs (i: CARDINAL) : CARDINAL ;
73 IF GetArg (option, i) AND EqualArray (option, '-fcpp-begin')
76 WHILE GetArg (option, i) DO
77 IF EqualArray (option, '-fcpp-end')
81 (* do not remember the filename. *)
82 IF char (option, 0)='-'
84 CppRemember (option) ;
85 i := CppArgument (i, option)