Skip to content

Commit

Permalink
Merge pull request #439 from libretro/disable-love-system-execute-by-…
Browse files Browse the repository at this point in the history
…default

Disable love system execute by default
  • Loading branch information
RobLoach authored Feb 8, 2025
2 parents 66d0866 + d91df90 commit 7c9f942
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Make sure to use `conf.chai` for `def conf(t)`
- `joystickpressed()` and `joystickreleased()` now matches [love.joystickpressed](https://love2d.org/wiki/love.joystickpressed) counterpart
- Added `gamepadpressed()` and `gamepadreleased()` matching [love.gamepadpressed`](https://love2d.org/wiki/love.gamepadpressed)
- `love.system.execute()` build disabled by default. Enable with `CHAILOVE_ENABLE_LOVE_SYSTEM_EXECUTE` compile define.

## 1.3.1 - 2025-02-04
### Change
Expand Down
5 changes: 1 addition & 4 deletions Makefile.libretro
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ else ifeq ($(platform), tvos-arm64)
TARGET := $(TARGET_NAME)_libretro_tvos.dylib
fpic := -fPIC
SHARED := -dynamiclib
CFLAGS += -DIOS -DCHAILOVE_DISABLE_LOVE_SYSTEM_EXECUTE
CXXFLAGS += -DCHAILOVE_DISABLE_LOVE_SYSTEM_EXECUTE
CFLAGS += -DIOS
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
endif
Expand Down Expand Up @@ -643,13 +642,11 @@ endif
ifeq ($(platform), ios-arm64)
LDFLAGS += -framework IOKit -framework Foundation
FLAGS += -D__MACH__ -D__APPLE__
FLAGS += -DCHAILOVE_DISABLE_LOVE_SYSTEM_EXECUTE
endif

ifeq ($(platform), tvos-arm64)
LDFLAGS += -framework Foundation
FLAGS += -D__MACH__ -D__APPLE__
FLAGS += -DCHAILOVE_DISABLE_LOVE_SYSTEM_EXECUTE
endif

ifeq ($(EXTERNAL_ZLIB), 1)
Expand Down
4 changes: 3 additions & 1 deletion src/love/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include "../ChaiLove.h"

#include <string>
#ifdef CHAILOVE_ENABLE_LOVE_SYSTEM_EXECUTE
#include <cstdlib>
#endif
#include <cstdio>
#include <vector>
#include "libretro.h"
Expand Down Expand Up @@ -107,7 +109,7 @@ std::string system::getUsername() {
}

bool system::execute(const std::string& command) {
#ifdef CHAILOVE_DISABLE_LOVE_SYSTEM_EXECUTE
#ifndef CHAILOVE_ENABLE_LOVE_SYSTEM_EXECUTE
pntr_app_log(PNTR_APP_LOG_ERROR, "[ChaiLove] [system] love.system.execute() is disabled");
return false;
#else
Expand Down
2 changes: 2 additions & 0 deletions src/love/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class system {
/**
* Execute an operating system shell command. This is like the C system() function.
*
* This feature is disabled by default. Enable with `CHAILOVE_ENABLE_LOVE_SYSTEM_EXECUTE` compiler definition.
*
* @param command The command to run.
*
* @return Returns true or false depending on the process succeeded to execute.
Expand Down
7 changes: 0 additions & 7 deletions test/unittests/system.chai
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ assert_equal(versionNumber[0], 2, "love.system.getVersion()")
var username = love.system.getUsername()
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')")
}

// setClipboardText()
love.system.setClipboardText("Hello World!")

Expand Down

0 comments on commit 7c9f942

Please sign in to comment.