Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List the supported targets using odin build . -targets:? #4471

Merged
merged 3 commits into from
Nov 11, 2024

Conversation

bayo-code
Copy link
Contributor

Added support for listing supported targets using odin targets.

@Kelimion
Copy link
Member

Kelimion commented Nov 10, 2024

This is asymmetric with odin build . -microarch:? and odin build . -target-features:?

@bayo-code
Copy link
Contributor Author

What do I need to add, please?

I'm new to the project, and I'm still trying to find my way around the code.

@FourteenBrush
Copy link
Contributor

FourteenBrush commented Nov 10, 2024

I mean odin build prints the available targets when you attempt to do something like odin build . -target:something-invalid, but having it support -target:? doesn't sound bad.

What do I need to add, please?

Perhaps this could help?

Odin/src/main.cpp

Lines 3280 to 3310 in da196a2

// Check chosen microarchitecture. If not found or ?, print list.
bool print_microarch_list = true;
if (build_context.microarch.len == 0 || build_context.microarch == str_lit("native")) {
// Autodetect, no need to print list.
print_microarch_list = false;
} else {
String march_list = target_microarch_list[build_context.metrics.arch];
String_Iterator it = {march_list, 0};
for (;;) {
String str = string_split_iterator(&it, ',');
if (str == "") break;
if (str == build_context.microarch) {
// Found matching microarch
print_microarch_list = false;
break;
}
}
}
// Set and check build paths...
if (!init_build_paths(init_filename)) {
return 1;
}
String default_march = get_default_microarchitecture();
if (print_microarch_list) {
if (build_context.microarch != "?") {
gb_printf("Unknown microarchitecture '%.*s'.\n", LIT(build_context.microarch));
}
gb_printf("Possible -microarch values for target %.*s are:\n", LIT(target_arch_names[build_context.metrics.arch]));
gb_printf("\n");

@bayo-code
Copy link
Contributor Author

Ah, yes this makes sense now... I think I can do this 🙂

@bayo-code bayo-code changed the title List the supported targets using odin targets List the supported targets using odin build . -targets:? Nov 11, 2024
@Kelimion Kelimion merged commit 74178cd into odin-lang:master Nov 11, 2024
7 checks passed
@bayo-code bayo-code deleted the list-supported-targets branch November 11, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants