Skip to content

Commit c67a743

Browse files
authored
Merge pull request #212 from tsoding/next-release
Release v3.2.1
2 parents 918a5fc + bea26aa commit c67a743

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

nob.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const char *test_names[] = {
1717
"no_echo",
1818
"cmd_run_dont_reset",
1919
"chain",
20+
"private_functions_inside_public_macros",
2021
};
2122
#define test_names_count ARRAY_LEN(test_names)
2223

nob.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ typedef struct {
315315
DIR *posix_dir;
316316
struct dirent *posix_ent;
317317
#endif // _WIN32
318-
} nob__private;
318+
} nob__private; // TODO: we don't have solid conventions regarding private struct fields
319319
} Nob_Dir_Entry;
320320

321321
// nob_dir_entry_open() - open the directory entry for iteration.
@@ -643,10 +643,13 @@ typedef struct {
643643
// use it as a C string.
644644
NOBDEF void nob_cmd_render(Nob_Cmd cmd, Nob_String_Builder *render);
645645

646+
NOBDEF void nob__cmd_append(Nob_Cmd *cmd, size_t n, ...);
646647
#define nob_cmd_append(cmd, ...) \
647648
nob__cmd_append(cmd, (sizeof((const char*[]){__VA_ARGS__})/sizeof(const char*)), __VA_ARGS__)
648649

649650
// TODO: nob_cmd_extend() evaluates other_cmd twice
651+
// It can be fixed by turning nob_cmd_extend() call into a statement.
652+
// But that may break backward compatibility of the API.
650653
#define nob_cmd_extend(cmd, other_cmd) \
651654
nob_da_append_many(cmd, (other_cmd)->items, (other_cmd)->count)
652655

@@ -753,7 +756,7 @@ NOBDEF char *nob_temp_file_name(const char *path);
753756
NOBDEF char *nob_temp_file_ext(const char *path);
754757
NOBDEF char *nob_temp_running_executable_path(void);
755758

756-
// TODO: we should probably document somewhere all the compiler we support
759+
// TODO: we should probably document somewhere all the compilers we support
757760

758761
// The nob_cc_* macros try to abstract away the specific compiler.
759762
// They are verify basic and not particularly flexible, but you can redefine them if you need to
@@ -922,7 +925,7 @@ static Nob_Proc nob__cmd_start_process(Nob_Cmd cmd, Nob_Fd *fdin, Nob_Fd *fdout,
922925
// Any messages with the level below nob_minimal_log_level are going to be suppressed.
923926
Nob_Log_Level nob_minimal_log_level = NOB_INFO;
924927

925-
void nob__cmd_append(Nob_Cmd *cmd, size_t n, ...)
928+
NOBDEF void nob__cmd_append(Nob_Cmd *cmd, size_t n, ...)
926929
{
927930
va_list args;
928931
va_start(args, n);
@@ -2907,6 +2910,7 @@ NOBDEF char *nob_temp_running_executable_path(void)
29072910
/*
29082911
Revision history:
29092912
2913+
Fix the implicit declaration error when nob is included as a header (by @ysoftware)
29102914
3.2.0 (2026-01-28) Introduce Chain API
29112915
- Nob_Chain
29122916
- Nob_Chain_Begin_Opt
@@ -3092,12 +3096,16 @@ NOBDEF char *nob_temp_running_executable_path(void)
30923096
- Breaking backward compatibility in a MINOR release should be considered a bug and
30933097
should be promptly fixed in the next PATCH release.
30943098
3095-
Naming Conventions:
3099+
API conventions:
30963100
3097-
- All the user facing names should be prefixed with `nob_` or `NOB_` depending on the case.
3101+
- All the user facing names should be prefixed with `nob_`, `NOB_`, or `Nob_` depending on the case.
30983102
- The prefixes of non-redefinable names should be stripped in NOB_STRIP_PREFIX_GUARD_ section,
30993103
unless explicitly stated otherwise like in case of nob_log() or nob_rename().
3100-
- Internal names should be prefixed with `nob__` (double underscore).
3104+
- Internal (private) names should be prefixed with `nob__` (double underscore). The user code is discouraged
3105+
from using such names since they are allowed to be broken in a backward incompatible way even in PATCH
3106+
releases. (This is why they are internal)
3107+
- If a public macro uses an private function internally such function must be forward declared in the NOB_H_
3108+
section.
31013109
*/
31023110

31033111
/*

shared.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool build_tool(Cmd *cmd, Procs *procs, const char *bin_path, const char *src_pa
5555
// To make sure no compiler output pollutes the test output.
5656
// This is needed specifically for cl.exe cause it has
5757
// a tendency to output compiled source files to stdout.
58-
.stdout_path = temp_sprintf("%s.comp.txt", bin_path),
58+
.stdout_path = temp_sprintf("%s.comp.txt", bin_path),
5959
);
6060
}
6161

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Some public functions may use private functions internally.
2+
// Examples are NOB_GO_REBUILD_URSELF* and nob_cmd_append().
3+
// Which means such private functions must be declared in the header part
4+
// publically, even though their usage by the end users is discouraged.
5+
6+
#include "nob.h"
7+
8+
int main(void)
9+
{
10+
Cmd cmd = {0};
11+
cmd_append(&cmd, "foo", "bar", "baz");
12+
da_foreach(const char *, arg, &cmd) {
13+
printf("%s\n", *arg);
14+
}
15+
return 0;
16+
}
17+
18+
#define NOB_IMPLEMENTATION
19+
#include "nob.h"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
foo
2+
bar
3+
baz
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
foo
2+
bar
3+
baz

0 commit comments

Comments
 (0)