From 90860f9711093a0534a02325a93f86a142843b22 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 21 Oct 2018 16:34:53 -0700 Subject: [PATCH 01/23] Update libretro-common --- vendor/libretro-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/libretro-common b/vendor/libretro-common index 29905d94e..79c6979d3 160000 --- a/vendor/libretro-common +++ b/vendor/libretro-common @@ -1 +1 @@ -Subproject commit 29905d94e39090dbde5f9e6d726eb2510618704a +Subproject commit 79c6979d34298bcb3d67ad64d937c9140d54df9f From 48795e610d21409a15630e84b4ef7f72ab4751bf Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 21 Oct 2018 23:42:33 -0700 Subject: [PATCH 02/23] Update dependencies --- vendor/ChaiScript_Extras | 2 +- vendor/chaiscript | 2 +- vendor/cppcodec | 2 +- vendor/didstopia-physfs | 2 +- vendor/random | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vendor/ChaiScript_Extras b/vendor/ChaiScript_Extras index 7043c1210..f1adc0fa4 160000 --- a/vendor/ChaiScript_Extras +++ b/vendor/ChaiScript_Extras @@ -1 +1 @@ -Subproject commit 7043c12105f20baec7655e62563796ca43535557 +Subproject commit f1adc0fa4528ff762a1eea3116977228d16cf0da diff --git a/vendor/chaiscript b/vendor/chaiscript index ac0d7ce94..8d0fc7434 160000 --- a/vendor/chaiscript +++ b/vendor/chaiscript @@ -1 +1 @@ -Subproject commit ac0d7ce94925f8eac367533b276d9d7db13a77ae +Subproject commit 8d0fc743418385451146bed97c75b27a8e38acdb diff --git a/vendor/cppcodec b/vendor/cppcodec index 302dc28f8..82d011756 160000 --- a/vendor/cppcodec +++ b/vendor/cppcodec @@ -1 +1 @@ -Subproject commit 302dc28f8fd5c8bf2ea8d7212aed3be884d5d166 +Subproject commit 82d011756adfece7506728b4fa9e7354cbe58641 diff --git a/vendor/didstopia-physfs b/vendor/didstopia-physfs index fe12df085..3ae84ee5d 160000 --- a/vendor/didstopia-physfs +++ b/vendor/didstopia-physfs @@ -1 +1 @@ -Subproject commit fe12df08508044287aba2317e13cd91596af5af1 +Subproject commit 3ae84ee5d0a0af72a6a808a32b63e1ea0076f2be diff --git a/vendor/random b/vendor/random index 2cdf5dc1b..985de84de 160000 --- a/vendor/random +++ b/vendor/random @@ -1 +1 @@ -Subproject commit 2cdf5dc1b22a390f1a09008a98c56a7604d27597 +Subproject commit 985de84de4ec891ce060c4c6579cf70d3c1c86e2 From 6f352593e5dbab69d48141b9c340cbac2cf28a27 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 21 Oct 2018 23:49:52 -0700 Subject: [PATCH 03/23] Revert ChaiScript update --- vendor/chaiscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/chaiscript b/vendor/chaiscript index 8d0fc7434..ac0d7ce94 160000 --- a/vendor/chaiscript +++ b/vendor/chaiscript @@ -1 +1 @@ -Subproject commit 8d0fc743418385451146bed97c75b27a8e38acdb +Subproject commit ac0d7ce94925f8eac367533b276d9d7db13a77ae From 6cd44e68240283e4c168882f105bbab747326fc0 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 29 Oct 2018 03:09:36 -0400 Subject: [PATCH 04/23] Move String Methods to ChaiScript_Extras --- CHANGELOG.md | 4 ++++ src/love/script.cpp | 50 +++------------------------------------- vendor/ChaiScript_Extras | 2 +- 3 files changed, 8 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c1f4f741..8caf0ad97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 0.29.1 - Unreleased +### Chores +- Moved String Methods to [ChaiScript_Extras](https://github.com/ChaiScript/ChaiScript_Extras) + ## 0.29.0 - 2018-10-13 ### Fixes - Fixed `/libretro/saves` mounting diff --git a/src/love/script.cpp b/src/love/script.cpp index 9576853a5..d503dc9f2 100644 --- a/src/love/script.cpp +++ b/src/love/script.cpp @@ -5,6 +5,7 @@ #ifdef __HAVE_CHAISCRIPT__ #include "chaiscript/extras/math.hpp" +#include "chaiscript/extras/string_methods.hpp" using namespace chaiscript; #endif @@ -92,53 +93,8 @@ script::script(const std::string& file) { chai.add(bootstrap::standard_library::vector_type>("StringVector")); chai.add(bootstrap::standard_library::map_type>("StringBoolMap")); - // Global Helpers - // string::replace(std::string search, std::string replace) - chai.add(fun([](const std::string& subject, const std::string& search, const std::string& replace) { - std::string newSubject(subject); - size_t pos = 0; - while ((pos = newSubject.find(search, pos)) != std::string::npos) { - newSubject.replace(pos, search.length(), replace); - pos += replace.length(); - } - return newSubject; - }), "replace"); - - // string::replace(char search, char replace) - chai.add(fun([](const std::string& subject, char search, char replace) { - std::string newSubject(subject); - std::replace(newSubject.begin(), newSubject.end(), search, replace); - return newSubject; - }), "replace"); - - // string::trim() - chai.add(fun([](const std::string& subject) { - std::string result(subject); - std::string chars = "\t\n\v\f\r "; - result.erase(0, result.find_first_not_of(chars)); - result.erase(0, result.find_last_not_of(chars)); - return result; - }), "trim"); - - // string::split() - chai.add(fun([](const std::string& subject, const std::string& token) { - std::string str(subject); - std::vector result; - while (str.size()) { - int index = str.find(token); - if (index != std::string::npos) { - result.push_back(str.substr(0, index)); - str = str.substr(index + token.size()); - if (str.size() == 0) { - result.push_back(str); - } - } else { - result.push_back(str); - str = ""; - } - } - return result; - }), "split"); + auto stringmethods = chaiscript::extras::string_methods::bootstrap(); + chai.add(stringmethods); // List auto listModule = std::make_shared(); diff --git a/vendor/ChaiScript_Extras b/vendor/ChaiScript_Extras index f1adc0fa4..76d21cd8a 160000 --- a/vendor/ChaiScript_Extras +++ b/vendor/ChaiScript_Extras @@ -1 +1 @@ -Subproject commit f1adc0fa4528ff762a1eea3116977228d16cf0da +Subproject commit 76d21cd8acb08e945f0c305ad55334e289fd68a9 From 5b769652ce11839959493aa5647461104178b2f6 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 3 Nov 2018 18:09:54 -0400 Subject: [PATCH 05/23] Update libnx definitions --- Makefile.libretro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index c17a2a0a9..95600bc2a 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -286,7 +286,8 @@ else ifeq ($(platform), libnx) -fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs CFLAGS += $(INCDIRS) CFLAGS += $(INCLUDE) -D__SWITCH__ -DHAVE_LIBNX - CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 + # Replaced -fno-rtti -fno-exceptions with -fexceptions, using C++14 + CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fexceptions -std=c++14 CFLAGS += -std=gnu11 PLATFORM_DEFINES += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft STATIC_LINKING = 1 From e13d137cfcd527c9711427d83a36e611c87a3da5 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 3 Nov 2018 18:54:15 -0400 Subject: [PATCH 06/23] Replace filesystem/path.h --- .gitignore | 1 + Makefile.common | 5 +--- Makefile.libretro | 1 + src/love/Types/FileSystem/FileData.cpp | 6 ++-- src/love/filesystem.cpp | 39 +++++++++++++++++++++----- src/love/filesystem.h | 4 +++ src/love/script.cpp | 10 +++---- 7 files changed, 46 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index a32a01e07..d356db5fa 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ node_modules /package.json /.bsv /*.mkv +*.d diff --git a/Makefile.common b/Makefile.common index 0be81b20a..1b196a792 100644 --- a/Makefile.common +++ b/Makefile.common @@ -17,9 +17,6 @@ SOURCES_C := $(CORE_DIR)/vendor/semver/semver.c # random FLAGS += -I$(CORE_DIR)/vendor/random/include -# filesystem -FLAGS += -I$(CORE_DIR)/vendor/filesystem - # libretro-common FLAGS += -I$(CORE_DIR)/vendor/libretro-common/include # Only compile libretro-common when not STATIC_LINKING @@ -49,7 +46,7 @@ ifneq ($(STATIC_LINKING), 1) ) # Ensure the sinc_resampler_neon is available for ARM NEON devices. OBJECTS += $(CORE_DIR)/vendor/libretro-common/audio/resampler/drivers/sinc_resampler_neon.o - + # MD5 FLAGS += -I$(CORE_DIR)/vendor/libretro-common/include SOURCES_C += $(CORE_DIR)/vendor/libretro-common/utils/md5.c diff --git a/Makefile.libretro b/Makefile.libretro index 95600bc2a..207e62263 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -13,6 +13,7 @@ filter_out1 = $(filter-out $(firstword $1),$1) filter_out2 = $(call filter_out1,$(call filter_out1,$1)) unixpath = $(subst \,/,$1) unixcygpath = /$(subst :,,$(call unixpath,$1)) +export DEPSDIR := $(CURDIR)/ ifeq ($(platform),) platform = unix diff --git a/src/love/Types/FileSystem/FileData.cpp b/src/love/Types/FileSystem/FileData.cpp index 3a57264f8..2821bbd5b 100644 --- a/src/love/Types/FileSystem/FileData.cpp +++ b/src/love/Types/FileSystem/FileData.cpp @@ -4,7 +4,6 @@ #include #include -#include "filesystem/path.h" #include "../../../ChaiLove.h" @@ -38,9 +37,8 @@ std::string FileData::getString() { } std::string FileData::getExtension() { - ::filesystem::path p(m_filepath.c_str()); - std::string extension(p.extension()); - return extension; + ChaiLove* app = ChaiLove::getInstance(); + return app->filesystem.getExtension(m_filepath); } } // namespace FileSystem diff --git a/src/love/filesystem.cpp b/src/love/filesystem.cpp index 02e5df83b..16b9f2352 100644 --- a/src/love/filesystem.cpp +++ b/src/love/filesystem.cpp @@ -5,7 +5,6 @@ #include "physfs.h" #include "filesystem.h" #include "physfsrwops.h" -#include "filesystem/path.h" #include "../ChaiLove.h" #include "Types/FileSystem/FileInfo.h" @@ -32,8 +31,7 @@ bool filesystem::init(const std::string& file, const void* data) { } // Find the parent and extension of the given file. - ::filesystem::path p(file.c_str()); - std::string extension(p.extension()); + std::string extension(getFileExtension(file)); // Allow loading from an Archive. if (extension == "chaigame" || extension == "chailove" || extension == "zip") { @@ -41,8 +39,7 @@ bool filesystem::init(const std::string& file, const void* data) { } // If we are just running the core, load the base path. - ::filesystem::path parent(p.parent_path()); - std::string parentPath(parent.str()); + std::string parentPath(getParentDirectory(file)); if (parentPath.empty()) { return mount(".", "/", false); } @@ -51,6 +48,34 @@ bool filesystem::init(const std::string& file, const void* data) { return mount(parentPath.c_str(), "/", false); } +std::string filesystem::getParentDirectory(const std::string& filepath) { + return filepath.substr(0, filepath.find_last_of("/\\")); +} + +std::string filesystem::getFileExtension(const std::string& filepath) { + size_t i = filepath.rfind('.', filepath.length()); + if (i != std::string::npos) { + return filepath.substr(i + 1, filepath.length() - i); + } + return ""; +} + +std::string filesystem::getBasename(const std::string& filepath) { + char sep = '/'; + #ifdef _WIN32 + if (filepath.find('\\') != std::string::npos) { + sep = '\\'; + } + #endif + + size_t i = filepath.rfind(sep, filepath.length()); + if (i != std::string::npos) { + return filepath.substr(i + 1, filepath.length() - i); + } + + return ""; +} + void filesystem::mountlibretro() { // Mount some of the libretro directories. const char *system_dir = NULL; @@ -60,8 +85,8 @@ void filesystem::mountlibretro() { if (ChaiLove::environ_cb(RETRO_ENVIRONMENT_GET_LIBRETRO_PATH, &core_dir) && core_dir) { // Make sure to get the directory of the core. - ::filesystem::path p(core_dir); - mount(p.parent_path().str(), "/libretro/core", false); + std::string parentPath(getParentDirectory(core_dir)); + mount(parentPath, "/libretro/core", false); } if (ChaiLove::environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_dir) && system_dir) { mount(system_dir, "/libretro/system", false); diff --git a/src/love/filesystem.h b/src/love/filesystem.h index a848dccde..1018e299c 100644 --- a/src/love/filesystem.h +++ b/src/love/filesystem.h @@ -78,6 +78,10 @@ class filesystem { */ int getSize(const std::string& file); + std::string getFileExtension(const std::string& filepath); + std::string getBasename(const std::string& filepath); + std::string getParentDirectory(const std::string& filepath); + /** * Removes a file or empty directory. * diff --git a/src/love/script.cpp b/src/love/script.cpp index d503dc9f2..2bc6a12fa 100644 --- a/src/love/script.cpp +++ b/src/love/script.cpp @@ -1,6 +1,5 @@ #include "script.h" #include "../ChaiLove.h" -#include #include #ifdef __HAVE_CHAISCRIPT__ @@ -86,6 +85,7 @@ std::string script::evalString(const std::string& code, const std::string& filen script::script(const std::string& file) { #ifdef __HAVE_CHAISCRIPT__ + ChaiLove* app = ChaiLove::getInstance(); // ChaiScript Standard Library Additions // This adds some basic type definitions to ChaiScript. @@ -388,18 +388,18 @@ script::script(const std::string& file) { // Load the desired main.chai file. if (file.empty()) { // When no content is provided, display a No Game demo. - eval(ChaiLove::getInstance()->demo(), "demo.chai"); + eval(app->demo(), "demo.chai"); mainLoaded = true; } else { // Load the main.chai file. - ::filesystem::path p(file.c_str()); - std::string extension(p.extension()); loadModuleRequire("conf"); + + std::string extension(app->filesystem.getExtension(file)); if (extension == "chailove" || extension == "chaigame") { mainLoaded = loadModuleRequire("main"); } else { // Otherwise, load the actual file. - std::string filename(p.filename()); + std::string filename(app->filesystem.getBasename(file)); mainLoaded = loadModuleRequire(filename); } } From 5c5a12e93690d37080d6b6b1e86a795e8d7e3676 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 3 Nov 2018 19:06:18 -0400 Subject: [PATCH 07/23] Fix filesystem extesion call --- src/love/Types/FileSystem/FileData.cpp | 2 +- src/love/script.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/love/Types/FileSystem/FileData.cpp b/src/love/Types/FileSystem/FileData.cpp index 2821bbd5b..77c354f07 100644 --- a/src/love/Types/FileSystem/FileData.cpp +++ b/src/love/Types/FileSystem/FileData.cpp @@ -38,7 +38,7 @@ std::string FileData::getString() { std::string FileData::getExtension() { ChaiLove* app = ChaiLove::getInstance(); - return app->filesystem.getExtension(m_filepath); + return app->filesystem.getFileExtension(m_filepath); } } // namespace FileSystem diff --git a/src/love/script.cpp b/src/love/script.cpp index 2bc6a12fa..7126948bb 100644 --- a/src/love/script.cpp +++ b/src/love/script.cpp @@ -394,7 +394,7 @@ script::script(const std::string& file) { // Load the main.chai file. loadModuleRequire("conf"); - std::string extension(app->filesystem.getExtension(file)); + std::string extension(app->filesystem.getFileExtension(file)); if (extension == "chailove" || extension == "chaigame") { mainLoaded = loadModuleRequire("main"); } else { From 1c1024296055f2fa90e7f60d2b3e42dcd82e82a9 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 3 Nov 2018 19:36:02 -0400 Subject: [PATCH 08/23] Skip some math functions --- Makefile.common | 1 + Makefile.libretro | 1 + vendor/ChaiScript_Extras | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.common b/Makefile.common index 1b196a792..1be6db8a7 100644 --- a/Makefile.common +++ b/Makefile.common @@ -187,6 +187,7 @@ ifeq ($(HAVE_CHAISCRIPT),) FLAGS += -I$(CORE_DIR)/vendor/ChaiScript_Extras/include FLAGS += -D__HAVE_CHAISCRIPT__ FLAGS += -DCHAISCRIPT_NO_THREADS -DCHAISCRIPT_NO_THREADS_WARNING -DCHAISCRIPT_NO_DYNLOAD + FLAGS += -DCHAISCRIPT_EXTRAS_MATH_SKIP_ADVANCED endif # SDL diff --git a/Makefile.libretro b/Makefile.libretro index 207e62263..9137f4ea7 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -292,6 +292,7 @@ else ifeq ($(platform), libnx) CFLAGS += -std=gnu11 PLATFORM_DEFINES += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft STATIC_LINKING = 1 + PLATFORM_DEFINES += -D_INCL_PHYSFS_PLATFORMS -DPHYSFS_PLATFORM_UNIX=1 # ARM else ifneq (,$(findstring armv,$(platform))) diff --git a/vendor/ChaiScript_Extras b/vendor/ChaiScript_Extras index 76d21cd8a..6d77ff380 160000 --- a/vendor/ChaiScript_Extras +++ b/vendor/ChaiScript_Extras @@ -1 +1 @@ -Subproject commit 76d21cd8acb08e945f0c305ad55334e289fd68a9 +Subproject commit 6d77ff3808b128c55190db1c8bea4098c63c3297 From d2014ad65931c46a49698d83b0c8b98e403b5e6f Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 3 Nov 2018 19:45:17 -0400 Subject: [PATCH 09/23] Fix whitespace --- src/love/filesystem.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/love/filesystem.cpp b/src/love/filesystem.cpp index 16b9f2352..d674498e2 100644 --- a/src/love/filesystem.cpp +++ b/src/love/filesystem.cpp @@ -53,11 +53,11 @@ std::string filesystem::getParentDirectory(const std::string& filepath) { } std::string filesystem::getFileExtension(const std::string& filepath) { - size_t i = filepath.rfind('.', filepath.length()); - if (i != std::string::npos) { - return filepath.substr(i + 1, filepath.length() - i); - } - return ""; + size_t i = filepath.rfind('.', filepath.length()); + if (i != std::string::npos) { + return filepath.substr(i + 1, filepath.length() - i); + } + return ""; } std::string filesystem::getBasename(const std::string& filepath) { From 8884c0332de6db2f9a96a5973b4c272631d08c91 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 3 Nov 2018 19:50:30 -0400 Subject: [PATCH 10/23] Add pthread for libnx --- Makefile.libretro | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.libretro b/Makefile.libretro index 9137f4ea7..eb4c3f1a8 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -293,6 +293,7 @@ else ifeq ($(platform), libnx) PLATFORM_DEFINES += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft STATIC_LINKING = 1 PLATFORM_DEFINES += -D_INCL_PHYSFS_PLATFORMS -DPHYSFS_PLATFORM_UNIX=1 + PLATFORM_DEFINES += -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_ # ARM else ifneq (,$(findstring armv,$(platform))) From fa6d96456096af5bed450d10f996eb2e5502f0c1 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 3 Nov 2018 22:22:57 -0400 Subject: [PATCH 11/23] Remove vendor/filesystem --- .gitmodules | 5 ----- vendor/filesystem | 1 - 2 files changed, 6 deletions(-) delete mode 160000 vendor/filesystem diff --git a/.gitmodules b/.gitmodules index 55c17f666..b179b87d1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,11 +13,6 @@ url = https://github.com/ChaiScript/ChaiScript.git ignore = dirty branch = develop -[submodule "vendor/filesystem"] - path = vendor/filesystem - url = https://github.com/wjakob/filesystem.git - ignore = dirty - branch = master [submodule "vendor/SDL_tty"] path = vendor/SDL_tty url = https://github.com/Grumbel/SDL_tty.git diff --git a/vendor/filesystem b/vendor/filesystem deleted file mode 160000 index 0a539a6c9..000000000 --- a/vendor/filesystem +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0a539a6c988dc8691af317e077893e831dee2908 From 70754c0c1336550590120c552171af807c530dfd Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 3 Nov 2018 22:27:08 -0400 Subject: [PATCH 12/23] Update CHANGELOG.md with filesystem changes --- CHANGELOG.md | 1 + src/love/filesystem.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8caf0ad97..350ead86e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## 0.29.1 - Unreleased ### Chores - Moved String Methods to [ChaiScript_Extras](https://github.com/ChaiScript/ChaiScript_Extras) +- Replaced use of `filesystem/path.h` with internal functions ## 0.29.0 - 2018-10-13 ### Fixes diff --git a/src/love/filesystem.cpp b/src/love/filesystem.cpp index d674498e2..5833708a5 100644 --- a/src/love/filesystem.cpp +++ b/src/love/filesystem.cpp @@ -62,11 +62,9 @@ std::string filesystem::getFileExtension(const std::string& filepath) { std::string filesystem::getBasename(const std::string& filepath) { char sep = '/'; - #ifdef _WIN32 if (filepath.find('\\') != std::string::npos) { sep = '\\'; } - #endif size_t i = filepath.rfind(sep, filepath.length()); if (i != std::string::npos) { From d8d97ece2ff78292e19435c49428416e29d69d9f Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 3 Nov 2018 22:36:32 -0400 Subject: [PATCH 13/23] Add POSIX_THREADS --- Makefile.libretro | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index eb4c3f1a8..11ed15363 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -292,8 +292,9 @@ else ifeq ($(platform), libnx) CFLAGS += -std=gnu11 PLATFORM_DEFINES += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft STATIC_LINKING = 1 - PLATFORM_DEFINES += -D_INCL_PHYSFS_PLATFORMS -DPHYSFS_PLATFORM_UNIX=1 - PLATFORM_DEFINES += -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_ + PLATFORM_DEFINES += -D_INCL_PHYSFS_PLATFORMS -DPHYSFS_PLATFORM_UNIX=1 -DPHYSFS_PLATFORM_POSIX=1 + #PLATFORM_DEFINES += -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_ + PLATFORM_DEFINES += -D_POSIX_THREADS # ARM else ifneq (,$(findstring armv,$(platform))) From 4c042b3ecff29cca8a9a214a298ad108f25543ba Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 3 Nov 2018 22:57:49 -0400 Subject: [PATCH 14/23] Update libnx definitions --- Makefile.libretro | 3 +-- src/love/audio.cpp | 1 - src/love/filesystem.cpp | 3 +++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 11ed15363..bd7d88586 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -293,8 +293,7 @@ else ifeq ($(platform), libnx) PLATFORM_DEFINES += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft STATIC_LINKING = 1 PLATFORM_DEFINES += -D_INCL_PHYSFS_PLATFORMS -DPHYSFS_PLATFORM_UNIX=1 -DPHYSFS_PLATFORM_POSIX=1 - #PLATFORM_DEFINES += -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_ - PLATFORM_DEFINES += -D_POSIX_THREADS + PLATFORM_DEFINES += -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_ # ARM else ifneq (,$(findstring armv,$(platform))) diff --git a/src/love/audio.cpp b/src/love/audio.cpp index 2d65ef2e4..5cbfd817c 100644 --- a/src/love/audio.cpp +++ b/src/love/audio.cpp @@ -3,7 +3,6 @@ #include "Types/Audio/SoundData.h" #include "../ChaiLove.h" #include "sound.h" -#include "physfs.h" #include "audio/conversion/float_to_s16.h" using love::Types::Audio::SoundData; diff --git a/src/love/filesystem.cpp b/src/love/filesystem.cpp index 5833708a5..aefce6c4f 100644 --- a/src/love/filesystem.cpp +++ b/src/love/filesystem.cpp @@ -2,6 +2,9 @@ #include #include "libretro.h" +#if SWITCH +#include +#endif #include "physfs.h" #include "filesystem.h" #include "physfsrwops.h" From 4f5172bf0298cd563376a0df4788de645bcb2f98 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 4 Nov 2018 00:05:22 -0400 Subject: [PATCH 15/23] Update Makefile.libretro --- Makefile.libretro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index bd7d88586..c233784a4 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -292,8 +292,8 @@ else ifeq ($(platform), libnx) CFLAGS += -std=gnu11 PLATFORM_DEFINES += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft STATIC_LINKING = 1 - PLATFORM_DEFINES += -D_INCL_PHYSFS_PLATFORMS -DPHYSFS_PLATFORM_UNIX=1 -DPHYSFS_PLATFORM_POSIX=1 - PLATFORM_DEFINES += -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_ + #PLATFORM_DEFINES += -D_INCL_PHYSFS_PLATFORMS -DPHYSFS_PLATFORM_UNIX=1 -DPHYSFS_PLATFORM_POSIX=1 + #PLATFORM_DEFINES += -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_ # ARM else ifneq (,$(findstring armv,$(platform))) From efe09e008cc15566c15800e18c26f898994e0d40 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 4 Nov 2018 00:05:33 -0400 Subject: [PATCH 16/23] Update filesystem.cpp --- src/love/filesystem.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/love/filesystem.cpp b/src/love/filesystem.cpp index aefce6c4f..5833708a5 100644 --- a/src/love/filesystem.cpp +++ b/src/love/filesystem.cpp @@ -2,9 +2,6 @@ #include #include "libretro.h" -#if SWITCH -#include -#endif #include "physfs.h" #include "filesystem.h" #include "physfsrwops.h" From 526d6aec60d2a8b43da248193fad7d9c441b2049 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 4 Nov 2018 00:23:06 -0400 Subject: [PATCH 17/23] 0.29.1 --- docs/Doxyfile | 2 +- src/ChaiLove.h | 4 ++-- vendor/ChaiScript_Extras | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/Doxyfile b/docs/Doxyfile index 1878557ee..73b362898 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -23,7 +23,7 @@ PROJECT_NAME = "ChaiLove API" # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = "0.29.0" +PROJECT_NUMBER = "0.29.1" # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/src/ChaiLove.h b/src/ChaiLove.h index a90fbf4a0..dbae5bec5 100644 --- a/src/ChaiLove.h +++ b/src/ChaiLove.h @@ -48,8 +48,8 @@ #define CHAILOVE_VERSION_MAJOR 0 #define CHAILOVE_VERSION_MINOR 29 -#define CHAILOVE_VERSION_PATCH 0 -#define CHAILOVE_VERSION_STRING "0.29.0" +#define CHAILOVE_VERSION_PATCH 1 +#define CHAILOVE_VERSION_STRING "0.29.1" #include "SDL.h" #include "libretro.h" diff --git a/vendor/ChaiScript_Extras b/vendor/ChaiScript_Extras index 6d77ff380..4f3ee0219 160000 --- a/vendor/ChaiScript_Extras +++ b/vendor/ChaiScript_Extras @@ -1 +1 @@ -Subproject commit 6d77ff3808b128c55190db1c8bea4098c63c3297 +Subproject commit 4f3ee02194411edc5b7aa80d109e400d3b94c15d From 5aa1b09e458c07f0393d37bd829e03b16bbd6cc9 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 4 Nov 2018 01:13:17 -0400 Subject: [PATCH 18/23] Add filesystem methods --- src/love/script.cpp | 3 +++ test/unittests/filesystem.chai | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/love/script.cpp b/src/love/script.cpp index 7126948bb..f409dfd6f 100644 --- a/src/love/script.cpp +++ b/src/love/script.cpp @@ -311,6 +311,9 @@ script::script(const std::string& file) { chai.add(fun, filesystem, const std::string&, const std::string&>(&filesystem::lines), "lines"); chai.add(fun(&filesystem::load), "load"); chai.add(fun(&script::loadModuleRequire, this), "require"); + chai.add(fun(&filesystem::getFileExtension), "getFileExtension"); + chai.add(fun(&filesystem::getBasename), "getBasename"); + chai.add(fun(&filesystem::getParentDirectory), "getParentDirectory"); // System chai.add(fun(&system::getOS), "getOS"); diff --git a/test/unittests/filesystem.chai b/test/unittests/filesystem.chai index 9cd6c81ea..f48fbf9cc 100644 --- a/test/unittests/filesystem.chai +++ b/test/unittests/filesystem.chai @@ -102,3 +102,12 @@ requiretestFileLoaded = false requireReturn = require("assets.requiretest") assert(requireReturn, " double call") assert_not(requiretestFileLoaded, " not loaded twice") + +// getFileExtension() +assert_equal(love.filesystem.getFileExtension("/opt/var/something.txt"), "txt", "love.filesystem.getFileExtension()") + +// getBasename +assert_equal(love.filesystem.getBasename("/opt/var/something.txt"), "something.txt", "love.filesystem.getBasename()") + +// getParentDirectory +assert_equal(love.filesystem.getParentDirectory("/opt/var/something.txt"), "/opt/var", "love.filesystem.getParentDirectory()") From 8826028c36f6516dd1e3d54661256fe4a7c8ef26 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 4 Nov 2018 01:07:55 -0500 Subject: [PATCH 19/23] Fix filesystem methods --- src/love/filesystem.cpp | 8 ++++++-- src/love/script.cpp | 4 ++-- test/unittests/filesystem.chai | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/love/filesystem.cpp b/src/love/filesystem.cpp index 5833708a5..65f32b709 100644 --- a/src/love/filesystem.cpp +++ b/src/love/filesystem.cpp @@ -49,7 +49,11 @@ bool filesystem::init(const std::string& file, const void* data) { } std::string filesystem::getParentDirectory(const std::string& filepath) { - return filepath.substr(0, filepath.find_last_of("/\\")); + size_t last = filepath.find_last_of("/\\"); + if (last != std::string::npos) { + return filepath.substr(0, last); + } + return ""; } std::string filesystem::getFileExtension(const std::string& filepath) { @@ -71,7 +75,7 @@ std::string filesystem::getBasename(const std::string& filepath) { return filepath.substr(i + 1, filepath.length() - i); } - return ""; + return filepath; } void filesystem::mountlibretro() { diff --git a/src/love/script.cpp b/src/love/script.cpp index f409dfd6f..e1ac536fc 100644 --- a/src/love/script.cpp +++ b/src/love/script.cpp @@ -35,7 +35,7 @@ bool script::loadModule(const std::string& moduleName) { // See if we are to append .chai. filename = filename + ".chai"; if (!app->filesystem.exists(filename)) { - std::cout << "[ChaiLove] [script] Module " << moduleName << " not found." << std::endl; + std::cout << "[ChaiLove] [script] Module " << filename << " not found." << std::endl; return false; } } @@ -45,7 +45,7 @@ bool script::loadModule(const std::string& moduleName) { // Make sure it was not empty. if (contents.empty()) { - std::cout << "[ChaiLove] [script] Module " << moduleName << " was loaded, but empty." << std::endl; + std::cout << "[ChaiLove] [script] Module " << filename << " was loaded, but empty." << std::endl; return false; } diff --git a/test/unittests/filesystem.chai b/test/unittests/filesystem.chai index f48fbf9cc..2e3a2154c 100644 --- a/test/unittests/filesystem.chai +++ b/test/unittests/filesystem.chai @@ -105,9 +105,12 @@ assert_not(requiretestFileLoaded, " not loaded twice") // getFileExtension() assert_equal(love.filesystem.getFileExtension("/opt/var/something.txt"), "txt", "love.filesystem.getFileExtension()") +assert_equal(love.filesystem.getFileExtension("/opt/var/something.tar.gz"), "gz", "love.filesystem.getFileExtension()") // getBasename assert_equal(love.filesystem.getBasename("/opt/var/something.txt"), "something.txt", "love.filesystem.getBasename()") +assert_equal(love.filesystem.getBasename("something.txt"), "something.txt", "love.filesystem.getBasename()") // getParentDirectory assert_equal(love.filesystem.getParentDirectory("/opt/var/something.txt"), "/opt/var", "love.filesystem.getParentDirectory()") +assert_equal(love.filesystem.getParentDirectory("something.txt"), "", "love.filesystem.getParentDirectory()") From 396da7210cfc0be65a4c6681211cdc71d8d9827a Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 5 Nov 2018 00:47:56 -0500 Subject: [PATCH 20/23] 0.29.1 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 350ead86e..8293f9dd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,13 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## 0.29.1 - Unreleased +## 0.29.1 - 2018-11-05 ### Chores - Moved String Methods to [ChaiScript_Extras](https://github.com/ChaiScript/ChaiScript_Extras) - Replaced use of `filesystem/path.h` with internal functions +- Updated ChaiScript/ChaiScript_Extras +- Updated libretro/libretro-common +- Updated effolkronium/random ## 0.29.0 - 2018-10-13 ### Fixes From e5ea28a97ccf01c595eeb73ab5b615e364bc630c Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 5 Nov 2018 00:50:10 -0500 Subject: [PATCH 21/23] Update libretro-common and styleguide --- vendor/libretro-common | 2 +- vendor/styleguide | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/libretro-common b/vendor/libretro-common index 79c6979d3..4f99997d9 160000 --- a/vendor/libretro-common +++ b/vendor/libretro-common @@ -1 +1 @@ -Subproject commit 79c6979d34298bcb3d67ad64d937c9140d54df9f +Subproject commit 4f99997d94bbfed63d957153976dd9a43c73aced diff --git a/vendor/styleguide b/vendor/styleguide index d3881b4fa..2589002f5 160000 --- a/vendor/styleguide +++ b/vendor/styleguide @@ -1 +1 @@ -Subproject commit d3881b4fa910526f0e60e56d0110a9c6492949d8 +Subproject commit 2589002f53fa8866c9f0b48b9854eb4c8dbf4fa9 From 39990920dbb5a32d4b342255c85c9f463684f81a Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 5 Nov 2018 00:51:04 -0500 Subject: [PATCH 22/23] Update styleguide --- vendor/styleguide | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/styleguide b/vendor/styleguide index 2589002f5..d3881b4fa 160000 --- a/vendor/styleguide +++ b/vendor/styleguide @@ -1 +1 @@ -Subproject commit 2589002f53fa8866c9f0b48b9854eb4c8dbf4fa9 +Subproject commit d3881b4fa910526f0e60e56d0110a9c6492949d8 From 47a48a39dfdd850faefb0ae5c428038c3637e47d Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 5 Nov 2018 01:07:40 -0500 Subject: [PATCH 23/23] Update libnx whitespace and definition --- Makefile.libretro | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index c233784a4..c13b9a4b3 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -13,7 +13,6 @@ filter_out1 = $(filter-out $(firstword $1),$1) filter_out2 = $(call filter_out1,$(call filter_out1,$1)) unixpath = $(subst \,/,$1) unixcygpath = /$(subst :,,$(call unixpath,$1)) -export DEPSDIR := $(CURDIR)/ ifeq ($(platform),) platform = unix @@ -278,22 +277,23 @@ else ifeq ($(platform), switch) # Nintendo Switch (libnx) else ifeq ($(platform), libnx) - include $(DEVKITPRO)/libnx/switch_rules - EXT=a - TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT) - DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL - CFLAGS := $(DEFINES) -g \ - -O2 \ + export DEPSDIR := $(CURDIR)/ + include $(DEVKITPRO)/libnx/switch_rules + EXT=a + TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT) + DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL + CFLAGS := $(DEFINES) -g \ + -O2 \ -fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs - CFLAGS += $(INCDIRS) - CFLAGS += $(INCLUDE) -D__SWITCH__ -DHAVE_LIBNX - # Replaced -fno-rtti -fno-exceptions with -fexceptions, using C++14 - CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fexceptions -std=c++14 - CFLAGS += -std=gnu11 - PLATFORM_DEFINES += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft - STATIC_LINKING = 1 - #PLATFORM_DEFINES += -D_INCL_PHYSFS_PLATFORMS -DPHYSFS_PLATFORM_UNIX=1 -DPHYSFS_PLATFORM_POSIX=1 - #PLATFORM_DEFINES += -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_ + CFLAGS += $(INCDIRS) + CFLAGS += $(INCLUDE) -D__SWITCH__ -DHAVE_LIBNX + # Replaced -fno-rtti -fno-exceptions with -fexceptions, using C++14 + CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fexceptions -std=c++14 + CFLAGS += -std=gnu11 + PLATFORM_DEFINES += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft + STATIC_LINKING = 1 + #PLATFORM_DEFINES += -D_INCL_PHYSFS_PLATFORMS -DPHYSFS_PLATFORM_UNIX=1 -DPHYSFS_PLATFORM_POSIX=1 + #PLATFORM_DEFINES += -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_ # ARM else ifneq (,$(findstring armv,$(platform)))