Browse Source

Fix a logic error part ofr issue #12

Panagiotis Christopoulos Charitos 8 years ago
parent
commit
40fdaf2c6d
3 changed files with 26 additions and 16 deletions
  1. 18 14
      CMakeLists.txt
  2. 7 1
      src/anki/core/App.cpp
  3. 1 1
      src/anki/util/File.cpp

+ 18 - 14
CMakeLists.txt

@@ -133,6 +133,10 @@ elseif(MINGW AND ARCH_32)
 	add_definitions(-D_MINGW_32_VER)
 endif()
 
+if(MINGW)
+	set(COMPILER_FLAGS "${COMPILER_FLAGS} -mconsole ")
+endif()
+
 add_definitions(-DGLEW_NO_GLU)
 add_definitions(-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
 add_definitions(-DANKI_BUILD)
@@ -229,8 +233,8 @@ if(SDL)
 	add_subdirectory(thirdparty/SDL2)
 	message("++ End configuring SDL2")
 
-	# Include first the build directory. 
-	set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/SDL2/include" 
+	# Include first the build directory.
+	set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/SDL2/include"
 		"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/SDL2/include")
 else()
 	set(SDL2_INCLUDE_DIRS "")
@@ -279,7 +283,7 @@ find_package(Doxygen)
 if(DOXYGEN_FOUND)
 	message("++ Doxygen found")
 
-	add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxyfile 
+	add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxyfile
 		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 		COMMENT "Generating API documentation with Doxygen" VERBATIM)
 endif()
@@ -324,21 +328,21 @@ configure_file("src/anki/Config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/anki/Confi
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/anki/Config.h" DESTINATION "${INCLUDE_INSTALL_DIR}/anki")
 
 # Include & lib directories
-include_directories("src" 
-	"thirdparty/tinyxml2/include" 
-	"thirdparty/lua" 
-	"thirdparty/z" 
+include_directories("src"
+	"thirdparty/tinyxml2/include"
+	"thirdparty/lua"
+	"thirdparty/z"
 	"${SDL2_INCLUDE_DIRS}"
-	"thirdparty/freetype/include" 
+	"thirdparty/freetype/include"
 	"${CMAKE_CURRENT_BINARY_DIR}/thirdparty/freetype/include/freetype2"
-	"thirdparty/newton/coreLibrary_300/source/newton" 
+	"thirdparty/newton/coreLibrary_300/source/newton"
 	"thirdparty/newton/packages/dCustomJoints"
-	"thirdparty/newton/packages/dContainers" 
-	"thirdparty/newton/packages/dMath" 
+	"thirdparty/newton/packages/dContainers"
+	"thirdparty/newton/packages/dMath"
 	"thirdparty/newton/packages/thirdParty/timeTracker/"
-	"thirdparty/khronos" 
-	"${CMAKE_CURRENT_BINARY_DIR}" 
-	"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glslang" 
+	"thirdparty/khronos"
+	"${CMAKE_CURRENT_BINARY_DIR}"
+	"${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glslang"
 	"thirdparty")
 
 if(LINUX OR MACOS OR WINDOWS)

+ 7 - 1
src/anki/core/App.cpp

@@ -332,12 +332,18 @@ Error App::initDirs(const ConfigSet& cfg)
 	// Cache
 	m_cacheDir.sprintf(m_heapAlloc, "%s/cache", &m_settingsDir[0]);
 
-	if(cfg.getNumber("clearCaches") && directoryExists(m_cacheDir.toCString()))
+	const Bool cacheDirExists = directoryExists(m_cacheDir.toCString());
+	if(cfg.getNumber("clearCaches") && cacheDirExists)
 	{
 		ANKI_CORE_LOGI("Will delete the cache dir and start fresh: %s", &m_cacheDir[0]);
 		ANKI_CHECK(removeDirectory(m_cacheDir.toCString()));
 		ANKI_CHECK(createDirectory(m_cacheDir.toCString()));
 	}
+	else if(!cacheDirExists)
+	{
+		ANKI_CORE_LOGI("Will create cache dir: %s", &m_cacheDir[0]);
+		ANKI_CHECK(createDirectory(m_cacheDir.toCString()));
+	}
 
 #else
 	// ANKI_ASSERT(gAndroidApp);

+ 1 - 1
src/anki/util/File.cpp

@@ -130,7 +130,7 @@ Error File::openCFile(const CString& filename, FileOpenFlag flags)
 	m_file = fopen(filename.get(), openMode);
 	if(m_file == nullptr)
 	{
-		ANKI_UTIL_LOGE("Failed to open file %s", &filename[0]);
+		ANKI_UTIL_LOGE("Failed to open file \"%s\", open mode \"%s\"", &filename[0], openMode);
 		err = ErrorCode::FILE_ACCESS;
 	}
 	else