[DEV/DEBUG] correct android init bug and support multiple init

This commit is contained in:
Edouard DUPIN 2017-04-28 21:27:36 +02:00
parent 2b29067041
commit 01d6aadf13
2 changed files with 45 additions and 5 deletions

View File

@ -11,24 +11,60 @@
#include <elog/elog.hpp>
#include <etk/os/FSNode.hpp>
static int32_t nbTimeInit = 0;
void etk::unInit() {
if (nbTimeInit > 1) {
nbTimeInit--;
// not the time to uninit
return;
}
nbTimeInit--;
if (nbTimeInit < 0) {
TK_ERROR("E-TK system un-init More un-init than init ...");
nbTimeInit = 0;
return;
}
TK_INFO("E-TK system un-init (BEGIN)");
TK_INFO("E-TK system un-init (END)");
}
void etk::init(int _argc, const char** _argv) {
if (nbTimeInit > 0) {
nbTimeInit++;
// already init
return;
}
nbTimeInit++;
if (_argc >= 1) {
TK_INFO("E-TK system init (BEGIN) " << _argv[0]);
} else {
TK_INFO("E-TK system init (BEGIN) ");
}
elog::init(_argc, _argv);
TK_PRINT("plooooooooooooooooooooppppppppppppppppppppppppp");
#if !defined(__TARGET_OS__Android) and !defined(__TARGET_OS__IOs)
// This action is done by the main wrapper...
if (_argc >= 1) {
TK_PRINT("ploppppppppppppppppppppppppp");
etk::setArgZero(_argv[0]);
}
#endif
for (int32_t iii=0; iii<_argc ; ++iii) {
std::string data = _argv[iii];
if ( data == "-h"
|| data == "--help") {
TK_PRINT("etk - help : ");
if (_argc >= 1) {
TK_PRINT(" " << _argv[0] << " [options]");
}
/*
TK_PRINT(" --etk-log-lib=name:X Set a library specific level:");
TK_PRINT(" name Name of the library");
TK_PRINT(" X Log level to set [0..6]");
*/
TK_PRINT(" -h/--help: this help");
TK_PRINT(" example:");
TK_PRINT(" " << _argv[0] << " ...");
} else if (etk::start_with(data, "--etk")) {
TK_ERROR("Can not parse the argument : '" << data << "'");
}

View File

@ -16,6 +16,10 @@ namespace etk {
* @param[in] _argv List of arguments
*/
void init(int _argc, const char** _argv);
/**
* @brief Un-Initialize etk
*/
void unInit();
/**
* @brief Get application name.