mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Added in better versioning info
This commit is contained in:
		
							parent
							
								
									4df64127e9
								
							
						
					
					
						commit
						42de135c3a
					
				
					 2 changed files with 19 additions and 3 deletions
				
			
		
							
								
								
									
										18
									
								
								sway/ipc.c
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								sway/ipc.c
									
										
									
									
									
								
							| 
						 | 
					@ -225,14 +225,30 @@ void ipc_client_handle_command(struct ipc_client *client) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	case IPC_GET_VERSION:
 | 
						case IPC_GET_VERSION:
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
					#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
 | 
				
			||||||
 | 
							char *full_version = calloc(strlen(SWAY_GIT_VERSION) + strlen(SWAY_GIT_BRANCH) + strlen(SWAY_VERSION_DATE) + 20, 1);
 | 
				
			||||||
 | 
							strcat(full_version, SWAY_GIT_VERSION);
 | 
				
			||||||
 | 
							strcat(full_version, " (");
 | 
				
			||||||
 | 
							strcat(full_version, SWAY_VERSION_DATE);
 | 
				
			||||||
 | 
							strcat(full_version, ", branch \"");
 | 
				
			||||||
 | 
							strcat(full_version, SWAY_GIT_BRANCH);
 | 
				
			||||||
 | 
							strcat(full_version, "\")");
 | 
				
			||||||
		json_object *json = json_object_new_object();
 | 
							json_object *json = json_object_new_object();
 | 
				
			||||||
		json_object_object_add(json, "human_readable", json_object_new_string(SWAY_GIT_VERSION));
 | 
							json_object_object_add(json, "human_readable", json_object_new_string(full_version));
 | 
				
			||||||
 | 
							// Todo once we actually release a version
 | 
				
			||||||
		json_object_object_add(json, "major", json_object_new_int(0));
 | 
							json_object_object_add(json, "major", json_object_new_int(0));
 | 
				
			||||||
		json_object_object_add(json, "minor", json_object_new_int(0));
 | 
							json_object_object_add(json, "minor", json_object_new_int(0));
 | 
				
			||||||
		json_object_object_add(json, "patch", json_object_new_int(1));
 | 
							json_object_object_add(json, "patch", json_object_new_int(1));
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
							json_object_object_add(json, "human_readable", json_object_new_string("version not found"));
 | 
				
			||||||
 | 
							json_object_object_add(json, "major", json_object_new_int(0));
 | 
				
			||||||
 | 
							json_object_object_add(json, "minor", json_object_new_int(0));
 | 
				
			||||||
 | 
							json_object_object_add(json, "patch", json_object_new_int(0));
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		const char *json_string = json_object_to_json_string(json);
 | 
							const char *json_string = json_object_to_json_string(json);
 | 
				
			||||||
		ipc_send_reply(client, json_string, (uint32_t) strlen(json_string));
 | 
							ipc_send_reply(client, json_string, (uint32_t) strlen(json_string));
 | 
				
			||||||
		json_object_put(json); // free
 | 
							json_object_put(json); // free
 | 
				
			||||||
 | 
							free(full_version);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,8 +78,8 @@ int main(int argc, char **argv) {
 | 
				
			||||||
			debug = 1;
 | 
								debug = 1;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case 'v': // version
 | 
							case 'v': // version
 | 
				
			||||||
#ifdef SWAY_GIT_VERSION
 | 
					#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
 | 
				
			||||||
			fprintf(stdout, "sway build %s\n", SWAY_GIT_VERSION);
 | 
								fprintf(stdout, "sway version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
			fprintf(stdout, "version not detected\n");
 | 
								fprintf(stdout, "version not detected\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue