Pārlūkot izejas kodu

Update tools folder

Daniele Bartolini 12 gadi atpakaļ
vecāks
revīzija
543f9e0487
2 mainītis faili ar 14 papildinājumiem un 38 dzēšanām
  1. 4 6
      tools/compilers/CMakeLists.txt
  2. 10 32
      tools/compilers/resource-hash.cpp

+ 4 - 6
tools/compilers/CMakeLists.txt

@@ -20,15 +20,13 @@ target_link_libraries(resource-linker crown)
 add_executable(resource-hash resource-hash.cpp)
 target_link_libraries(resource-hash crown)
 
-add_subdirectory(txt)
-add_subdirectory(tga)
-add_subdirectory(lua)
-add_subdirectory(mat)
-add_subdirectory(vs)
-add_subdirectory(ps)
+# resource-compiler
+add_executable(resource-compiler resource-compiler.cpp)
+target_link_libraries(resource-compiler crown)
 
 install (TARGETS crown-compiler-utils DESTINATION lib/${CMAKE_PROJECT_NAME})
 
 install (TARGETS resource-linker DESTINATION bin)
 install (TARGETS resource-hash DESTINATION bin)
+install (TARGETS resource-compiler DESTINATION bin)
 install (FILES resource-compiler.py DESTINATION bin)

+ 10 - 32
tools/compilers/resource-hash.cpp

@@ -67,50 +67,28 @@ void parse_command_line(int argc, char** argv)
 
 	Args args(argc, argv, "", options);
 
-	while (1)
-	{
-		int32_t ret = args.next_option();
-		
-		switch (ret)
+	int32_t opt;
+	while ((opt = args.getopt()) != -1)
+	{		
+		switch (opt)
 		{
-			case -1:
-			{
-				return;
-			}
-			// Help message
-			case 'h':
-			{
-				print_help_message(argv[0]);
-				exit(0);
-			}
 			// Resource in
 			case 'i':
 			{
-				if (args.option_argument() == NULL)
-				{
-					printf("%s: ERROR: missing path after `--resource-in`\n", argv[0]);
-					exit(-1);
-				}
-				
-				resource_in = args.option_argument();
-				
+				resource_in = args.optarg();
 				break;
 			}
 			case 's':
 			{
-				if (args.option_argument() == NULL)
-				{
-					printf("%s: ERROR: missing seed value after `--seed`\n", argv[0]);
-					exit(-1);
-				}
-
-				hash_seed = atoi(args.option_argument());
-
+				hash_seed = atoi(args.optarg());
 				break;
 			}
+			case 'h':
+			case '?':
 			default:
 			{
-				break;
+				print_help_message(argv[0]);
+				exit(-1);
 			}
 		}
 	}