-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0f02444
Showing
25 changed files
with
847 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.ignore/* | ||
generated/* | ||
m |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# echo $PWD | ||
rm -rf ./m.config | ||
xxd -n root_contributors -i contributors ./locale/contributors.h | ||
xxd -n license_text -i license ./locale/license.h | ||
xxd -n help_text -i help ./locale/help.h | ||
xxd -n root_default_config -i default.config ./locale/config.h | ||
gcc -o m m.c -lm -D ENGLISH | ||
# gcc -o ./modules/success test_module.c -D test_success -Oz | ||
# gcc -o ./modules/failure test_module.c -Oz | ||
tcc -o ./modules/success test_module.c -D test_success -lm | ||
tcc -o ./modules/failure test_module.c -lm | ||
rm -rf ./generated/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#define config_maxsize 1024 * 4 | ||
#define config_reset file_write(root_config, root_default_config, sizeof(root_default_config)) | ||
|
||
list_t *config_load(char *filename){ | ||
/* Initialize an empty configuration */ | ||
list_t *self = list_new(module_alloc_default); | ||
|
||
/* export the default config if none exists */ | ||
char config[config_maxsize]; | ||
int read = file_read(root_config, config, sizeof(config)); | ||
if (read == false) { config_reset; } | ||
|
||
/* Load and begin processing the configuration file */ | ||
int len = file_read(root_config, config, sizeof(config)); | ||
int cursor; int last = 0; int line = 0; int item = 0; | ||
char *working_name; char *working_bin; char *working_flag; char *working_ext; | ||
for(cursor=0; cursor < len; cursor++) { | ||
if ( config[cursor] == '\n' ) { | ||
if (working_name == NULL) { printf(config_missing_name, line); exit(1); } | ||
else if (working_bin == NULL) { printf(config_missing_binary, line); exit(1); } | ||
else if (working_flag == NULL) { printf(config_missing_flag, line); exit(1); } | ||
else if (cursor == last) { printf(config_missing_ext, line); exit(1); } | ||
working_ext = string_substr(config, last, cursor); | ||
module_mount(self, working_name, working_bin, working_flag, working_ext); | ||
working_name = NULL; working_bin = NULL; working_flag = NULL; working_ext = NULL; | ||
line++; item = 0; last = cursor+1; | ||
} | ||
else if ( config[cursor] == ' ' ) { | ||
char *snippet = string_substr(config, last, cursor); | ||
switch(item) { | ||
default: printf(config_unexpected, line); exit(1); break; | ||
case 0: working_name = snippet; break; | ||
case 1: working_bin = snippet; break; | ||
case 2: working_flag = snippet; break; | ||
/* case 3: working_ext = snippet; break; !! DONE DURING NEWLINE*/ | ||
} item++; last = cursor+1; | ||
} | ||
} | ||
/* before returning, make sure we don't have a partial entry */ | ||
if (item == 0) { return self; } | ||
if (item == 1) { printf(config_missing_binary, line); exit(1); } | ||
if (item == 2) { printf(config_missing_flag); exit(1); } | ||
if (item == 3) { | ||
if (cursor == last) {printf(config_missing_flag, line); exit(1); } | ||
working_ext = string_substr(config, last, cursor); | ||
module_mount(self, working_name, working_bin, working_flag, working_ext); | ||
return self; | ||
} | ||
printf(config_unexpected, line); exit(1); | ||
} | ||
|
||
void config_save(list_t *modules, char *filename) { | ||
char *config = malloc(sizeof(char)*config_maxsize); | ||
char *line = malloc(sizeof(char)*512); | ||
int i; for(i=0;i<modules->entries;i++) { | ||
module_t *ref = modules->item[i]; | ||
sprintf(line, "%s %s %s %s\n", ref->name, ref->bin, ref->flag, ref->ext); | ||
config = string_concat(config, line); | ||
} | ||
file_write(filename, config, config_maxsize); | ||
free(config); | ||
free(line); | ||
} | ||
|
||
void config_edit() { | ||
#ifdef _WIN_32 | ||
system("notepad.exe " root_config); | ||
#elif defined(__APPLE__) | ||
system("open -a TextEdit ", root_config); | ||
#else | ||
system("nano " root_config); | ||
#endif | ||
exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
m cli: John Alex, Modula.dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DEBUG_OK success --TRUE .TRUE | ||
DEBUG_NO failure --FALSE .FALSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
an extensible cross-compiler CLI | ||
m [inputs] [flags] | ||
|
||
SETTINGS | ||
- `init` makes folders for modules and temporary files and creates a config | ||
- `config` launches the configuration file in a text editor | ||
- `reset` deletes the config and unmounts all modules | ||
- `license` prints the license agreement | ||
- `contributors` prints the names of the compiler's contributors | ||
|
||
MODULES | ||
- `install {name} {flag} {ext} {url}` downloads and mounts module from url | ||
- `mount {name} {flag} {ext} {binary}` installs local module | ||
- `remove {name}` deletes and unmounts the module | ||
- `unmount {name}` uninstalls local module without deleting | ||
- `list` prints the list of currently installed modules | ||
|
||
USAGE | ||
- `{filename.ext}` will infer the frontend from the file extension | ||
- `{-cflag} [filename]` will tell the cli to use a specific frontend | ||
- `{filename1} {filename2}` frontend outputs are passed in sequential order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
m - modula's extensible cross compiler | ||
|
||
ASSET LICENSE | ||
|
||
Copyright (C) 2024, Modula.dev, All Rights Reserved | ||
|
||
SOFTWARE LICENSE | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as | ||
published by the Free Software Foundation, either version 3 of the | ||
License, or (at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
|
||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
unsigned char root_default_config[] = { | ||
0x44, 0x45, 0x42, 0x55, 0x47, 0x5f, 0x4f, 0x4b, 0x20, 0x73, 0x75, 0x63, | ||
0x63, 0x65, 0x73, 0x73, 0x20, 0x2d, 0x2d, 0x54, 0x52, 0x55, 0x45, 0x20, | ||
0x2e, 0x54, 0x52, 0x55, 0x45, 0x0a, 0x44, 0x45, 0x42, 0x55, 0x47, 0x5f, | ||
0x4e, 0x4f, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x20, 0x2d, | ||
0x2d, 0x46, 0x41, 0x4c, 0x53, 0x45, 0x20, 0x2e, 0x46, 0x41, 0x4c, 0x53, | ||
0x45 | ||
}; | ||
unsigned int root_default_config_len = 61; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
unsigned char root_contributors[] = { | ||
0x6d, 0x20, 0x63, 0x6c, 0x69, 0x3a, 0x20, 0x4a, 0x6f, 0x68, 0x6e, 0x20, | ||
0x41, 0x6c, 0x65, 0x78, 0x2c, 0x20, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x61, | ||
0x2e, 0x64, 0x65, 0x76 | ||
}; | ||
unsigned int root_contributors_len = 28; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifdef ENGLISH | ||
#include "help.h" | ||
#define root_missing_module "error, no module for %s\n" | ||
#define root_missing_binary "error, missing module binary for %s\n" | ||
#define root_invalid_target "error, invalid target %s\n" | ||
#define root_error "error, %s threw code %d\n%s\n" | ||
|
||
#define config_missing_name "config error, ln %d missing module name\n" | ||
#define config_missing_binary "config error, ln %d missing binary name\n" | ||
#define config_missing_flag "config error, ln %d missing module flag\n" | ||
#define config_missing_ext "config error, ln %d missing associated file extension\n" | ||
#define config_unexpected "config error, ln %d unexpected values after entry\n" | ||
#define config_empty_value "config error, ln %d one or more entries left blank\n" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
unsigned char help_text[] = { | ||
0x20, 0x20, 0x20, 0x20, 0x61, 0x6e, 0x20, 0x65, 0x78, 0x74, 0x65, 0x6e, | ||
0x73, 0x69, 0x62, 0x6c, 0x65, 0x20, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x2d, | ||
0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x43, 0x4c, 0x49, | ||
0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x20, 0x5b, 0x69, 0x6e, 0x70, 0x75, | ||
0x74, 0x73, 0x5d, 0x20, 0x5b, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x5d, 0x0a, | ||
0x0a, 0x53, 0x45, 0x54, 0x54, 0x49, 0x4e, 0x47, 0x53, 0x0a, 0x20, 0x20, | ||
0x20, 0x20, 0x2d, 0x20, 0x60, 0x69, 0x6e, 0x69, 0x74, 0x60, 0x20, 0x6d, | ||
0x61, 0x6b, 0x65, 0x73, 0x20, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x73, | ||
0x20, 0x66, 0x6f, 0x72, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, | ||
0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, | ||
0x72, 0x79, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x20, 0x61, 0x6e, 0x64, | ||
0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x73, 0x20, 0x61, 0x20, 0x63, | ||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x20, | ||
0x60, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x60, 0x20, 0x6c, 0x61, 0x75, | ||
0x6e, 0x63, 0x68, 0x65, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, | ||
0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, | ||
0x66, 0x69, 0x6c, 0x65, 0x20, 0x69, 0x6e, 0x20, 0x61, 0x20, 0x74, 0x65, | ||
0x78, 0x74, 0x20, 0x65, 0x64, 0x69, 0x74, 0x6f, 0x72, 0x0a, 0x20, 0x20, | ||
0x20, 0x20, 0x2d, 0x20, 0x60, 0x72, 0x65, 0x73, 0x65, 0x74, 0x60, 0x20, | ||
0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, | ||
0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x75, | ||
0x6e, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, | ||
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x0a, 0x20, 0x20, 0x20, 0x20, | ||
0x2d, 0x20, 0x60, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x60, 0x20, | ||
0x70, 0x72, 0x69, 0x6e, 0x74, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, | ||
0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x20, 0x61, 0x67, 0x72, 0x65, 0x65, | ||
0x6d, 0x65, 0x6e, 0x74, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x20, 0x60, | ||
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x73, | ||
0x60, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x73, 0x20, 0x74, 0x68, 0x65, | ||
0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, | ||
0x65, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x27, 0x73, | ||
0x20, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, | ||
0x73, 0x0a, 0x0a, 0x4d, 0x4f, 0x44, 0x55, 0x4c, 0x45, 0x53, 0x0a, 0x20, | ||
0x20, 0x20, 0x20, 0x2d, 0x20, 0x60, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, | ||
0x6c, 0x20, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x20, 0x7b, 0x66, 0x6c, | ||
0x61, 0x67, 0x7d, 0x20, 0x7b, 0x65, 0x78, 0x74, 0x7d, 0x20, 0x7b, 0x75, | ||
0x72, 0x6c, 0x7d, 0x60, 0x20, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, | ||
0x64, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6d, 0x6f, 0x75, 0x6e, 0x74, | ||
0x73, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x66, 0x72, 0x6f, | ||
0x6d, 0x20, 0x75, 0x72, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x20, | ||
0x60, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x20, 0x20, 0x7b, 0x6e, 0x61, | ||
0x6d, 0x65, 0x7d, 0x20, 0x7b, 0x66, 0x6c, 0x61, 0x67, 0x7d, 0x20, 0x7b, | ||
0x65, 0x78, 0x74, 0x7d, 0x20, 0x7b, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, | ||
0x7d, 0x60, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x73, 0x20, | ||
0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, | ||
0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x20, 0x60, 0x72, 0x65, 0x6d, 0x6f, | ||
0x76, 0x65, 0x20, 0x20, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x60, 0x20, | ||
0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, | ||
0x75, 0x6e, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x20, 0x74, 0x68, 0x65, | ||
0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, | ||
0x2d, 0x20, 0x60, 0x75, 0x6e, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x7b, | ||
0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x60, 0x20, 0x75, 0x6e, 0x69, 0x6e, 0x73, | ||
0x74, 0x61, 0x6c, 0x6c, 0x73, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, | ||
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, | ||
0x75, 0x74, 0x20, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x0a, | ||
0x20, 0x20, 0x20, 0x20, 0x2d, 0x20, 0x60, 0x6c, 0x69, 0x73, 0x74, 0x60, | ||
0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, | ||
0x6c, 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x63, 0x75, 0x72, 0x72, | ||
0x65, 0x6e, 0x74, 0x6c, 0x79, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, | ||
0x6c, 0x65, 0x64, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x0a, | ||
0x0a, 0x55, 0x53, 0x41, 0x47, 0x45, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, | ||
0x20, 0x60, 0x7b, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x2e, | ||
0x65, 0x78, 0x74, 0x7d, 0x60, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x69, | ||
0x6e, 0x66, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x72, 0x6f, | ||
0x6e, 0x74, 0x65, 0x6e, 0x64, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, | ||
0x68, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x65, 0x78, 0x74, 0x65, | ||
0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x20, | ||
0x60, 0x7b, 0x2d, 0x63, 0x66, 0x6c, 0x61, 0x67, 0x7d, 0x20, 0x5b, 0x66, | ||
0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x5d, 0x60, 0x20, 0x77, 0x69, | ||
0x6c, 0x6c, 0x20, 0x74, 0x65, 0x6c, 0x6c, 0x20, 0x74, 0x68, 0x65, 0x20, | ||
0x63, 0x6c, 0x69, 0x20, 0x74, 0x6f, 0x20, 0x75, 0x73, 0x65, 0x20, 0x61, | ||
0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x20, 0x66, 0x72, | ||
0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, | ||
0x20, 0x60, 0x7b, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x31, | ||
0x7d, 0x20, 0x7b, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x32, | ||
0x7d, 0x60, 0x20, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x20, | ||
0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, | ||
0x70, 0x61, 0x73, 0x73, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x20, 0x73, 0x65, | ||
0x71, 0x75, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x20, 0x6f, 0x72, 0x64, | ||
0x65, 0x72 | ||
}; | ||
unsigned int help_text_len = 950; |
Oops, something went wrong.