ソースを参照

script-compiler renamed to lua-compiler

mikymod 13 年 前
コミット
5dd90de39b
2 ファイル変更8 行追加11 行削除
  1. 2 2
      tools/CMakeLists.txt
  2. 6 9
      tools/resource-compilers/lua-compiler.cpp

+ 2 - 2
tools/CMakeLists.txt

@@ -17,7 +17,7 @@ add_executable(resource-hash resource-compilers/resource-hash.cpp)
 
 add_executable(txt-compiler resource-compilers/txt-compiler.cpp)
 add_executable(tga-compiler resource-compilers/tga-compiler.cpp)
-add_executable(script-compiler resource-compilers/script-compiler.cpp)
+add_executable(lua-compiler resource-compilers/lua-compiler.cpp)
 
 add_executable(resource-linker resource-compilers/resource-linker.cpp)
 
@@ -27,7 +27,7 @@ target_link_libraries(resource-hash crown)
 
 target_link_libraries(txt-compiler crown)
 target_link_libraries(tga-compiler crown)
-target_link_libraries(script-compiler crown)
+target_link_libraries(lua-compiler crown)
 
 target_link_libraries(resource-linker crown)
 

+ 6 - 9
tools/resource-compilers/script-compiler.cpp → tools/resource-compilers/lua-compiler.cpp

@@ -8,12 +8,11 @@
 
 using namespace crown;
 
-const char* command = NULL;
-const char* option = NULL;
 const char* root_path = NULL;
 const char* resource_in = NULL;
 const char* resource_out = NULL;
 
+
 void 	parse_command_line(int argc, char** argv);
 void 	print_help_message(const char* program_name);
 void	compile_script(char* tmp_out);
@@ -67,8 +66,11 @@ int main(int argc, char** argv)
 	dest_file->write(&src_file_size, sizeof(uint32_t));
 	dest_file->write(buffer, src_file_size);
 
+	fs_root.delete_file(tmp_file);
 	fs_root.close(dest_file);	
 
+	printf("Resource compilation completed: %s\n", resource_out);
+
 	return 0;
 }
 
@@ -162,11 +164,6 @@ void print_help_message(const char* program_name)
 
 void compile_script(char* tmp_out)
 {
-	char* command = "luajit";
-	char* option = "-bl";
-
-	size_t in_len = strlen(root_path) + strlen(resource_in);
-
 	char in[256];
 	strcpy(in, root_path);
 	strcat(in, resource_in);
@@ -181,7 +178,7 @@ void compile_script(char* tmp_out)
 
 	strcpy(tmp_out, rel_out);
 
-	// Fork for exec
+	// Fork for execl
 	pid_t child = 0;
 
 	child = fork();
@@ -198,6 +195,6 @@ void compile_script(char* tmp_out)
 	}
 	else
 	{
-		execl("/usr/local/bin/luajit", command, option, in, out, NULL);
+		execl("/usr/local/bin/luajit", "luajit", "-bl", in, out, NULL);
 	}
 }