From 147aaeec8219b0501e04b69ff1188888b4a7bbc3 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 7 Oct 2018 14:16:54 -0400 Subject: [PATCH 01/36] Fix save_dir mounting --- CHANGELOG.md | 4 ++++ src/love/filesystem.cpp | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b66d7eb..6788506 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.28.1 - Unreleased +### Fixes +- Fixed save_dir mounting + ## 0.28.0 - 2018-10-07 ### Features - `love.timer.step()` now returns `dt` diff --git a/src/love/filesystem.cpp b/src/love/filesystem.cpp index 44f7b67..02e5df8 100644 --- a/src/love/filesystem.cpp +++ b/src/love/filesystem.cpp @@ -72,8 +72,12 @@ void filesystem::mountlibretro() { if (ChaiLove::environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &save_dir) && save_dir) { save_dir = *save_dir ? save_dir : system_dir; mount(save_dir, "/libretro/saves", false); - } else { + } else if (system_dir) { + // Have the system directory be the save directory if available. mount(save_dir = system_dir, "/libretro/saves", false); + } else { + // Save directory becomes the current working directory. + mount(save_dir = ".", "/libretro/saves", false); } // Ensure the write directory is set to the Save Directory. @@ -171,10 +175,11 @@ char* filesystem::readChar(const std::string& filename) { std::string filesystem::read(const std::string& filename) { // Retrieve a character buffer. char* myBuf = readChar(filename); - if (myBuf == NULL) { - return std::string(""); + std::string output; + if (myBuf != NULL) { + output = std::string(myBuf); } - return std::string(myBuf); + return output; } void* filesystem::readBuffer(const std::string& filename, int& size) { @@ -222,6 +227,9 @@ bool filesystem::unmount(const std::string& archive) { } bool filesystem::mount(const char *archive, const std::string& mountpoint) { + if (strlen(archive) == 0) { + return false; + } return mount(std::string(archive), mountpoint); } From 97ad82450059a7afc90e07fb1add06b50619c899 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 8 Oct 2018 17:59:22 -0400 Subject: [PATCH 02/36] Error out with fatal erros --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 5427c4b..2ae92fb 100644 --- a/Makefile +++ b/Makefile @@ -16,16 +16,16 @@ all: $(TARGET) $(MAKE) $(TARGET) $(TARGET): $(OBJECTS) | vendor/libretro-common/include/libretro.h - -$(CXX) -o $@ $^ $(LDFLAGS) + $(CXX) -Wfatal-errors -o $@ $^ $(LDFLAGS) %.o: %.cpp | vendor/libretro-common/include/libretro.h - -$(CXX) -c -o $@ $< $(CXXFLAGS) + $(CXX) -Wfatal-errors -c -o $@ $< $(CXXFLAGS) %.o: %.c | vendor/libretro-common/include/libretro.h - -$(CC) -c -o $@ $< $(CFLAGS) + $(CC) -Wfatal-errors -c -o $@ $< $(CFLAGS) %.o: %.m | vendor/libretro-common/include/libretro.h - -$(CC) -c -o $@ $< $(CFLAGS) + $(CC) -Wfatal-errors -c -o $@ $< $(CFLAGS) clean: rm -f $(TARGET) $(OBJECTS) From 9cad66f0ea07ccf049d39f4e23c18aaaf6d6a3e6 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 8 Oct 2018 18:01:02 -0400 Subject: [PATCH 03/36] Add -wfatal-errors --- Makefile | 8 ++++---- Makefile.common | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2ae92fb..809fd64 100644 --- a/Makefile +++ b/Makefile @@ -16,16 +16,16 @@ all: $(TARGET) $(MAKE) $(TARGET) $(TARGET): $(OBJECTS) | vendor/libretro-common/include/libretro.h - $(CXX) -Wfatal-errors -o $@ $^ $(LDFLAGS) + $(CXX) -o $@ $^ $(LDFLAGS) %.o: %.cpp | vendor/libretro-common/include/libretro.h - $(CXX) -Wfatal-errors -c -o $@ $< $(CXXFLAGS) + $(CXX) -c -o $@ $< $(CXXFLAGS) %.o: %.c | vendor/libretro-common/include/libretro.h - $(CC) -Wfatal-errors -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(CFLAGS) %.o: %.m | vendor/libretro-common/include/libretro.h - $(CC) -Wfatal-errors -c -o $@ $< $(CFLAGS) + $(CC) -c -o $@ $< $(CFLAGS) clean: rm -f $(TARGET) $(OBJECTS) diff --git a/Makefile.common b/Makefile.common index 42a7ca2..a7d3c03 100644 --- a/Makefile.common +++ b/Makefile.common @@ -8,6 +8,7 @@ SOURCES_CXX := $(wildcard \ $(CORE_DIR)/src/love/Types/Graphics/*.cpp \ $(CORE_DIR)/src/love/Types/Input/*.cpp \ ) +FLAGS += -Wfatal-errors # semver FLAGS += -I$(CORE_DIR)/vendor/semver From d240627d0acfba7552bb8791dce63aa8049c549a Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 10 Oct 2018 19:38:58 -0400 Subject: [PATCH 04/36] docs: Split up Installation and Usage --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index af561a7..4a4f1d8 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,20 @@ ChaiLove is an awesome framework you can use to make 2D games in [ChaiScript](ht - [Game of Life](https://github.com/RobLoach/ChaiLove-GameOfLife) - [... and more](https://github.com/topics/chailove) -## Usage +## Installation -ChaiLove is a [libretro](https://www.libretro.com/) core, which can be run through [RetroArch](http://retroarch.com/). [Floppy Bird](https://github.com/RobLoach/ChaiLove-FloppyBird) is a [free game you can download and play](https://www.youtube.com/watch?v=RLVwTh6qDFI)... +ChaiLove is a [libretro](https://www.libretro.com/) core, which can be installed through [RetroArch](http://retroarch.com/). 1. Run [RetroArch](http://retroarch.com/) 2. *Online Updater* → *Core Updator* → *ChaiLove* -3. *Online Updater* → *Content Downloader* → *ChaiLove* → *Floppy Bird* -4. *Load Content* → *Downloads* → *Floppy Bird.chailove* + +## Usage + +[Floppy Bird](https://github.com/RobLoach/ChaiLove-FloppyBird) is a [free game you can download and play](https://www.youtube.com/watch?v=RLVwTh6qDFI)... + +1. Run [RetroArch](http://retroarch.com/) +2. *Online Updater* → *Content Downloader* → *ChaiLove* → *FloppyBird.chailove* +3. *Load Content* → *Downloads* → *FloppyBird.chailove* Alternatively, you can run the ChaiLove core through RetroArch via the command line: From cdec53d1ddf7681df566c455edbc2fde94ed8343 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 10 Oct 2018 20:24:24 -0400 Subject: [PATCH 05/36] Remove minor debugging --- src/libretro.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libretro.cpp b/src/libretro.cpp index 6c9bdab..3dc4f05 100644 --- a/src/libretro.cpp +++ b/src/libretro.cpp @@ -78,7 +78,6 @@ void retro_set_environment(retro_environment_t cb) { * libretro callback; Updates the core option variables. */ static void update_variables(void) { - std::cout << "[ChaiLove] [libretro] update_variables()" << std::endl; ChaiLove* app = ChaiLove::getInstance(); app->system.updateVariables(app->config); } @@ -314,7 +313,6 @@ void frame_time_cb(retro_usec_t usec) { * libretro callback; Load the given game. */ bool retro_load_game(const struct retro_game_info *info) { - std::cout << "[ChaiLove] retro_load_game" << std::endl; // Update the core options. update_variables(); From aaa88afab9b6e49e3333c12bbdaf05a3cfacf098 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 10 Oct 2018 23:51:00 -0400 Subject: [PATCH 06/36] Add string::trim() --- CHANGELOG.md | 3 +++ src/docs/Globals.h | 12 ++++++++++++ src/love/script.cpp | 13 ++++++++++++- src/love/system.h | 4 +++- test/unittests/system.chai | 5 +++++ test/unittests/timer.chai | 2 +- 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6788506..fea8572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixes - Fixed save_dir mounting +### Features +- Added `string::trim()` + ## 0.28.0 - 2018-10-07 ### Features - `love.timer.step()` now returns `dt` diff --git a/src/docs/Globals.h b/src/docs/Globals.h index 4e06016..16ae77c 100644 --- a/src/docs/Globals.h +++ b/src/docs/Globals.h @@ -100,6 +100,18 @@ class String { * @endcode */ std::string replace(const std::string& search, const std::string& replace); + + /** + * Returns a trimmed version of the given string. + * + * @return A new string with trimmed left and right. + * + * @code + * var hello = " Hello World! " + * var result = hello.trim() + * // => "Hello World!" + */ + std::string trim(); }; #endif // SRC_CHAILOVEDOCS_H_ diff --git a/src/love/script.cpp b/src/love/script.cpp index ab271de..32f0713 100644 --- a/src/love/script.cpp +++ b/src/love/script.cpp @@ -76,6 +76,7 @@ chaiscript::Boxed_Value script::eval(const std::string& code, const std::string& std::string contents = replaceString(code, "\t", " "); return chai.eval(contents, Exception_Handler(), filename); } + std::string script::evalString(const std::string& code, const std::string& filename) { // Replace possible problematic tabs, and evaluate the script. std::string contents = replaceString(code, "\t", " "); @@ -102,6 +103,7 @@ script::script(const std::string& file) { } return newSubject; }), "replace"); + // string::replace(char search, char replace) chai.add(fun([](const std::string& subject, char search, char replace) { std::string newSubject(subject); @@ -109,6 +111,15 @@ script::script(const std::string& file) { 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"); + // List auto listModule = std::make_shared(); chaiscript::bootstrap::standard_library::list_type >("List", *listModule); @@ -330,9 +341,9 @@ script::script(const std::string& file) { chai.add(fun(&system::getVersion), "getVersion"); chai.add(fun(&system::getVersionString), "getVersionString"); chai.add(fun(&system::getUsername), "getUsername"); - chai.add(fun(&system::execute), "execute"); chai.add(fun(&system::getClipboardText), "getClipboardText"); chai.add(fun(&system::setClipboardText), "setClipboardText"); + chai.add(fun(&system::execute), "execute"); // Mouse chai.add(fun(&mouse::getX), "getX"); diff --git a/src/love/system.h b/src/love/system.h index 69f4dff..a35a18f 100644 --- a/src/love/system.h +++ b/src/love/system.h @@ -96,7 +96,9 @@ class system { /** * Execute an operating system shell command. This is like the C system() function. * - * @return True or False depending on whether or not the command started properly. + * @param command The command to run. + * + * @return Returns true or false depending on the process succeeded to execute. */ bool execute(const std::string& command); diff --git a/test/unittests/system.chai b/test/unittests/system.chai index b1f3ca6..4abbff2 100644 --- a/test/unittests/system.chai +++ b/test/unittests/system.chai @@ -16,6 +16,7 @@ assert(true, "love.system.getUsername() == '" + username + "'") // getOS() if (love.system.getOS() == "Linux") { + // Run in foreground. var result = love.system.execute("uname") assert(result, "love.system.execute('uname')") } @@ -32,3 +33,7 @@ var newReplaceString = replaceSubject.replace("World", "Space") assert_equal(newReplaceString, "Hello Space! Hello Space!", "string::replace(string, string)") newReplaceString = replaceSubject.replace('!', '.') assert_equal(newReplaceString, "Hello World. Hello World.", "string::replace(char, char)") + +// string::trim() +var trimSubject = " Hello World! " +assert_equal(trimSubject.trim(), "Hello World!", "string::trim()") diff --git a/test/unittests/timer.chai b/test/unittests/timer.chai index 7273309..0c81f4b 100644 --- a/test/unittests/timer.chai +++ b/test/unittests/timer.chai @@ -4,4 +4,4 @@ assert(delta >= 0, "love.timer.getDelta()") // getFPS() var fps = love.timer.getFPS() -assert(fps >= 0, "love.love.timer.getFPS()") +assert(fps >= 0, "love.timer.getFPS()") From e6e69a705a0cd6b5c3b391d20cb08879d081f026 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 11 Oct 2018 00:04:54 -0400 Subject: [PATCH 07/36] Add string::split() --- CHANGELOG.md | 3 ++- src/love/script.cpp | 24 ++++++++++++++++++++++-- test/unittests/system.chai | 8 ++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fea8572..f54258b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## 0.28.1 - Unreleased ### Fixes -- Fixed save_dir mounting +- Fixed `/libretro/saves` mounting ### Features - Added `string::trim()` +- Added `string::split()` ## 0.28.0 - 2018-10-07 ### Features diff --git a/src/love/script.cpp b/src/love/script.cpp index 32f0713..3be280b 100644 --- a/src/love/script.cpp +++ b/src/love/script.cpp @@ -104,14 +104,14 @@ script::script(const std::string& file) { return newSubject; }), "replace"); - // string::replace(char search, char 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() + // string::trim() chai.add(fun([](const std::string& subject) { std::string result(subject); std::string chars = "\t\n\v\f\r "; @@ -120,6 +120,26 @@ script::script(const std::string& file) { 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"); + // List auto listModule = std::make_shared(); chaiscript::bootstrap::standard_library::list_type >("List", *listModule); diff --git a/test/unittests/system.chai b/test/unittests/system.chai index 4abbff2..89dec45 100644 --- a/test/unittests/system.chai +++ b/test/unittests/system.chai @@ -37,3 +37,11 @@ assert_equal(newReplaceString, "Hello World. Hello World.", "string::replace(cha // string::trim() var trimSubject = " Hello World! " assert_equal(trimSubject.trim(), "Hello World!", "string::trim()") + +// string::split() +var splitTest = "Hello|How|Are|You" +var splitResult = splitTest.split("|") +assert_equal(splitResult[1], "How", "string::split()") +splitTest = "Rob, John, Loach" +splitResult = splitTest.split(", ") +assert_equal(splitResult[1], "John", " - commas") From 33ed1733d0370c6b604eb90354fcac0dc7ef8c7c Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 11 Oct 2018 02:45:44 -0400 Subject: [PATCH 08/36] Update Globals.h --- src/docs/Globals.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/docs/Globals.h b/src/docs/Globals.h index 16ae77c..c8232ab 100644 --- a/src/docs/Globals.h +++ b/src/docs/Globals.h @@ -110,8 +110,14 @@ class String { * var hello = " Hello World! " * var result = hello.trim() * // => "Hello World!" + * @endcode */ std::string trim(); + + /** + * Splits a string by the given token. + */ + std::string split(const std::string& token); }; #endif // SRC_CHAILOVEDOCS_H_ From 2c37a363d7c7a51305395b5e2b185d18a148109f Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 13 Oct 2018 16:50:10 -0400 Subject: [PATCH 09/36] Add conf.chai loading --- CHANGELOG.md | 3 ++- examples/benchmark/main.chai | 4 ---- src/libretro.cpp | 4 ++-- src/love/script.cpp | 7 ++++--- test/unittests/conf.chai | 8 ++++++++ test/unittests/main.chai | 6 ------ test/unittests/system.chai | 12 ++++++++++-- 7 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 test/unittests/conf.chai diff --git a/CHANGELOG.md b/CHANGELOG.md index f54258b..af5eb02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,14 @@ 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.28.1 - Unreleased +## 0.29.0 - Unreleased ### Fixes - Fixed `/libretro/saves` mounting ### Features - Added `string::trim()` - Added `string::split()` +- Adds loading of `conf.chai` for the `conf()` callback ## 0.28.0 - 2018-10-07 ### Features diff --git a/examples/benchmark/main.chai b/examples/benchmark/main.chai index 697fd6d..9debffa 100644 --- a/examples/benchmark/main.chai +++ b/examples/benchmark/main.chai @@ -126,8 +126,6 @@ class Sprite { }; def loadstate(data) { - print("Load State") - print(data) var info = from_json(data) var num = info["number"] @@ -147,8 +145,6 @@ def savestate() { // Construct the JSON data. var data = ["number": num] - print("Save State") - print(to_json(data)) // Tell the system to save the JSON data. return to_json(data) diff --git a/src/libretro.cpp b/src/libretro.cpp index 3dc4f05..a4c5336 100644 --- a/src/libretro.cpp +++ b/src/libretro.cpp @@ -225,8 +225,8 @@ void retro_set_controller_port_device(unsigned port, unsigned device) { * libretro callback; Return the amount of bytes required to save a state. */ size_t retro_serialize_size(void) { - // Save states will be 5 kilobytes. - return 5000; + // Save states will be 32 kilobytes. + return 32768; } /** diff --git a/src/love/script.cpp b/src/love/script.cpp index 3be280b..9576853 100644 --- a/src/love/script.cpp +++ b/src/love/script.cpp @@ -58,7 +58,7 @@ bool script::loadModule(const std::string& moduleName) { bool script::loadModuleRequire(const std::string& moduleName) { // Check if the module has already been loaded. - std::string filename = replaceString(moduleName, ".", "/"); + std::string filename = replaceString(replaceString(moduleName, ".chai", ""), ".", "/"); if (std::find(m_requiremodules.begin(), m_requiremodules.end(), filename) != m_requiremodules.end()) { return true; } @@ -438,12 +438,13 @@ script::script(const std::string& file) { // Load the main.chai file. ::filesystem::path p(file.c_str()); std::string extension(p.extension()); + loadModuleRequire("conf"); if (extension == "chailove" || extension == "chaigame") { - mainLoaded = loadModule("main.chai"); + mainLoaded = loadModuleRequire("main"); } else { // Otherwise, load the actual file. std::string filename(p.filename()); - mainLoaded = loadModule(filename); + mainLoaded = loadModuleRequire(filename); } } diff --git a/test/unittests/conf.chai b/test/unittests/conf.chai new file mode 100644 index 0000000..0d7f7dd --- /dev/null +++ b/test/unittests/conf.chai @@ -0,0 +1,8 @@ +global confTestLoaded = false + +def conf(t) { + t.console = true + t.window.width = 640 + t.window.height = 500 + confTestLoaded = true +} diff --git a/test/unittests/main.chai b/test/unittests/main.chai index f215f3f..ded5cf1 100644 --- a/test/unittests/main.chai +++ b/test/unittests/main.chai @@ -1,11 +1,5 @@ global failure = "" -def conf(t) { - t.console = true - t.window.width = 640 - t.window.height = 500 -} - def load() { print("\n================================\n") print("ChaiLove: Unit Testing Framework\n") diff --git a/test/unittests/system.chai b/test/unittests/system.chai index 89dec45..26d7c2b 100644 --- a/test/unittests/system.chai +++ b/test/unittests/system.chai @@ -42,6 +42,14 @@ assert_equal(trimSubject.trim(), "Hello World!", "string::trim()") var splitTest = "Hello|How|Are|You" var splitResult = splitTest.split("|") assert_equal(splitResult[1], "How", "string::split()") -splitTest = "Rob, John, Loach" +splitTest = "Hello, World, Time" splitResult = splitTest.split(", ") -assert_equal(splitResult[1], "John", " - commas") +assert_equal(splitResult[1], "World", " - commas") + +// conf.chai +var objs = get_objects() +var confTestLoadedExists = objs["confTestLoaded"].get_type_info().bare_equal(bool_type) +assert(confTestLoadedExists, "conf.chai is loaded") +if (confTestLoadedExists) { + assert(confTestLoaded, "conf() called") +} From b08fef956c27a9d48a5823db99640f2718ef8727 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 13 Oct 2018 16:53:31 -0400 Subject: [PATCH 10/36] Make save state 8KB --- src/libretro.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libretro.cpp b/src/libretro.cpp index a4c5336..67de394 100644 --- a/src/libretro.cpp +++ b/src/libretro.cpp @@ -225,8 +225,8 @@ void retro_set_controller_port_device(unsigned port, unsigned device) { * libretro callback; Return the amount of bytes required to save a state. */ size_t retro_serialize_size(void) { - // Save states will be 32 kilobytes. - return 32768; + // Save states will be 8 KB. + return 8192; } /** From 90a623759f1b406fb8f448113d475ef6305e1dd7 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 13 Oct 2018 16:58:13 -0400 Subject: [PATCH 11/36] benchmark: Update Sprite constructor --- examples/benchmark/main.chai | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/benchmark/main.chai b/examples/benchmark/main.chai index 9debffa..bb658c5 100644 --- a/examples/benchmark/main.chai +++ b/examples/benchmark/main.chai @@ -94,8 +94,8 @@ class Sprite { def Sprite() { this.x = love.math.random(love.graphics.getWidth()) * 1.0f this.y = love.math.random(love.graphics.getHeight()) * 1.0f - this.xspeed = love.math.random(10) * 50.0f - this.yspeed = love.math.random(10) * 50.0f + this.xspeed = love.math.random(-10, 10) * 50 + this.yspeed = love.math.random(-10, 10) * 50 } def draw() { From f3797d61bbfc8e081c44c1b58d5092aba2ea9575 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 13 Oct 2018 17:08:03 -0400 Subject: [PATCH 12/36] Move conf() to conf.chai --- examples/benchmark/conf.chai | 8 ++++++++ examples/benchmark/main.chai | 34 ---------------------------------- examples/pong/conf.chai | 9 +++++++++ examples/pong/main.chai | 11 ----------- 4 files changed, 17 insertions(+), 45 deletions(-) create mode 100644 examples/benchmark/conf.chai create mode 100644 examples/pong/conf.chai diff --git a/examples/benchmark/conf.chai b/examples/benchmark/conf.chai new file mode 100644 index 0000000..fb2e787 --- /dev/null +++ b/examples/benchmark/conf.chai @@ -0,0 +1,8 @@ +/** + * ChaiLove callback; Configure the application. + */ +def conf(t) { + t.window.width = 720 + t.window.height = 680 + t.console = true +} diff --git a/examples/benchmark/main.chai b/examples/benchmark/main.chai index bb658c5..b7e899e 100644 --- a/examples/benchmark/main.chai +++ b/examples/benchmark/main.chai @@ -7,15 +7,6 @@ global sprites = List() global img global music -/** - * ChaiLove callback; Configure the application. - */ -def conf(t) { - t.window.width = 720 - t.window.height = 680 - t.console = true -} - /** * ChaiLove callback; Load the application. */ @@ -124,28 +115,3 @@ class Sprite { } } }; - -def loadstate(data) { - var info = from_json(data) - var num = info["number"] - - // Do something with the loaded number. - sprites.clear() - for (var i = 0; i < num; ++i) { - sprites.push_back(Sprite()) - } - - // The state loaded correctly, so return true. - return true -} - -def savestate() { - // Retrieve the number to save. - var num = sprites.size() - - // Construct the JSON data. - var data = ["number": num] - - // Tell the system to save the JSON data. - return to_json(data) -} diff --git a/examples/pong/conf.chai b/examples/pong/conf.chai new file mode 100644 index 0000000..a335539 --- /dev/null +++ b/examples/pong/conf.chai @@ -0,0 +1,9 @@ +/** + * ChaiLove callback; Configure the application. + */ +def conf(t) { + t.window.width = 640 + t.window.height = 480 + //t.modules.sound = false + t.console = true +} diff --git a/examples/pong/main.chai b/examples/pong/main.chai index e810b7a..6932796 100644 --- a/examples/pong/main.chai +++ b/examples/pong/main.chai @@ -5,16 +5,6 @@ global players = [] global pongSound global ball -/** - * ChaiLove callback; Configure the application. - */ -def conf(t) { - t.window.width = 640 - t.window.height = 480 - //t.modules.sound = false - t.console = true -} - /** * ChaiLove callback; Load the application. */ @@ -29,7 +19,6 @@ def load() { Player(false, 80.0f, love.graphics.getHeight() / 2.0f), Player(true, love.graphics.getWidth() - 80.0f, love.graphics.getHeight() / 2.0f) ] - } /** From 16e3c94708f2dc8f42085649c100ca8842b27003 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 13 Oct 2018 17:34:35 -0400 Subject: [PATCH 13/36] 0.29.0 --- CHANGELOG.md | 2 +- docs/Doxyfile | 2 +- examples/snake/Snake.chai | 2 +- src/ChaiLove.h | 4 ++-- src/love/script.h | 4 +++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af5eb02..6c1f4f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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.0 - Unreleased +## 0.29.0 - 2018-10-13 ### Fixes - Fixed `/libretro/saves` mounting diff --git a/docs/Doxyfile b/docs/Doxyfile index 5cd0f12..1878557 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.28.0" +PROJECT_NUMBER = "0.29.0" # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/examples/snake/Snake.chai b/examples/snake/Snake.chai index 1fbdd8d..781e1a5 100644 --- a/examples/snake/Snake.chai +++ b/examples/snake/Snake.chai @@ -47,7 +47,7 @@ global T def conf(t) { t.window.width = WIDTH * gridScale t.window.height = HEIGHT * gridScale - t.version = "0.28.0" + t.version = "0.29.0" } /** diff --git a/src/ChaiLove.h b/src/ChaiLove.h index 02d21c4..a90fbf4 100644 --- a/src/ChaiLove.h +++ b/src/ChaiLove.h @@ -47,9 +47,9 @@ #define SRC_CHAILOVE_H_ #define CHAILOVE_VERSION_MAJOR 0 -#define CHAILOVE_VERSION_MINOR 28 +#define CHAILOVE_VERSION_MINOR 29 #define CHAILOVE_VERSION_PATCH 0 -#define CHAILOVE_VERSION_STRING "0.28.0" +#define CHAILOVE_VERSION_STRING "0.29.0" #include "SDL.h" #include "libretro.h" diff --git a/src/love/script.h b/src/love/script.h index ecaf6cf..916f4dc 100644 --- a/src/love/script.h +++ b/src/love/script.h @@ -45,6 +45,8 @@ class script { * * @param t The config object to modify. * + * This callback can live in the `conf.chai` file. + * * ### Example * * @code @@ -53,7 +55,7 @@ class script { * t.console = false * * // The ChaiLove version this game was made for. - * t.version = "0.27.0" + * t.version = "0.29.0" * * // The width and height of the game. * t.window.width = 1024 From 90860f9711093a0534a02325a93f86a142843b22 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sun, 21 Oct 2018 16:34:53 -0700 Subject: [PATCH 14/36] 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 29905d9..79c6979 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 15/36] 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 7043c12..f1adc0f 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 ac0d7ce..8d0fc74 160000 --- a/vendor/chaiscript +++ b/vendor/chaiscript @@ -1 +1 @@ -Subproject commit ac0d7ce94925f8eac367533b276d9d7db13a77ae +Subproject commit 8d0fc743418385451146bed97c75b27a8e38acdb diff --git a/vendor/cppcodec b/vendor/cppcodec index 302dc28..82d0117 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 fe12df0..3ae84ee 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 2cdf5dc..985de84 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 16/36] Revert ChaiScript update --- vendor/chaiscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/chaiscript b/vendor/chaiscript index 8d0fc74..ac0d7ce 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 17/36] 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 6c1f4f7..8caf0ad 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 9576853..d503dc9 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 f1adc0f..76d21cd 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 18/36] Update libnx definitions --- Makefile.libretro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.libretro b/Makefile.libretro index c17a2a0..95600bc 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 19/36] 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 a32a01e..d356db5 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 0be81b2..1b196a7 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 95600bc..207e622 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 3a57264..2821bbd 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 02e5df8..16b9f23 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 a848dcc..1018e29 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 d503dc9..2bc6a12 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 20/36] 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 2821bbd..77c354f 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 2bc6a12..7126948 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 21/36] 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 1b196a7..1be6db8 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 207e622..9137f4e 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 76d21cd..6d77ff3 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 22/36] 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 16b9f23..d674498 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 23/36] Add pthread for libnx --- Makefile.libretro | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.libretro b/Makefile.libretro index 9137f4e..eb4c3f1 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 24/36] 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 55c17f6..b179b87 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 0a539a6..0000000 --- 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 25/36] 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 8caf0ad..350ead8 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 d674498..5833708 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 26/36] Add POSIX_THREADS --- Makefile.libretro | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index eb4c3f1..11ed153 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 27/36] 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 11ed153..bd7d885 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 2d65ef2..5cbfd81 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 5833708..aefce6c 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 28/36] Update Makefile.libretro --- Makefile.libretro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index bd7d885..c233784 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 29/36] 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 aefce6c..5833708 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 30/36] 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 1878557..73b3628 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 a90fbf4..dbae5be 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 6d77ff3..4f3ee02 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 31/36] 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 7126948..f409dfd 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 9cd6c81..f48fbf9 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 32/36] 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 5833708..65f32b7 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 f409dfd..e1ac536 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 f48fbf9..2e3a215 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 33/36] 0.29.1 --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 350ead8..8293f9d 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 34/36] 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 79c6979..4f99997 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 d3881b4..2589002 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 35/36] Update styleguide --- vendor/styleguide | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/styleguide b/vendor/styleguide index 2589002..d3881b4 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 36/36] Update libnx whitespace and definition --- Makefile.libretro | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index c233784..c13b9a4 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)))