kraken_convert now supports reading list of assets from a file.
This commit is contained in:
@@ -233,12 +233,19 @@ ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
|
|||||||
|
|
||||||
add_subdirectory(standard_assets)
|
add_subdirectory(standard_assets)
|
||||||
|
|
||||||
|
SET(STANDARD_ASSET_LIST_FILE "${CMAKE_BINARY_DIR}/standard_assets_list")
|
||||||
SET(STANDARD_ASSET_BUNDLE "${CMAKE_BINARY_DIR}/output/assets/standard_assets.krbundle")
|
SET(STANDARD_ASSET_BUNDLE "${CMAKE_BINARY_DIR}/output/assets/standard_assets.krbundle")
|
||||||
|
|
||||||
|
SET(STANDARD_ASSET_LIST_FILE_CONTENTS "")
|
||||||
|
FOREACH(line ${KRAKEN_STANDARD_ASSETS})
|
||||||
|
SET(STANDARD_ASSET_LIST_FILE_CONTENTS "${STANDARD_ASSET_LIST_FILE_CONTENTS}${line}\n")
|
||||||
|
ENDFOREACH(line)
|
||||||
|
FILE(WRITE ${STANDARD_ASSET_LIST_FILE} ${STANDARD_ASSET_LIST_FILE_CONTENTS})
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${STANDARD_ASSET_BUNDLE}
|
OUTPUT ${STANDARD_ASSET_BUNDLE}
|
||||||
COMMAND kraken_convert -c -o ${STANDARD_ASSET_BUNDLE} ${KRAKEN_STANDARD_ASSETS}
|
COMMAND kraken_convert -c -i ${STANDARD_ASSET_LIST_FILE} -o ${STANDARD_ASSET_BUNDLE}
|
||||||
DEPENDS kraken_convert ${KRAKEN_STANDARD_ASSETS}
|
DEPENDS kraken_convert ${KRAKEN_STANDARD_ASSETS} ${STANDARD_ASSET_LIST_FILE}
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
COMMENT "Creating Standard Assets"
|
COMMENT "Creating Standard Assets"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
#include "kraken.h"
|
#include "kraken.h"
|
||||||
|
|
||||||
using namespace kraken;
|
using namespace kraken;
|
||||||
@@ -16,10 +20,6 @@ int main( int argc, char *argv[] )
|
|||||||
bool failed = false;
|
bool failed = false;
|
||||||
printf("Kraken Convert\n");
|
printf("Kraken Convert\n");
|
||||||
printf("Initializing Kraken...\n");
|
printf("Initializing Kraken...\n");
|
||||||
printf("%i arguments:\n", argc);
|
|
||||||
for (int i = 0; i < argc; i++) {
|
|
||||||
printf("argv[%i]: %s\n", i, argv[i]);
|
|
||||||
}
|
|
||||||
KrInitializeInfo init_info = {};
|
KrInitializeInfo init_info = {};
|
||||||
init_info.sType = KR_STRUCTURE_TYPE_INITIALIZE;
|
init_info.sType = KR_STRUCTURE_TYPE_INITIALIZE;
|
||||||
init_info.resourceMapSize = 1024;
|
init_info.resourceMapSize = 1024;
|
||||||
@@ -50,6 +50,9 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
char* output_bundle = nullptr;
|
char* output_bundle = nullptr;
|
||||||
bool compile_shaders = false;
|
bool compile_shaders = false;
|
||||||
|
char* input_list_file = nullptr;
|
||||||
|
|
||||||
|
std::vector<std::string> input_files;
|
||||||
|
|
||||||
char command = '\0';
|
char command = '\0';
|
||||||
for (int i = 1; i < argc && !failed; i++) {
|
for (int i = 1; i < argc && !failed; i++) {
|
||||||
@@ -79,6 +82,7 @@ int main( int argc, char *argv[] )
|
|||||||
compile_shaders = true;
|
compile_shaders = true;
|
||||||
command = '\0';
|
command = '\0';
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
case 'o':
|
case 'o':
|
||||||
// Next arg will be the output path
|
// Next arg will be the output path
|
||||||
break;
|
break;
|
||||||
@@ -92,14 +96,41 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
// Process commands that receive arguments
|
// Process commands that receive arguments
|
||||||
switch (command) {
|
switch (command) {
|
||||||
|
case 'i':
|
||||||
|
input_list_file = arg;
|
||||||
|
command = '\0';
|
||||||
|
continue;
|
||||||
case 'o':
|
case 'o':
|
||||||
output_bundle = arg;
|
output_bundle = arg;
|
||||||
command = '\0';
|
command = '\0';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
load_resource_info.pResourcePath = arg;
|
input_files.push_back(arg);
|
||||||
printf("loading %s... ", arg);
|
}
|
||||||
|
|
||||||
|
if (input_list_file != nullptr) {
|
||||||
|
printf("Reading %s... ", input_list_file);
|
||||||
|
std::ifstream in(input_list_file);
|
||||||
|
if (!in) {
|
||||||
|
printf("[FAIL]\n");
|
||||||
|
failed = true;
|
||||||
|
} else {
|
||||||
|
for (std::string line; std::getline(in, line); ) {
|
||||||
|
const std::string ws = "\t ";
|
||||||
|
line.erase(0, line.find_first_not_of(ws));
|
||||||
|
line.erase(line.find_last_not_of(ws) + 1);
|
||||||
|
if (!line.empty()) {
|
||||||
|
input_files.push_back(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("[GOOD]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const std::string& file_name : input_files) {
|
||||||
|
load_resource_info.pResourcePath = file_name.c_str();
|
||||||
|
printf("loading %s... ", load_resource_info.pResourcePath);
|
||||||
res = KrLoadResource(&load_resource_info);
|
res = KrLoadResource(&load_resource_info);
|
||||||
if (res != KR_SUCCESS) {
|
if (res != KR_SUCCESS) {
|
||||||
printf("[FAIL] (KrLoadResource)\n");
|
printf("[FAIL] (KrLoadResource)\n");
|
||||||
@@ -147,10 +178,5 @@ int main( int argc, char *argv[] )
|
|||||||
}
|
}
|
||||||
|
|
||||||
KrShutdown();
|
KrShutdown();
|
||||||
printf("--- after shutdown ----\n");
|
|
||||||
printf("%i arguments:\n", argc);
|
|
||||||
for (int i = 0; i < argc; i++) {
|
|
||||||
printf("argv[%i]: %s\n", i, argv[i]);
|
|
||||||
}
|
|
||||||
return failed ? 1 : 0;
|
return failed ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user