1 # module adding separate specification of opts to compiler
6 # only to order correctly redefs of compile_separate_module
7 import native_interface
9 redef class ToolContext
10 # all ops precised in .ops files
11 var separate_options
: OptionContext = new OptionContext
12 var opt_cc_lib_paths
: OptionArray = new OptionArray("Path to libraries for C compiler", "--cc-lib-path")
13 var opt_cc_libs
: OptionArray = new OptionArray("Name of library to use for C compiler", "--cc-lib-name")
14 var opt_cc_include_paths
: OptionArray = new OptionArray("Path to .h files for C compiler", "--cc-header-path")
20 separate_options
.add_option
( opt_cc_lib_paths
)
21 separate_options
.add_option
( opt_cc_libs
)
22 separate_options
.add_option
( opt_cc_include_paths
)
25 fun integrate_separate_options
( options
: String )
27 separate_options
.parse
( options
.split_with
( ' ' ) )
28 if separate_options
.rest
.length
> 0 then
29 warning
( null, "module {self} args file has unknown args: {separate_options.rest.join(", ")}" )
32 cc_lib_paths
.append
( opt_cc_lib_paths
.value
)
33 cc_libs
.append
( opt_cc_libs
.value
)
34 cc_include_paths
.append
( opt_cc_include_paths
.value
)
38 redef class MMSrcModule
40 redef fun compile_separate_module
(cprogram
)
44 # extract options from file
45 var options_path
= "{location.file.filename}.args"
46 if options_path
.file_exists
then
47 var option_file
= new IFStream.open
( options_path
)
48 var option_content
= option_file
.read_all
51 cprogram
.program
.tc
.integrate_separate_options
( option_content
)