]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/gm2-compiler/M2DriverOptions.mod
Update copyright years.
[thirdparty/gcc.git] / gcc / m2 / gm2-compiler / M2DriverOptions.mod
1 (* M2DriverOptions.mod provides procedures to handle driver options.
2
3 Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
5
6 This file is part of GNU Modula-2.
7
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)
11 any later version.
12
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.
17
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/>. *)
21
22 IMPLEMENTATION MODULE M2DriverOptions ;
23
24 FROM DynamicStrings IMPORT String, Length, InitString, Mark, Slice, EqualArray,
25 InitStringCharStar, ConCatChar, ConCat, KillString,
26 PushAllocation, PopAllocationExemption, char ;
27
28 FROM SArgs IMPORT GetArg, Narg ;
29 FROM M2Options IMPORT CppRemember ;
30
31
32 (*
33 CppArgument - some options might have arguments, remember these as well.
34 *)
35
36 PROCEDURE CppArgument (i: CARDINAL; option: String) : CARDINAL ;
37 VAR
38 arg: String ;
39 BEGIN
40 IF GetArg (arg, i+1) AND (char (arg, 0) # '-')
41 THEN
42 (* arg exists and is not an option and might be an argument to a specific option. *)
43 IF EqualArray (option, '-I')
44 THEN
45 INC (i) ;
46 CppRemember (arg) (* arg will be a path for -I. *)
47 ELSIF EqualArray (option, '-D')
48 THEN
49 INC (i) ;
50 CppRemember (arg) (* arg will be define for -D. *)
51 ELSIF EqualArray (option, '-isystem')
52 THEN
53 INC (i) ;
54 CppRemember (arg) (* arg will be a path for -isystem. *)
55 ELSIF EqualArray (option, '-imultiarch')
56 THEN
57 INC (i) ;
58 CppRemember (arg) (* arg will be a definition for -imultiarch. *)
59 END
60 END ;
61 RETURN i
62 END CppArgument ;
63
64
65 (*
66 ScanCppArgs - scans the cpp arguments and builds up the cpp command line.
67 *)
68
69 PROCEDURE ScanCppArgs (i: CARDINAL) : CARDINAL ;
70 VAR
71 option: String ;
72 BEGIN
73 IF GetArg (option, i) AND EqualArray (option, '-fcpp-begin')
74 THEN
75 INC (i) ;
76 WHILE GetArg (option, i) DO
77 IF EqualArray (option, '-fcpp-end')
78 THEN
79 RETURN i
80 ELSE
81 (* do not remember the filename. *)
82 IF char (option, 0)='-'
83 THEN
84 CppRemember (option) ;
85 i := CppArgument (i, option)
86 END
87 END ;
88 INC (i)
89 END
90 END ;
91 RETURN i
92 END ScanCppArgs ;
93
94
95 END M2DriverOptions.