Browse Source

Deprecate `remove_ext(path)`. Introduce API conventions.

rexim 4 years ago
parent
commit
c374ffa920
5 changed files with 17 additions and 4 deletions
  1. 2 0
      ChangeLog.md
  2. 4 0
      README.md
  3. 1 1
      examples/string.c
  4. 2 2
      nobuild.c
  5. 8 1
      nobuild.h

+ 2 - 0
ChangeLog.md

@@ -5,6 +5,8 @@
 *Not Released Yet*
 
 - Introduced logging functions `INFO(fmt, ...)`, `WARN(fmt, ...)`, `ERRO(fmt, ...)`.
+- `remove_ext(path)` is deprecated. Please use `NOEXT(path)` instead. `remove_ext(path)` will be removed in the next major release.
+- Introduced API conventions. Functions that start with `nobuild__` (double underscore) are private to the library and should not be relied upon. They can be changed in any release without a warning.
 
 # 0.0.1 — First Official Release
 

+ 4 - 0
README.md

@@ -25,3 +25,7 @@ Keep in mind that [nobuild.h](./nobuild.h) is an [stb-style](https://github.com/
    - `$ cc nobuild.c -o nobuild` on POSIX systems
    - `$ cl.exe nobuild.c` on Windows with MSVC
 4. Run the build: `$ ./nobuild`
+
+## API Conventions
+
+- Functions from [nobuild.h](./nobuild.h) that start with `nobuild__` (double underscore) are private to the library and should not be relied upon. They can be changed in any release without a warning.

+ 1 - 1
examples/string.c

@@ -9,6 +9,6 @@ int main(int argc, char *argv[])
     DEMO(CONCAT("foo", "bar", "baz"));
     DEMO(PATH("foo", "bar", "baz"));
     DEMO(CONCAT_SEP("++", "foo", "bar", "baz"));
-    DEMO(remove_ext("main.c"));
+    DEMO(NOEXT("main.c"));
     return 0;
 }

+ 2 - 2
nobuild.c

@@ -3,9 +3,9 @@
 
 void check_example(const char *example)
 {
-    const char *example_path = PATH("examples", remove_ext(example));
+    const char *example_path = PATH("examples", NOEXT(example));
 
-    INFO("===== %s =====", remove_ext(example));
+    INFO("===== %s =====", NOEXT(example));
 
 #ifdef _WIN32
     CMD("cl.exe", "/Fe.\\examples\\", PATH("examples", example));

+ 8 - 1
nobuild.h

@@ -166,6 +166,7 @@ char *shift(int *argc, char ***argv);
 #define CONCAT_SEP(sep, ...) concat_sep_impl(sep, __VA_ARGS__, NULL)
 #define PATH(...) CONCAT_SEP(PATH_SEP, __VA_ARGS__)
 #define MKDIRS(...) mkdirs_impl(69, __VA_ARGS__, NULL)
+#define NOEXT(path) nobuild__remove_ext(path)
 
 void nobuild_log(FILE *stream, const char *tag, const char *fmt, ...);
 void nobuild_vlog(FILE *stream, const char *tag, const char *fmt, va_list args);
@@ -430,7 +431,7 @@ void cmd_impl(int ignore, ...)
     nobuild_exec(argv);
 }
 
-const char *remove_ext(const char *path)
+const char *nobuild__remove_ext(const char *path)
 {
     size_t n = strlen(path);
     while (n > 0 && path[n - 1] != '.') {
@@ -448,6 +449,12 @@ const char *remove_ext(const char *path)
     }
 }
 
+const char *remove_ext(const char *path)
+{
+    WARN("DEPRECATED: please use `NOEXT` instead of `remove_ext`. `remove_ext` will be removed in the next major release");
+    nobuild__remove_ext(path);
+}
+
 char *shift(int *argc, char ***argv)
 {
     assert(*argc > 0);