`onyx-pkg` command is now gone. All functionality moved into `onyx pkg` command.
+++ /dev/null
-#!/bin/sh
-
-# @Cleanup this assumes that this is the path, but it could be modified.
-onyx run /usr/share/onyx/tools/onyx-pkg.onyx -- $@
\ No newline at end of file
sudo cp -r ./core/ "$CORE_DIR"
-sudo cp ./bin/onyx-pkg "$BIN_DIR/onyx-pkg"
sudo mkdir -p "$CORE_DIR/tools"
sudo cp ./scripts/onyx-pkg.onyx "$CORE_DIR/tools"
#define VERSION "v0.1.0"
-// #ifndef CORE_INSTALLATION
-// #ifdef _BH_LINUX
-// #define CORE_INSTALLATION "/usr/share/onyx"
-// #elif defined(_WIN32) || defined(_WIN64)
-// #define CORE_INSTALLATION "\\dev\\onyx\\"
-// #endif
-// #endif
-
-
-
-
Context context;
-static const char* docstring = "Onyx compiler version " VERSION "\n"
+static const char* docstring = "Onyx toolchain version " VERSION "\n"
"\n"
- "The compiler for the Onyx programming language, created by Brendan Hansen.\n"
+ "The toolchain for the Onyx programming language, created by Brendan Hansen.\n"
"\n"
"Usage:\n"
"\tonyx compile [-o <target file>] [--verbose] <input files>\n"
- "\tonyx check [--verbose] <input files>\n"
+ "\tonyx check <input files>\n"
#ifdef ENABLE_RUN_WITH_WASMER
"\tonyx run <input files> -- <args>\n"
#endif
+ "\tonyx pkg\n"
// "\tonyx doc <input files>\n"
"\tonyx help\n"
"\n"
- "Flags:\n"
+ "Compile Flags:\n"
"\t<input files> List of initial files\n"
"\t-o <target_file> Specify the target file (default: out.wasm).\n"
+ "\t --output <target_file>\n"
"\t--runtime, -r <runtime> Specifies the runtime. Can be: onyx, wasi, js, custom.\n"
"\t--verbose, -V Verbose output.\n"
"\t -VV Very verbose output.\n"
i32 arg_parse_start = 1;
if (!strcmp(argv[1], "help")) options.action = ONYX_COMPILE_ACTION_PRINT_HELP;
- if (!strcmp(argv[1], "compile")) {
+ if (!strcmp(argv[1], "compile") || !strcmp(argv[1], "build")) {
options.action = ONYX_COMPILE_ACTION_COMPILE;
arg_parse_start = 2;
}
options.action = ONYX_COMPILE_ACTION_CHECK;
arg_parse_start = 2;
}
+ if (!strcmp(argv[1], "pkg") || !strcmp(argv[1], "package")) {
+ options.action = ONYX_COMPILE_ACTION_RUN;
+ options.passthrough_argument_count = argc - 2;
+ options.passthrough_argument_data = &argv[2];
+ arg_parse_start = argc;
+
+ bh_arr_push(options.files, bh_aprintf(global_heap_allocator, "%s/tools/onyx-pkg.onyx", core_installation));
+ }
#ifdef ENABLE_RUN_WITH_WASMER
else if (!strcmp(argv[1], "run")) {
options.action = ONYX_COMPILE_ACTION_RUN;
arg_parse_start = 2;
}
#endif
- else options.action = ONYX_COMPILE_ACTION_COMPILE;
if (options.action != ONYX_COMPILE_ACTION_PRINT_HELP) {
fori(i, arg_parse_start, argc) {
- if (!strcmp(argv[i], "-o")) {
+ if (!strcmp(argv[i], "-o") || !strcmp(argv[i], "--output")) {
options.target_file = argv[++i];
}
else if (!strcmp(argv[i], "--verbose") || !strcmp(argv[i], "-V")) {
onyx_report_error((parser->curr - 2)->pos, Error_Critical, "#Self is only allowed in an #inject block.");
}
- retval = parser->injection_point;
+ AstAlias* alias = make_node(AstAlias, Ast_Kind_Alias);
+ alias->token = parser->injection_point->token;
+ alias->alias = parser->injection_point;
+ retval = (AstTyped *) alias;
break;
}
If result contains Err, the given code is run. This code is
expected to either:
- Return a good value with `return`
- - Return an error value with `return #enclosing_scope`
+ - Return an error value with `return #from_enclosing`
This procedure is subject to change.
"""
#tag Command.{ "help", "Show help.", "", require_config_file=false }
run_help_command :: (args: [] cstr) {
- printf("onyx-pkg version {}\n", Version);
+ printf("onyx pkg version {}\n", Version);
printf("Package dependency resolver and synchronizer for Onyx.\n\nUsage:\n");
command_procedures := runtime.info.get_procedures_with_tag(Command);
defer delete(^command_procedures);
for command_procedures {
printf("{}\n", it.tag.description);
- printf(" onyx-pkg {} {}\n", it.tag.command, it.tag.arguments);
+ printf(" onyx pkg {} {}\n", it.tag.command, it.tag.arguments);
if it.tag.argument_descriptions.count > 0 {
lines := string.split(it.tag.argument_descriptions, #char "\n", context.temp_allocator);
}
}
-#tag Command.{ "new", "Create a new project from an installed template." }
+#tag Command.{ "new", "Create a new project in the current directory." }
run_new_command :: (args: [] cstr) {
-
+ // Create onyx-pkg.ini
+ // Create onyx-lsp.ini
+ // Create src/main.onyx
+ // Create .gitignore
}
io.write(^w, """
//
-// THIS FILE WAS AUTOMATICALLY GENERATED BY onyx-pkg.
+// THIS FILE WAS AUTOMATICALLY GENERATED BY onyx pkg.
// DO NOT MODIFY UNLESS YOU KNOW WHAT YOU ARE DOING.
//
b32 bh_str_starts_with(char* str, char* start);
b32 bh_str_ends_with(char* str, char* end);
+b32 bh_str_contains(char *str, char *needle);
char* bh_strdup(bh_allocator a, char* str);
return *e == *s;
}
+b32 bh_str_contains(char *str, char *needle) {
+ while (*str) {
+ char *walk = needle;
+ while (*str == *walk && *walk) walk++, str++;
+ if (*walk) return 1;
+ }
+
+ return 0;
+}
+
char* bh_strdup(bh_allocator a, char* str) {
u32 len = strlen(str);
char* buf = bh_alloc(a, len + 1);