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

Fix nob's program name on windows #87

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/nob.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ int nob_file_exists(const char *file_path);
# endif
#endif

#ifdef _WIN32
#define NOB_FIX_ARGV(argv) \
do { \
if (strstr(argv[0], ".exe") == NULL) { \
char* temp = malloc(strlen(argv[0]) + 5); \
strcpy(temp, argv[0]); \
strcat(temp, ".exe"); \
argv[0] = temp; \
} \
} while(0)
#else
#define NOB_FIX_ARGV(argv)
#endif

// Go Rebuild Urself™ Technology
//
// How to use it:
Expand All @@ -259,6 +273,7 @@ int nob_file_exists(const char *file_path);
//
#define NOB_GO_REBUILD_URSELF(argc, argv) \
do { \
NOB_FIX_ARGV(argv); \
const char *source_path = __FILE__; \
assert(argc >= 1); \
const char *binary_path = argv[0]; \
Expand Down