From 51661f5c55f5f6d149e5c24392bdf03c088e2007 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sat, 27 Jul 2024 11:49:53 +0200 Subject: [PATCH] c3c init-lib does not create the directory with the .c3l suffix #1253 --- .github/workflows/main.yml | 7 +++++++ releasenotes.md | 1 + src/build/project_creation.c | 13 ++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8ccb88b62..80840a384 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -324,6 +324,13 @@ jobs: cd resources/testproject ../../build/c3c run --debug-log --linker=builtin + - name: Init a library & a project + run: | + ./build/c3c init-lib mylib + ls mylib.c3l + ./build/c3c init myproject + ls myproject + - name: run compiler tests run: | cd test diff --git a/releasenotes.md b/releasenotes.md index 2c6c89733..8261712af 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -12,6 +12,7 @@ - Made "add" the default for things like `sources`, `dependencies` and other keys in project and library files. - Give some symbol name suggestions when the path is matched. - Don't generate .o files on `compile` and `compile-run` if there is no `main`. +- c3c init-lib does not create the directory with the .c3l suffix #1253 ### Fixes - Broken WASM library code. diff --git a/src/build/project_creation.c b/src/build/project_creation.c index 951a3d109..9efa297f2 100644 --- a/src/build/project_creation.c +++ b/src/build/project_creation.c @@ -185,6 +185,11 @@ static const char *module_name(BuildOptions *build_options); void create_library(BuildOptions *build_options) { + if (str_has_suffix(build_options->project_name, ".c3l")) + { + exit_fail("Please remove the '.c3l' suffix from the project name."); + } + if (!check_name(build_options->project_name)) { exit_fail("'%s' is not a valid library name.", build_options->project_name); @@ -194,12 +199,13 @@ void create_library(BuildOptions *build_options) exit_fail("Can't open path %s", build_options->path); } - if (!dir_make(build_options->project_name)) + const char *dir = str_cat(build_options->project_name, ".c3l"); + if (!dir_make(dir)) { - exit_fail("Could not create directory %s.", build_options->project_name); + exit_fail("Could not create directory %s.", dir); } - chdir_or_fail(build_options, build_options->project_name); + chdir_or_fail(build_options, dir); create_file_or_fail(build_options, "LICENSE", NULL); create_file_or_fail(build_options, "README.md", LIB_README, build_options->project_name); mkdir_or_fail(build_options, "scripts"); @@ -215,6 +221,7 @@ void create_library(BuildOptions *build_options) mkdir_or_fail(build_options, target); } create_file_or_fail(build_options, "manifest.json", MANIFEST_TEMPLATE, build_options->project_name, scratch_buffer_to_string()); + printf("The '%s' library has been set up in the directory '%s'.\n", build_options->project_name, dir); } void create_project(BuildOptions *build_options)