mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-07 20:30:53 +01:00
Testing changes for Android and iOS tests
This commit is contained in:
parent
9649e5e446
commit
d1df773e47
2 changed files with 70 additions and 14 deletions
|
@ -188,6 +188,12 @@ if(MSVC_IDE)
|
||||||
target_sources(Luau.VM PRIVATE tools/natvis/VM.natvis)
|
target_sources(Luau.VM PRIVATE tools/natvis/VM.natvis)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# On Windows and Android threads are provided, on Linux/Mac/iOS we use pthreads
|
||||||
|
add_library(osthreads INTERFACE)
|
||||||
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin|iOS")
|
||||||
|
target_link_libraries(osthreads INTERFACE "-lpthread")
|
||||||
|
endif ()
|
||||||
|
|
||||||
if(LUAU_BUILD_CLI)
|
if(LUAU_BUILD_CLI)
|
||||||
target_compile_options(Luau.Repl.CLI PRIVATE ${LUAU_OPTIONS})
|
target_compile_options(Luau.Repl.CLI PRIVATE ${LUAU_OPTIONS})
|
||||||
target_compile_options(Luau.Reduce.CLI PRIVATE ${LUAU_OPTIONS})
|
target_compile_options(Luau.Reduce.CLI PRIVATE ${LUAU_OPTIONS})
|
||||||
|
@ -200,13 +206,8 @@ if(LUAU_BUILD_CLI)
|
||||||
|
|
||||||
target_link_libraries(Luau.Repl.CLI PRIVATE Luau.Compiler Luau.Config Luau.CodeGen Luau.VM Luau.CLI.lib isocline)
|
target_link_libraries(Luau.Repl.CLI PRIVATE Luau.Compiler Luau.Config Luau.CodeGen Luau.VM Luau.CLI.lib isocline)
|
||||||
|
|
||||||
if(UNIX)
|
target_link_libraries(Luau.Repl.CLI PRIVATE osthreads)
|
||||||
find_library(LIBPTHREAD pthread)
|
target_link_libraries(Luau.Analyze.CLI PRIVATE osthreads)
|
||||||
if (LIBPTHREAD)
|
|
||||||
target_link_libraries(Luau.Repl.CLI PRIVATE pthread)
|
|
||||||
target_link_libraries(Luau.Analyze.CLI PRIVATE pthread)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(Luau.Analyze.CLI PRIVATE Luau.Analysis Luau.CLI.lib)
|
target_link_libraries(Luau.Analyze.CLI PRIVATE Luau.Analysis Luau.CLI.lib)
|
||||||
|
|
||||||
|
@ -230,18 +231,17 @@ if(LUAU_BUILD_TESTS)
|
||||||
target_compile_options(Luau.Conformance PRIVATE ${LUAU_OPTIONS})
|
target_compile_options(Luau.Conformance PRIVATE ${LUAU_OPTIONS})
|
||||||
target_include_directories(Luau.Conformance PRIVATE extern)
|
target_include_directories(Luau.Conformance PRIVATE extern)
|
||||||
target_link_libraries(Luau.Conformance PRIVATE Luau.Analysis Luau.Compiler Luau.CodeGen Luau.VM)
|
target_link_libraries(Luau.Conformance PRIVATE Luau.Analysis Luau.Compiler Luau.CodeGen Luau.VM)
|
||||||
file(REAL_PATH "tests/conformance" LUAU_CONFORMANCE_SOURCE_DIR)
|
if(CMAKE_SYSTEM_NAME MATCHES "Android|iOS")
|
||||||
|
set(LUAU_CONFORMANCE_SOURCE_DIR "Client/Luau/tests/conformance")
|
||||||
|
else()
|
||||||
|
file(REAL_PATH "tests/conformance" LUAU_CONFORMANCE_SOURCE_DIR)
|
||||||
|
endif()
|
||||||
target_compile_definitions(Luau.Conformance PRIVATE LUAU_CONFORMANCE_SOURCE_DIR="${LUAU_CONFORMANCE_SOURCE_DIR}")
|
target_compile_definitions(Luau.Conformance PRIVATE LUAU_CONFORMANCE_SOURCE_DIR="${LUAU_CONFORMANCE_SOURCE_DIR}")
|
||||||
|
|
||||||
target_compile_options(Luau.CLI.Test PRIVATE ${LUAU_OPTIONS})
|
target_compile_options(Luau.CLI.Test PRIVATE ${LUAU_OPTIONS})
|
||||||
target_include_directories(Luau.CLI.Test PRIVATE extern CLI)
|
target_include_directories(Luau.CLI.Test PRIVATE extern CLI)
|
||||||
target_link_libraries(Luau.CLI.Test PRIVATE Luau.Compiler Luau.Config Luau.CodeGen Luau.VM Luau.CLI.lib isocline)
|
target_link_libraries(Luau.CLI.Test PRIVATE Luau.Compiler Luau.Config Luau.CodeGen Luau.VM Luau.CLI.lib isocline)
|
||||||
if(UNIX)
|
target_link_libraries(Luau.CLI.Test PRIVATE osthreads)
|
||||||
find_library(LIBPTHREAD pthread)
|
|
||||||
if (LIBPTHREAD)
|
|
||||||
target_link_libraries(Luau.CLI.Test PRIVATE pthread)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,46 @@
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#if __APPLE__
|
||||||
|
#include <TargetConditionals.h>
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
|
||||||
|
std::optional<std::string> getResourcePath0()
|
||||||
|
{
|
||||||
|
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||||
|
if (mainBundle == NULL)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
|
||||||
|
if (mainBundleURL == NULL)
|
||||||
|
{
|
||||||
|
CFRelease(mainBundle);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
char pathBuffer[PATH_MAX];
|
||||||
|
if (!CFURLGetFileSystemRepresentation(mainBundleURL, true, (UInt8*)pathBuffer, PATH_MAX))
|
||||||
|
{
|
||||||
|
CFRelease(mainBundleURL);
|
||||||
|
CFRelease(mainBundle);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFRelease(mainBundleURL);
|
||||||
|
CFRelease(mainBundle);
|
||||||
|
return std::string(pathBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> getResourcePath()
|
||||||
|
{
|
||||||
|
static std::optional<std::string> path0 = getResourcePath0();
|
||||||
|
return path0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
LUAU_FASTFLAG(LuauUpdatedRequireByStringSemantics)
|
LUAU_FASTFLAG(LuauUpdatedRequireByStringSemantics)
|
||||||
|
|
||||||
class ReplWithPathFixture
|
class ReplWithPathFixture
|
||||||
|
@ -49,7 +89,23 @@ public:
|
||||||
std::string luauDirRel = ".";
|
std::string luauDirRel = ".";
|
||||||
std::string luauDirAbs;
|
std::string luauDirAbs;
|
||||||
|
|
||||||
|
#if !__APPLE__ || !TARGET_OS_IPHONE
|
||||||
std::optional<std::string> cwd = getCurrentWorkingDirectory();
|
std::optional<std::string> cwd = getCurrentWorkingDirectory();
|
||||||
|
#else
|
||||||
|
std::optional<std::string> cwd0 = getCurrentWorkingDirectory();
|
||||||
|
std::optional<std::string> cwd = getResourcePath();
|
||||||
|
if (cwd && cwd0)
|
||||||
|
{
|
||||||
|
// when running in xcode cwd0 is "/", however that is not always the case
|
||||||
|
const auto& _res = *cwd;
|
||||||
|
const auto& _cwd = *cwd0;
|
||||||
|
if (_res.find(_cwd) == 0)
|
||||||
|
{
|
||||||
|
// we need relative path so we subtract cwd0 from cwd
|
||||||
|
luauDirRel = "./" + _res.substr(_cwd.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
REQUIRE_MESSAGE(cwd, "Error getting Luau path");
|
REQUIRE_MESSAGE(cwd, "Error getting Luau path");
|
||||||
std::replace((*cwd).begin(), (*cwd).end(), '\\', '/');
|
std::replace((*cwd).begin(), (*cwd).end(), '\\', '/');
|
||||||
luauDirAbs = *cwd;
|
luauDirAbs = *cwd;
|
||||||
|
|
Loading…
Add table
Reference in a new issue