2023-01-05 21:13:10 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "libcproject.h"
|
|
|
|
|
2023-08-10 00:32:49 +02:00
|
|
|
int main(int argc, string_t* argv) {
|
2023-01-05 21:13:10 +01:00
|
|
|
if (argc != 2) {
|
|
|
|
fprintf(stderr, "Usage: %s <version>\n", argv[0]);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2023-08-07 00:42:11 +02:00
|
|
|
string_t content = string_copy("#ifndef __LIBCPROJECT_VERSION__\n");
|
|
|
|
string_concatenate(&content, "#define __LIBCPROJECT_VERSION__ \"");
|
|
|
|
string_concatenate(&content, argv[1]);
|
|
|
|
string_concatenate(&content, "\"\n\n");
|
|
|
|
string_concatenate(&content, "#endif\n");
|
2023-06-25 21:35:24 +02:00
|
|
|
int result = filesystem_write("./version.h", (byte_t*)content, string_get_length(content));
|
2023-01-05 21:13:10 +01:00
|
|
|
if (result == -1) {
|
|
|
|
fprintf(stderr, "Error: Could not write to file.\n");
|
2023-08-09 21:08:15 +02:00
|
|
|
perror("Error (set_version)");
|
2023-01-05 21:13:10 +01:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
printf("Success: Version set to %s.\n", argv[1]);
|
2023-08-03 23:55:14 +02:00
|
|
|
free(content);
|
2023-01-05 21:13:10 +01:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|