(* Filled with any cpp-like defines seen on argv.
FIXME: Add something like `-D__ACTION_SCRIPT_2__' to it so we can
differentiate when we're compiling action script, and when c *)
(* Filled with the rest of command-line arguments *)
(* List of command-options we'd like to process *)
(* One option just for the test *)
let verbose = ref false
let begins_with_D str =
String.length str
>= 2 && str
.[0] = '-' && str
.[1] = 'D
';;
let split_argv str =
let usage = "usage string\n Options :" in
let file = "some_file" in
let defines, args =
let args_spec = [
("-v",
Arg.Unit
(fun () -> verbose
:= true),
"turn on verbose mode"); ] @ !options in
Arg.parse_argv
!args args_spec
(fun file -> files := file :: !files) usage;
(* Debug defines *)
List.iter
(printf
"'%s' ") !defines
; printf "\n";
(* Debug args *)
printf "\n";
;;
b3BlbiBQcmludGYKCigqIEZpbGxlZCB3aXRoIGFueSBjcHAtbGlrZSBkZWZpbmVzIHNlZW4gb24gYXJndi4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgIEZJWE1FOiBBZGQgc29tZXRoaW5nIGxpa2UgYC1EX19BQ1RJT05fU0NSSVBUXzJfXycgdG8gaXQgc28gd2UgY2FuICAgICAgICAgICAgICAgICAgICAgICAgCiAgIGRpZmZlcmVudGlhdGUgd2hlbiB3ZSdyZSBjb21waWxpbmcgYWN0aW9uIHNjcmlwdCwgYW5kIHdoZW4gYyAqKQpsZXQgZGVmaW5lcyA9IHJlZiAoW10gOiBzdHJpbmcgbGlzdCkKCigqIEZpbGxlZCB3aXRoIHRoZSByZXN0IG9mIGNvbW1hbmQtbGluZSBhcmd1bWVudHMgKikKbGV0IGFyZ3MgPSByZWYgKFtdIDogc3RyaW5nIGxpc3QpCgooKiBMaXN0IG9mIGNvbW1hbmQtb3B0aW9ucyB3ZSdkIGxpa2UgdG8gcHJvY2VzcyAqKQpsZXQgb3B0aW9ucyA9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