Skip to content

Commit 7c9f942

Browse files
authored
Merge pull request #439 from libretro/disable-love-system-execute-by-default
Disable love system execute by default
2 parents 66d0866 + d91df90 commit 7c9f942

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
- Make sure to use `conf.chai` for `def conf(t)`
1111
- `joystickpressed()` and `joystickreleased()` now matches [love.joystickpressed](https://love2d.org/wiki/love.joystickpressed) counterpart
1212
- Added `gamepadpressed()` and `gamepadreleased()` matching [love.gamepadpressed`](https://love2d.org/wiki/love.gamepadpressed)
13+
- `love.system.execute()` build disabled by default. Enable with `CHAILOVE_ENABLE_LOVE_SYSTEM_EXECUTE` compile define.
1314

1415
## 1.3.1 - 2025-02-04
1516
### Change

Makefile.libretro

+1-4
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ else ifeq ($(platform), tvos-arm64)
8787
TARGET := $(TARGET_NAME)_libretro_tvos.dylib
8888
fpic := -fPIC
8989
SHARED := -dynamiclib
90-
CFLAGS += -DIOS -DCHAILOVE_DISABLE_LOVE_SYSTEM_EXECUTE
91-
CXXFLAGS += -DCHAILOVE_DISABLE_LOVE_SYSTEM_EXECUTE
90+
CFLAGS += -DIOS
9291
ifeq ($(IOSSDK),)
9392
IOSSDK := $(shell xcodebuild -version -sdk appletvos Path)
9493
endif
@@ -643,13 +642,11 @@ endif
643642
ifeq ($(platform), ios-arm64)
644643
LDFLAGS += -framework IOKit -framework Foundation
645644
FLAGS += -D__MACH__ -D__APPLE__
646-
FLAGS += -DCHAILOVE_DISABLE_LOVE_SYSTEM_EXECUTE
647645
endif
648646

649647
ifeq ($(platform), tvos-arm64)
650648
LDFLAGS += -framework Foundation
651649
FLAGS += -D__MACH__ -D__APPLE__
652-
FLAGS += -DCHAILOVE_DISABLE_LOVE_SYSTEM_EXECUTE
653650
endif
654651

655652
ifeq ($(EXTERNAL_ZLIB), 1)

src/love/system.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#include "../ChaiLove.h"
33

44
#include <string>
5+
#ifdef CHAILOVE_ENABLE_LOVE_SYSTEM_EXECUTE
56
#include <cstdlib>
7+
#endif
68
#include <cstdio>
79
#include <vector>
810
#include "libretro.h"
@@ -107,7 +109,7 @@ std::string system::getUsername() {
107109
}
108110

109111
bool system::execute(const std::string& command) {
110-
#ifdef CHAILOVE_DISABLE_LOVE_SYSTEM_EXECUTE
112+
#ifndef CHAILOVE_ENABLE_LOVE_SYSTEM_EXECUTE
111113
pntr_app_log(PNTR_APP_LOG_ERROR, "[ChaiLove] [system] love.system.execute() is disabled");
112114
return false;
113115
#else

src/love/system.h

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class system {
9797
/**
9898
* Execute an operating system shell command. This is like the C system() function.
9999
*
100+
* This feature is disabled by default. Enable with `CHAILOVE_ENABLE_LOVE_SYSTEM_EXECUTE` compiler definition.
101+
*
100102
* @param command The command to run.
101103
*
102104
* @return Returns true or false depending on the process succeeded to execute.

test/unittests/system.chai

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ assert_equal(versionNumber[0], 2, "love.system.getVersion()")
1414
var username = love.system.getUsername()
1515
assert(true, "love.system.getUsername() == '" + username + "'")
1616

17-
// getOS()
18-
if (love.system.getOS() == "Linux") {
19-
// Run in foreground.
20-
var result = love.system.execute("uname")
21-
assert(result, "love.system.execute('uname')")
22-
}
23-
2417
// setClipboardText()
2518
love.system.setClipboardText("Hello World!")
2619

0 commit comments

Comments
 (0)