1
1
mirror of https://github.com/theoludwig/libcproject.git synced 2024-11-08 22:31:31 +01:00
libcproject/set_version.c

24 lines
764 B
C
Raw Normal View History

2023-01-05 21:13:10 +01:00
#include <stdio.h>
#include <stdlib.h>
#include "libcproject.h"
2023-06-25 15:01:25 +02:00
int main(int argc, string* argv) {
2023-01-05 21:13:10 +01:00
if (argc != 2) {
fprintf(stderr, "Usage: %s <version>\n", argv[0]);
return EXIT_FAILURE;
}
2023-06-25 15:01:25 +02:00
string content = "#ifndef __LIBCPROJECT_VERSION__\n";
2023-01-05 21:13:10 +01:00
content = string_concatenate(content, "#define __LIBCPROJECT_VERSION__ \"");
content = string_concatenate(content, argv[1]);
content = string_concatenate(content, "\"\n\n");
content = string_concatenate(content, "#endif\n");
int result = filesystem_write("./version.h", content, string_get_length(content));
if (result == -1) {
fprintf(stderr, "Error: Could not write to file.\n");
return EXIT_FAILURE;
}
printf("Success: Version set to %s.\n", argv[1]);
return EXIT_SUCCESS;
}