diff --git a/.gitignore b/.gitignore index 715dc43..244d2ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ Modules/* test/CMakeFiles/* +test/res.cpp cmake_install.cmake Makefile CMakeCache.txt diff --git a/resource.cmake b/resource.cmake index 1d3dfc0..db4566e 100644 --- a/resource.cmake +++ b/resource.cmake @@ -16,7 +16,7 @@ add_executable(SparrowResource ${CMAKE_TEMPLATE_PATH}/resource/main.cpp) add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DST_FILE} COMMAND SparrowResource - ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DST_FILE} ${RES_SRC_FILE} + ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DST_FILE} ${PROJECT_SOURCE_DIR} ${RES_SRC_FILE} DEPENDS ${RES_SRC_FILE} COMMENT "Generating resource file" ) diff --git a/resource/CMakeLists.txt b/resource/CMakeLists.txt deleted file mode 100644 index 4754a52..0000000 --- a/resource/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -project(SparrowResource) -cmake_minimum_required(VERSION 2.8) - -set(CMAKE_TEMPLATE_PATH "..") - -# choose source file -set(EXEC_SRC_LIST main.cpp) - -include(${CMAKE_TEMPLATE_PATH}/template.cmake) - diff --git a/resource/main.cpp b/resource/main.cpp index ad12c2e..db81823 100644 --- a/resource/main.cpp +++ b/resource/main.cpp @@ -6,16 +6,11 @@ using namespace std; #define NB_VAL_PER_LINE 256 - #define FILE_BEGIN "#include \n\ #include \n\ \n\ namespace Resource {\n\ typedef std::unordered_map ResourceMap;\n" - - -#define FILE_MID "" - #define FILE_END "\n\ }\n\ @@ -42,7 +37,7 @@ bool addFile(const string &inFile, FILE *out) fprintf(out, "\n"); } while(nbRead == NB_VAL_PER_LINE); - fprintf(out, "};\n"); + fprintf(out, ", 0x00}; // additionnal byte used to null-terminate ascii data\n"); ++n; fclose(in); return true; @@ -50,9 +45,13 @@ bool addFile(const string &inFile, FILE *out) int main(int argc, char *argv[]) { - if(argc < 3) + if(argc < 4) { - printf("usage : %s RESOURCE_PACK_NAME [LIST_OF_FILES_TO_BAKE]\n", argv[0]); + printf("usage : %s RESOURCE_PACK_FILE_TO_CREATE RESOURCE_PACK_ROOT [LIST_OF_FILES_TO_BAKE]\n\n", argv[0]); + printf("RESOURCE_PACK_FILE_TO_CREATE is the c++ source file that will be created,\n"); + printf("the resource pack will be named from the file name\n"); + printf("example, if the filename provided is : /directory/sources/myResourcePack.cpp , the resource pack will be named myResourcePack\n\n"); + printf("RESOURCE_PACK_ROOT is the root directory or the resources, they will be accessible from their relative path to this directory\n"); return EXIT_SUCCESS; } @@ -72,19 +71,28 @@ int main(int argc, char *argv[]) } fprintf(out, FILE_BEGIN); - for(int i=2; i offsets; + for(int i=3; i " << it.second << endl; } diff --git a/test/test.exe b/test/test.exe deleted file mode 100644 index 1dcf15a..0000000 Binary files a/test/test.exe and /dev/null differ diff --git a/test/plop2.txt b/test/test.txt similarity index 100% rename from test/plop2.txt rename to test/test.txt