Complete generalized C template with automatic versioning system
- Generalized build.sh script that works with any C project - Dynamic project name detection from directory name - Automatic version increment with each build following AUTOMATIC_VERSIONING guide - Generic version header generation with build info and git metadata - Template Makefile for C projects - Example main.c demonstrating version API usage - Proper .gitignore for auto-generated files - Maintains compliance with workspace rules (single Makefile, build.sh usage) - Fully functional template ready for new C projects
This commit is contained in:
33
main.c
Normal file
33
main.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* C Template - Main Example File
|
||||
* This is a basic template file to demonstrate the project structure
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Include version header if it exists (will be auto-generated by build.sh)
|
||||
#ifdef __has_include
|
||||
#if __has_include("version.h")
|
||||
#include "version.h"
|
||||
#define HAS_VERSION
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int main(void) {
|
||||
printf("C Template Project\n");
|
||||
printf("==================\n\n");
|
||||
|
||||
#ifdef HAS_VERSION
|
||||
printf("Version: %s\n", get_version());
|
||||
printf("Full Version: %s\n", get_version_full());
|
||||
printf("Build Info: %s\n", get_build_info());
|
||||
#else
|
||||
printf("Version: Not available (run ./build.sh to generate version info)\n");
|
||||
#endif
|
||||
|
||||
printf("\nThis is a template C project with automatic versioning.\n");
|
||||
printf("Use ./build.sh to build the project and generate version information.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user