mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Add VS2022 support with the v143 toolset
This commit is contained in:
parent
8ed40553c8
commit
ef69c37f66
7 changed files with 29 additions and 74 deletions
|
|
@ -469,8 +469,8 @@ function project_create(project_name, target_type)
|
|||
cppdialect "C++17"
|
||||
kind(target_type)
|
||||
|
||||
filter "action:vs2017"
|
||||
toolset "v141_xp"
|
||||
filter "action:vs2022"
|
||||
toolset "v143"
|
||||
filter {}
|
||||
|
||||
filter "action:vs*"
|
||||
|
|
@ -1007,7 +1007,7 @@ function setup_all_libs ()
|
|||
end
|
||||
|
||||
-- runtime-library-specific
|
||||
if _ACTION == "vs2017" then
|
||||
if _ACTION == "vs2022" then
|
||||
table.insert(source_dirs, "lib/sysdep/rtl/msc");
|
||||
else
|
||||
table.insert(source_dirs, "lib/sysdep/rtl/gcc");
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ rem ** Create Visual Studio Workspaces on Windows **
|
|||
|
||||
cd /D "%~dp0"
|
||||
cd ..\bin
|
||||
if not exist ..\workspaces\vs2017\SKIP_PREMAKE_HERE premake5.exe --file="../premake/premake5.lua" --outpath="../workspaces/vs2017" %* vs2017 || exit /b 1
|
||||
if not exist ..\workspaces\vs2022\SKIP_PREMAKE_HERE premake5.exe --file="../premake/premake5.lua" --outpath="../workspaces/vs2022" %* vs2022 || exit /b 1
|
||||
cd ..\workspaces
|
||||
|
|
|
|||
|
|
@ -43,14 +43,6 @@
|
|||
// external libraries from pulling it in (which would cause conflicts).
|
||||
#undef _WINDOWS_
|
||||
|
||||
// set version; needed for EnumDisplayDevices
|
||||
#ifndef NTDDI_VERSION
|
||||
# define NTDDI_VERSION NTDDI_LONGHORN
|
||||
#endif
|
||||
#ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x600
|
||||
#endif
|
||||
|
||||
#define NOGDICAPMASKS // CC_*, LC_*, PC_*, CP_*, TC_*, RC_
|
||||
//#define NOVIRTUALKEYCODES // VK_*
|
||||
//#define NOWINMESSAGES // WM_*, EM_*, LB_*, CB_*
|
||||
|
|
|
|||
|
|
@ -286,29 +286,6 @@ int wclose(int fd)
|
|||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// unistd.h
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// we don't want to #define read to _read, since that's a fairly common
|
||||
// identifier. therefore, translate from MS CRT names via thunk functions.
|
||||
// efficiency is less important, and the overhead could be optimized away.
|
||||
|
||||
int read(int fd, void* buf, size_t nbytes)
|
||||
{
|
||||
return _read(fd, buf, (int)nbytes);
|
||||
}
|
||||
|
||||
int write(int fd, void* buf, size_t nbytes)
|
||||
{
|
||||
return _write(fd, buf, (int)nbytes);
|
||||
}
|
||||
|
||||
off_t lseek(int fd, off_t ofs, int whence)
|
||||
{
|
||||
return _lseeki64(fd, ofs, whence);
|
||||
}
|
||||
|
||||
|
||||
int wtruncate(const OsPath& pathname, off_t length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
|
|
@ -53,12 +53,6 @@ typedef unsigned int mode_t; // defined by MinGW but not VC
|
|||
#define S_ISREG(m) (m & S_IFREG)
|
||||
|
||||
|
||||
//
|
||||
// <unistd.h>
|
||||
//
|
||||
|
||||
extern int read (int fd, void* buf, size_t nbytes); // thunk
|
||||
extern int write(int fd, void* buf, size_t nbytes); // thunk
|
||||
extern off_t lseek(int fd, off_t ofs, int whence); // thunk
|
||||
#include <corecrt_io.h> // read, write, lseek
|
||||
|
||||
#endif // #ifndef INCLUDED_WFILESYSTEM
|
||||
|
|
|
|||
|
|
@ -40,11 +40,6 @@
|
|||
#define VMA_STATS_STRING_ENABLED 0
|
||||
#endif
|
||||
|
||||
#if OS_WIN
|
||||
// MSVC doesn't enable std::shared_mutex for XP toolkit.
|
||||
#define VMA_USE_STL_SHARED_MUTEX 0
|
||||
#endif
|
||||
|
||||
#if GCC_VERSION
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat"
|
||||
|
|
|
|||
|
|
@ -65,13 +65,12 @@ private:
|
|||
|
||||
/**
|
||||
* Convenient struct to get info on a [class] [const] function pointer.
|
||||
* TODO VS19: I ran into a really weird bug with an auto specialisation on this taking function pointers.
|
||||
* It'd be good to add it back once we upgrade.
|
||||
*/
|
||||
template <class T> struct args_info;
|
||||
template <class T> struct args_info_t;
|
||||
template <auto T> using args_info = args_info_t<decltype(T)>;
|
||||
|
||||
template<typename R, typename ...Types>
|
||||
struct args_info<R(*)(Types ...)>
|
||||
struct args_info_t<R(*)(Types ...)>
|
||||
{
|
||||
static constexpr const size_t nb_args = sizeof...(Types);
|
||||
using return_type = R;
|
||||
|
|
@ -80,9 +79,9 @@ private:
|
|||
};
|
||||
|
||||
template<typename C, typename R, typename ...Types>
|
||||
struct args_info<R(C::*)(Types ...)> : public args_info<R(*)(Types ...)> { using object_type = C; };
|
||||
struct args_info_t<R(C::*)(Types ...)> : public args_info_t<R(*)(Types ...)> { using object_type = C; };
|
||||
template<typename C, typename R, typename ...Types>
|
||||
struct args_info<R(C::*)(Types ...) const> : public args_info<R(C::*)(Types ...)> {};
|
||||
struct args_info_t<R(C::*)(Types ...) const> : public args_info_t<R(C::*)(Types ...)> {};
|
||||
|
||||
struct IteratorResultError : std::runtime_error
|
||||
{
|
||||
|
|
@ -186,7 +185,7 @@ private:
|
|||
* Wrap std::apply for the case where we have an object method or a regular function.
|
||||
*/
|
||||
template <auto callable, typename T, typename tuple>
|
||||
static typename args_info<decltype(callable)>::return_type call(T* object, tuple& args)
|
||||
static typename args_info<callable>::return_type call(T* object, tuple& args)
|
||||
{
|
||||
if constexpr(std::is_same_v<T, void>)
|
||||
{
|
||||
|
|
@ -272,10 +271,8 @@ public:
|
|||
template <typename T>
|
||||
using ObjectGetter = T*(*)(const ScriptRequest&, JS::CallArgs&);
|
||||
|
||||
// TODO: the fact that this takes class and not auto is to work around an odd VS17 bug.
|
||||
// It can be removed with VS19.
|
||||
template <class callableType>
|
||||
using GetterFor = ObjectGetter<typename args_info<callableType>::object_type>;
|
||||
template <auto callable>
|
||||
using GetterFor = ObjectGetter<typename args_info<callable>::object_type>;
|
||||
|
||||
/**
|
||||
* The meat of this file. This wraps a C++ function into a JSNative,
|
||||
|
|
@ -290,16 +287,16 @@ public:
|
|||
*
|
||||
* @param thisGetter to get the object, if necessary.
|
||||
*/
|
||||
template <auto callable, GetterFor<decltype(callable)> thisGetter = nullptr>
|
||||
template <auto callable, GetterFor<callable> thisGetter = nullptr>
|
||||
static bool ToJSNative(JSContext* cx, unsigned argc, JS::Value* vp)
|
||||
{
|
||||
using ObjType = typename args_info<decltype(callable)>::object_type;
|
||||
using ObjType = typename args_info<callable>::object_type;
|
||||
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
ScriptRequest rq(cx);
|
||||
|
||||
// If the callable is an object method, we must specify how to fetch the object.
|
||||
static_assert(std::is_same_v<typename args_info<decltype(callable)>::object_type, void> || thisGetter != nullptr,
|
||||
static_assert(std::is_same_v<typename args_info<callable>::object_type, void> || thisGetter != nullptr,
|
||||
"ScriptFunction::Register - No getter specified for object method");
|
||||
|
||||
// GCC 7 triggers spurious warnings
|
||||
|
|
@ -319,16 +316,16 @@ public:
|
|||
#endif
|
||||
|
||||
bool wentOk = true;
|
||||
typename args_info<decltype(callable)>::arg_types outs = ConvertFromJS(rq, args, wentOk,
|
||||
static_cast<typename args_info<decltype(callable)>::arg_types*>(nullptr));
|
||||
typename args_info<callable>::arg_types outs = ConvertFromJS(rq, args, wentOk,
|
||||
static_cast<typename args_info<callable>::arg_types*>(nullptr));
|
||||
if (!wentOk)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
if constexpr (std::is_same_v<void, typename args_info<decltype(callable)>::return_type>)
|
||||
if constexpr (std::is_same_v<void, typename args_info<callable>::return_type>)
|
||||
call<callable>(obj, outs);
|
||||
else if constexpr (std::is_same_v<JS::Value, typename args_info<decltype(callable)>::return_type>)
|
||||
else if constexpr (std::is_same_v<JS::Value, typename args_info<callable>::return_type>)
|
||||
args.rval().set(call<callable>(obj, outs));
|
||||
else
|
||||
Script::ToJSVal(rq, args.rval(), call<callable>(obj, outs));
|
||||
|
|
@ -430,31 +427,31 @@ public:
|
|||
/**
|
||||
* Return a function spec from a C++ function.
|
||||
*/
|
||||
template <auto callable, GetterFor<decltype(callable)> thisGetter = nullptr>
|
||||
template <auto callable, GetterFor<callable> thisGetter = nullptr>
|
||||
static JSFunctionSpec Wrap(const char* name,
|
||||
const u16 flags = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT)
|
||||
{
|
||||
return JS_FN(name, (&ToJSNative<callable, thisGetter>), args_info<decltype(callable)>::nb_args, flags);
|
||||
return JS_FN(name, (&ToJSNative<callable, thisGetter>), args_info<callable>::nb_args, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a JSFunction from a C++ function.
|
||||
*/
|
||||
template <auto callable, GetterFor<decltype(callable)> thisGetter = nullptr>
|
||||
template <auto callable, GetterFor<callable> thisGetter = nullptr>
|
||||
static JSFunction* Create(const ScriptRequest& rq, const char* name,
|
||||
const u16 flags = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT)
|
||||
{
|
||||
return JS_NewFunction(rq.cx, &ToJSNative<callable, thisGetter>, args_info<decltype(callable)>::nb_args, flags, name);
|
||||
return JS_NewFunction(rq.cx, &ToJSNative<callable, thisGetter>, args_info<callable>::nb_args, flags, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a function on the native scope (usually 'Engine').
|
||||
*/
|
||||
template <auto callable, GetterFor<decltype(callable)> thisGetter = nullptr>
|
||||
template <auto callable, GetterFor<callable> thisGetter = nullptr>
|
||||
static void Register(const ScriptRequest& rq, const char* name,
|
||||
const u16 flags = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT)
|
||||
{
|
||||
JS_DefineFunction(rq.cx, rq.nativeScope, name, &ToJSNative<callable, thisGetter>, args_info<decltype(callable)>::nb_args, flags);
|
||||
JS_DefineFunction(rq.cx, rq.nativeScope, name, &ToJSNative<callable, thisGetter>, args_info<callable>::nb_args, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -462,11 +459,11 @@ public:
|
|||
* Prefer the version taking ScriptRequest unless you have a good reason not to.
|
||||
* @see Register
|
||||
*/
|
||||
template <auto callable, GetterFor<decltype(callable)> thisGetter = nullptr>
|
||||
template <auto callable, GetterFor<callable> thisGetter = nullptr>
|
||||
static void Register(JSContext* cx, JS::HandleObject scope, const char* name,
|
||||
const u16 flags = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT)
|
||||
{
|
||||
JS_DefineFunction(cx, scope, name, &ToJSNative<callable, thisGetter>, args_info<decltype(callable)>::nb_args, flags);
|
||||
JS_DefineFunction(cx, scope, name, &ToJSNative<callable, thisGetter>, args_info<callable>::nb_args, flags);
|
||||
}
|
||||
|
||||
template<typename Callable>
|
||||
|
|
|
|||
Loading…
Reference in a new issue