6 #include "../include/oberon.h"
8 static oberon_context_t
* ctx
;
9 static oberon_module_t
* mod
;
10 static const char * module
;
11 static const char * out_path
;
14 import_module(const char * name
)
20 snprintf(fname
, 256, "%s.obn", name
);
21 fp
= fopen(fname
, "r");
24 printf("can't open file %s\n", fname
);
32 fseek(fp
, 0, SEEK_END
);
34 fseek(fp
, 0, SEEK_SET
);
36 source
= calloc(1, len
+ 1);
37 fread(source
, len
, 1, fp
);
43 init(int argc
, char ** argv
)
48 if(argc
> 2 && strcmp(argv
[i
], "-d") == 0)
50 out_path
= argv
[i
+ 1];
55 if(argc
!= 2 || argv
[i
][0] == '-')
57 printf("usage: obn [-d out_dir] module\n");
65 main(int argc
, char ** argv
)
71 code
= import_module(module
);
73 ctx
= oberon_create_context(import_module
);
74 oberon_set_out_directory(ctx
, out_path
);
76 mod
= oberon_compile_module(ctx
, code
);
78 oberon_destroy_context(ctx
);