5 #include "shotgun/config.h"
6 #include "shotgun/lib/shotgun.h"
7 #include "shotgun/lib/machine.h"
8 #include "shotgun/lib/subtend/ruby.h"
9 #include "shotgun/lib/environment.h"
11 /* TODO incorporate system paths calculated at compile time. */
12 static const char *search_path
[] = {
19 static char *search_for(const char *evs
, const char *file
) {
21 static char path
[PATH_MAX
];
25 #define file_exists_p(file) stat(file, &_st) == 0
29 if(file_exists_p(env
)) return env
;
33 for(i
= 0; search_path
[i
]; i
++) {
34 snprintf(path
, PATH_MAX
, "%s/%s", search_path
[i
], file
);
35 if(file_exists_p(path
)) {
43 int main(int argc
, char **argv
) {
48 environment_at_startup();
50 e
= environment_new();
52 environment_setup_thread(e
, m
);
54 machine_setup_normal(m
, argc
, argv
);
56 /* We build up the environment information by looking around
57 * the filesystem now. */
59 /* Find the platform config */
60 e
->platform_config
= search_for("RBX_PLATFORM_CONF", "platform.conf");
62 /* Find the bootstrap. */
63 archive
= search_for("RBX_BOOTSTRAP", "bootstrap");
65 printf("Unable to find a bootstrap to load!\n");
68 e
->bootstrap_path
= archive
;
70 /* Find the platform. */
71 archive
= search_for("RBX_PLATFORM", "platform");
73 printf("Unable to find a platform to load!\n");
77 e
->platform_path
= archive
;
80 archive
= search_for("RBX_CORE", "core");
82 printf("Unable to find a core to load!\n");
86 e
->core_path
= archive
;
88 /* Load the loader.rbc */
89 archive
= search_for("RBX_LOADER", "loader.rbc");
91 printf("Unable to find loader.rbc to load!\n");
95 e
->loader_path
= archive
;
97 environment_load_machine(e
, m
);
101 printf("[GC M %6dK total]\n", m
->s
->om
->ms
->allocated_bytes
);