From 0129308bf33ddc86f93059c98d0bf4fffb03d422 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Fri, 25 Apr 2025 15:44:34 +0200 Subject: [PATCH] `c3c build` picks first target rather than the first executable #2105. --- releasenotes.md | 1 + src/build/project.c | 17 +---------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/releasenotes.md b/releasenotes.md index 9eb410c12..88eed439e 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -18,6 +18,7 @@ - `Foo[1..2] = { .baz = 123 }` inference now works. #2095 - Deprecated old inference with slice copy. Copying must now ensure a slicing operator at the end of the right hand side: `foo[1..2] = bar[..]` rather than the old `foo[1..2] = bar`. The old behaviour can be mostly retained with `--use-old-slice-copy`). - Added `Enum.lookup` and `Enum.lookup_field`. +- `c3c build` picks first target rather than the first executable #2105. ### Fixes - Trying to cast an enum to int and back caused the compiler to crash. diff --git a/src/build/project.c b/src/build/project.c index 51b7a89b6..0a546cc06 100644 --- a/src/build/project.c +++ b/src/build/project.c @@ -514,21 +514,6 @@ static void project_add_targets(const char *filename, Project *project, JSONObje } } -/** - * Grab the default target, this will be the executable if one exists, otherwise - * it's the first target in the list. - * - * @param project - * @return the selected build target. - */ -static BuildTarget *project_select_default_target(Project *project) -{ - FOREACH(BuildTarget *, target, project->targets) - { - if (target->type == TARGET_TYPE_EXECUTABLE) return target; - } - return project->targets[0]; -} /** * Select the project target. This may be given a target, if so it is looked for. @@ -546,7 +531,7 @@ BuildTarget *project_select_target(const char *filename, Project *project, const } if (!optional_target) { - return project_select_default_target(project); + return project->targets[0]; } FOREACH(BuildTarget *, target, project->targets) {