Remove ScriptTypes and ScriptExtraHeaders headers

The first header was used to include the SpiderMonkey JS API at once,
with safeguards and preprocessor defines. Nowadays, SpiderMonkey
provides modular headers allowing us to include what we use, refs #8086.

Some defines have to be moved to compiler options but it is apparently
a mistake from the SM developers:
https://bugzilla.mozilla.org/show_bug.cgi?id=1987876
This commit is contained in:
Itms 2025-09-10 12:18:16 +02:00
parent c4762e22cc
commit 9150c20818
No known key found for this signature in database
GPG key ID: C7E52BD14CE14E09
43 changed files with 35 additions and 138 deletions

View file

@ -643,6 +643,17 @@ extern_lib_defs = {
},
spidermonkey = {
compile_settings = function()
-- This define is not supposed to be needed anymore, but it leaks into the
-- SpiderMonkey headers, and is necessary to build with ESR140 at the time
-- of writing (https://bugzilla.mozilla.org/show_bug.cgi?id=1987876).
filter "system:windows"
defines { "XP_WIN" }
filter { }
filter "Debug"
defines { "MOZ_DIAGNOSTIC_ASSERT_ENABLED" }
filter {}
if _OPTIONS["with-system-mozjs"] then
if not _OPTIONS["android"] then
pkgconfig.add_includes_after("mozjs-128")

View file

@ -31,7 +31,6 @@
#include "scriptinterface/Object.h"
#include "scriptinterface/ScriptContext.h"
#include "scriptinterface/ScriptExceptions.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/ScriptRequest.h"

View file

@ -20,7 +20,6 @@
#include "lib/file/vfs/vfs_path.h"
#include "lib/types.h"
#include "scriptinterface/ScriptTypes.h"
#include "scriptinterface/StructuredClone.h"
#include <atomic>

View file

@ -28,7 +28,6 @@
#include "ps/CStr.h"
#include "ps/Errors.h"
#include "ps/FileIo.h"
#include "scriptinterface/ScriptTypes.h"
#include "simulation2/system/Entity.h"
#include <cstddef>

View file

@ -31,7 +31,6 @@
#include "ps/CLogger.h"
#include "ps/Profiler2.h"
#include "scriptinterface/Object.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptInterface.h"
#include "soundmanager/ISoundManager.h"

View file

@ -33,7 +33,6 @@
#include "lib/input.h"
#include "maths/Rect.h"
#include "ps/CStr.h"
#include "scriptinterface/ScriptTypes.h"
#include <js/RootingAPI.h>
#include <js/TypeDecls.h>

View file

@ -33,7 +33,6 @@
#include "scriptinterface/ScriptConversions.h"
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/ScriptRequest.h"
#include "scriptinterface/ScriptTypes.h"
#include <fmt/format.h>
#include <js/CallArgs.h>

View file

@ -20,10 +20,10 @@
#include "gui/ObjectBases/IGUIObject.h"
#include "lib/sysdep/compiler.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include <js/GCVector.h>
#include <js/Id.h>
#include <js/PropertyDescriptor.h>
#include <js/Proxy.h>
#include <js/RootingAPI.h>
#include <js/TypeDecls.h>

View file

@ -26,7 +26,6 @@
#include "scriptinterface/FunctionWrapper.h"
#include "scriptinterface/Object.h"
#include "scriptinterface/ScriptConversions.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptRequest.h"
#include <js/CallAndConstruct.h>

View file

@ -22,7 +22,6 @@
#include "lib/posix/posix_types.h"
#include "lib/types.h"
#include "ps/CStr.h"
#include "scriptinterface/ScriptTypes.h"
class ScriptInterface;
namespace JS { class Value; }

View file

@ -19,8 +19,10 @@
#define IXMPPCLIENT_H
#include "lib/types.h"
#include "scriptinterface/ScriptTypes.h"
#include <js/Value.h>
class ScriptInterface;
class ScriptRequest;
class IXmppClient

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2024 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -24,7 +24,6 @@
#define NETMESSAGES_H
#include "ps/CStr.h"
#include "scriptinterface/ScriptTypes.h"
#define PS_PROTOCOL_MAGIC 0x5073013f // 'P', 's', 0x01, '?'
#define PS_PROTOCOL_MAGIC_RESPONSE 0x50630121 // 'P', 'c', 0x01, '!'

View file

@ -23,7 +23,6 @@
#include "lib/types.h"
#include "network/NetHost.h"
#include "ps/CStr.h"
#include "scriptinterface/ScriptTypes.h"
#include <ctime>
#include <js/RootingAPI.h>

View file

@ -26,7 +26,6 @@
#include "ps/Errors.h"
#include "lib/file/vfs/vfs_path.h"
#include "lib/file/vfs/vfs_util.h"
#include "scriptinterface/ScriptTypes.h"
#endif // CONFIG_ENABLE_PCH
// IWYU pragma: end_keep

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2023 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -18,6 +18,5 @@
#include "lib/precompiled.h" // common precompiled header
// "graphics"-specific PCH:
#include "scriptinterface/ScriptTypes.h"
#include "ps/CStr.h"
#include "maths/Matrix3D.h"

View file

@ -23,7 +23,6 @@
#include "lib/types.h"
#include "ps/CStr.h"
#include "ps/Errors.h"
#include "scriptinterface/ScriptTypes.h"
#include "simulation2/helpers/Player.h"
#include <algorithm>

View file

@ -42,7 +42,6 @@
#include "scriptinterface/JSON.h"
#include "scriptinterface/Object.h"
#include "scriptinterface/ScriptContext.h"
#include "scriptinterface/ScriptConversions.h"
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/ScriptRequest.h"
#include "scriptinterface/ScriptStats.h"
@ -55,7 +54,6 @@
#include <ctime>
#include <fstream>
#include <js/Value.h>
#include <memory>
/**

View file

@ -21,11 +21,11 @@
#include "lib/code_annotation.h"
#include "lib/os_path.h"
#include "lib/types.h"
#include "scriptinterface/ScriptTypes.h"
#include <iosfwd>
#include <js/RootingAPI.h>
#include <js/TypeDecls.h>
#include <js/Value.h>
#include <string>
#include <vector>

View file

@ -19,7 +19,6 @@
#define INCLUDED_SAVEDGAME
#include "lib/status.h"
#include "scriptinterface/ScriptTypes.h"
#include "scriptinterface/StructuredClone.h"
#include <js/Value.h>

View file

@ -19,7 +19,6 @@
#define INCLUDED_VISUAL_REPLAY
#include "lib/os_path.h"
#include "scriptinterface/ScriptTypes.h"
#include <js/TypeDecls.h>

View file

@ -19,7 +19,6 @@
#define INCLUDED_JSI_VFS
#include "lib/types.h"
#include "scriptinterface/ScriptTypes.h"
#include <js/PropertyDescriptor.h>

View file

@ -30,7 +30,6 @@
#include "scriptinterface/FunctionWrapper.h"
#include "scriptinterface/ScriptExceptions.h"
#include "scriptinterface/ScriptRequest.h"
#include "scriptinterface/ScriptTypes.h"
#include <js/Exception.h>
#include <js/JSON.h>

View file

@ -20,7 +20,6 @@
#include "lib/file/vfs/vfs_path.h"
#include "lib/path.h"
#include "scriptinterface/ScriptTypes.h"
#include <cstddef>
#include <exception>

View file

@ -23,12 +23,12 @@
#include "ps/CLogger.h"
#include "scriptinterface/ScriptConversions.h"
#include "scriptinterface/ScriptRequest.h"
#include "scriptinterface/ScriptTypes.h"
#include <cwchar>
#include <js/Array.h>
#include <js/GCVector.h>
#include <js/Id.h>
#include <js/Object.h>
#include <js/PropertyAndElement.h>
#include <js/PropertyDescriptor.h>
#include <js/RootingAPI.h>

View file

@ -29,7 +29,6 @@
#include "scriptinterface/ModuleLoader.h"
#include "scriptinterface/Promises.h"
#include "scriptinterface/ScriptEngine.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include <js/Context.h>
#include <js/GCAPI.h>

View file

@ -18,9 +18,6 @@
#ifndef INCLUDED_SCRIPTCONTEXT
#define INCLUDED_SCRIPTCONTEXT
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptTypes.h"
#include <cstdint>
#include <list>
#include <memory>

View file

@ -23,7 +23,6 @@
#include "lib/path.h"
#include "ps/CStr.h"
#include "scriptinterface/ScriptExceptions.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptRequest.h"
#include <cstddef>

View file

@ -23,7 +23,6 @@
#include "lib/types.h"
#include "ps/CStr.h"
#include "scriptinterface/ScriptExceptions.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptRequest.h"
#include <js/Array.h>

View file

@ -20,11 +20,17 @@
#include "lib/debug.h"
#include "ps/Singleton.h"
#include "scriptinterface/ScriptTypes.h"
#include <js/Initialization.h>
#include <list>
#if MOZJS_MAJOR_VERSION != 128
#error Your compiler is trying to use an incorrect major version of the \
SpiderMonkey library. The SpiderMonkey API is subject to changes, and the \
game will not build with the selected version of the library. Make sure \
you have got all the right files and include paths.
#endif
struct JSContext;
/**

View file

@ -1,48 +0,0 @@
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INCLUDED_SCRIPTEXTRAHEADERS
#define INCLUDED_SCRIPTEXTRAHEADERS
// Includes occasionally-used SpiderMonkey headers for typed arrays and debug API,
// with appropriate tweaks to fix warnings and build errors. (Most code should
// just include ScriptTypes.h directly to get the standard jsapi.h.)
#include "scriptinterface/ScriptTypes.h"
#include "jsfriendapi.h"
#include "js/AllocPolicy.h"
#include "js/Array.h"
#include "js/ArrayBuffer.h"
#include "js/CompilationAndEvaluation.h"
#include "js/Conversions.h"
#include "js/ContextOptions.h"
#include "js/ForOfIterator.h"
#include "js/GCAPI.h"
#include "js/GCHashTable.h"
#include "js/SourceText.h"
#include "js/Proxy.h"
#include "js/Warnings.h"
#include "js/experimental/TypedData.h"
#include "js/friend/ErrorMessages.h"
#undef signbit
#endif // INCLUDED_SCRIPTEXTRAHEADERS

View file

@ -33,7 +33,6 @@
#include "scriptinterface/ModuleLoader.h"
#include "scriptinterface/Object.h"
#include "scriptinterface/ScriptContext.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptStats.h"
#include "scriptinterface/StructuredClone.h"

View file

@ -24,7 +24,6 @@
#include "scriptinterface/ScriptConversions.h"
#include "scriptinterface/ScriptExceptions.h"
#include "scriptinterface/ScriptRequest.h"
#include "scriptinterface/ScriptTypes.h"
#include <functional>
#include <js/CallArgs.h>

View file

@ -1,44 +0,0 @@
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INCLUDED_SCRIPTTYPES
#define INCLUDED_SCRIPTTYPES
#ifdef DEBUG
#define MOZ_DIAGNOSTIC_ASSERT_ENABLED
#endif
#ifdef _WIN32
# define XP_WIN
# ifndef WIN32
# define WIN32 // SpiderMonkey expects this
# endif
#endif
#include "jspubtd.h"
#include "jsapi.h"
#if MOZJS_MAJOR_VERSION != 128
#error Your compiler is trying to use an incorrect major version of the \
SpiderMonkey library. The SpiderMonkey API is subject to changes, and the \
game will not build with the selected version of the library. Make sure \
you have got all the right files and include paths.
#endif
class ScriptInterface;
#endif // INCLUDED_SCRIPTTYPES

View file

@ -27,7 +27,6 @@
#include "ps/Filesystem.h"
#include "scriptinterface/JSON.h"
#include "scriptinterface/Object.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/ScriptRequest.h"
#include "simulation2/system/InterfaceScripted.h"

View file

@ -18,7 +18,6 @@
#ifndef INCLUDED_SIMULATIONCOMMAND
#define INCLUDED_SIMULATIONCOMMAND
#include "scriptinterface/ScriptTypes.h"
#include "simulation2/helpers/Player.h"
#include <js/RootingAPI.h>

View file

@ -23,7 +23,6 @@
#include "ps/CLogger.h"
#include "scriptinterface/FunctionWrapper.h"
#include "scriptinterface/JSON.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptRequest.h"
#include "simulation2/serialization/SerializedScriptTypes.h"

View file

@ -25,7 +25,6 @@
#include "lib/debug.h"
#include "lib/types.h"
#include "maths/Fixed.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "simulation2/system/Component.h"
#include <cstddef>

View file

@ -21,7 +21,6 @@
#include "lib/types.h"
#include "maths/Fixed.h"
#include "ps/Errors.h"
#include "scriptinterface/ScriptTypes.h"
#include <cstddef>
#include <cstdint>

View file

@ -21,7 +21,6 @@
#include "lib/types.h"
#include "maths/Fixed.h"
#include "ps/Errors.h"
#include "scriptinterface/ScriptTypes.h"
#include <cstddef>
#include <cstdint>

View file

@ -25,7 +25,6 @@
#include "lib/utf8.h"
#include "ps/CStr.h"
#include "scriptinterface/FunctionWrapper.h"
#include "scriptinterface/ScriptExtraHeaders.h"
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/ScriptRequest.h"
#include "simulation2/serialization/ISerializer.h"

View file

@ -19,7 +19,6 @@
#define INCLUDED_MESSAGE
#include "lib/code_annotation.h"
#include "scriptinterface/ScriptTypes.h"
#include <js/RootingAPI.h>
#include <js/TypeDecls.h>

View file

@ -22,7 +22,6 @@
#include "lib/types.h"
#include "maths/Fixed.h"
#include "ps/Errors.h"
#include "scriptinterface/ScriptTypes.h"
#include <cstddef>
#include <iosfwd>

View file

@ -6,6 +6,15 @@ cppcheckError:./source/lib/file/file_system.cpp
*:source/third_party/*
// Ignore SpiderMonkey version compile check
preprocessorErrorDirective:source/scriptinterface/ScriptEngine.h
// Lists of network/simulation messages are included in other files which define macros
unknownMacro:source/network/NetMessages.h
unknownMacro:source/simulation2/TypeList.h
// Issues reported by cppcheck and not yet fixed
danglingLifetime:source/lib/sysdep/os/unix/ufilesystem.cpp
@ -34,7 +43,6 @@ preprocessorErrorDirective:source/lib/sysdep/arch.h
preprocessorErrorDirective:source/lib/sysdep/arch/x86_x64/x86_x64.h
preprocessorErrorDirective:source/lib/sysdep/os/win/win.h
preprocessorErrorDirective:source/network/NMTCreator.h
preprocessorErrorDirective:source/scriptinterface/ScriptTypes.h
preprocessorErrorDirective:source/tools/atlas/AtlasUI/CustomControls/Windows/AtlasWindow.h
returnDanglingLifetime:source/lib/file/vfs/vfs_tree.cpp
@ -53,4 +61,3 @@ unknownMacro:source/lib/sysdep/os/win/wdbg_sym.cpp
unknownMacro:source/lib/sysdep/os/win/wfirmware.cpp
unknownMacro:source/lib/sysdep/os/win/wposix/wutsname.cpp
unknownMacro:source/ps/CStr.cpp
unknownMacro:source/simulation2/TypeList.h