This commit is contained in:
SirLynix 2022-12-06 20:10:10 +01:00 committed by Jérôme Leclercq
parent b379518479
commit 292ca60592
34 changed files with 1995 additions and 60 deletions

1208
emscripten.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,8 @@
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Platform/Keyboard.hpp>
#include <Nazara/Platform/Platform.hpp>
#include <Nazara/Platform/Window.hpp>
#include <Nazara/Utility/BasicMainloop.hpp>
#include <chrono>
#include <iostream>
#include <thread>
@ -66,14 +68,17 @@ int main()
Nz::Vector3f pos = sound.GetPosition() + sound.GetVelocity() * clock.GetElapsedTime().AsSeconds();
sound.SetPosition(pos);
std::cout << "Sound position: " << pos << std::endl;
std::cout << "Sound position: " << pos << std::endl;
// Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap
if (pos.x > Nz::Vector3f::Left().x*-50.f || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Escape))
sound.Stop(); // On arrête le son (Stoppant également la boucle)
// Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap
if (pos.x > Nz::Vector3f::Left().x * -50.f || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Escape))
sound.Stop(); // On arrête le son (Stoppant également la boucle)
clock.Restart();
}
clock.Restart();
}
});
// La boucle du programme (Pour déplacer le son)
return 0;
}

View File

@ -8,35 +8,49 @@
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Platform/Keyboard.hpp>
#include <Nazara/Platform/Platform.hpp>
#include <Nazara/Utility/BasicMainloop.hpp>
#include <chrono>
#include <iostream>
#include <thread>
int main()
{
std::filesystem::path resourceDir = "assets/examples";
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir))
resourceDir = "../.." / resourceDir;
Nz::Modules<Nz::Audio> audio;
Nz::SoundStreamParams streamParams;
streamParams.forceMono = false;
Nz::Music music;
if (!music.OpenFromFile(resourceDir / "Audio/file_example_MP3_700KB.mp3", streamParams))
try
{
std::cout << "Failed to load sound" << std::endl;
std::filesystem::path resourceDir = "assets/examples";
if (!std::filesystem::is_directory(resourceDir) && std::filesystem::is_directory("../.." / resourceDir))
resourceDir = "../.." / resourceDir;
Nz::Modules<Nz::Audio> audio;
Nz::SoundStreamParams streamParams;
streamParams.forceMono = false;
Nz::Music music;
if (!music.OpenFromFile(resourceDir / "Audio/file_example_MP3_700KB.mp3", streamParams))
{
std::cout << "Failed to load sound" << std::endl;
std::getchar();
return EXIT_FAILURE;
}
std::getchar();
return EXIT_FAILURE;
music.Play();
std::cout << "Playing sound..." << std::endl;
Nz::Window window;
Nz::Clock clock;
Nz::BasicMainloop(window, [&] {
});
return EXIT_SUCCESS;
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
}
music.Play();
std::cout << "Playing sound..." << std::endl;
while (music.IsPlaying())
std::this_thread::sleep_for(std::chrono::milliseconds(100));
return EXIT_SUCCESS;
}

View File

@ -1,3 +1,3 @@
target("PlayMusic")
add_deps("NazaraAudio")
add_deps("NazaraAudio", "NazaraUtility", "NazaraPlatform")
add_files("main.cpp")

View File

@ -50,7 +50,7 @@ int main()
Nz::Window& mainWindow = windowing.CreateWindow(Nz::VideoMode(1280, 720), windowTitle);
auto& windowSwapchain = renderSystem.CreateSwapchain(mainWindow);
physSytem.GetPhysWorld().SetGravity({ 0.f, -9.81f, 0.f });
//physSytem.GetPhysWorld().SetGravity({ 0.f, -9.81f, 0.f });
Nz::TextureParams texParams;
texParams.renderDevice = device;
@ -516,6 +516,4 @@ int main()
});
return app.Run();
return EXIT_SUCCESS;
}

View File

@ -5,8 +5,12 @@ end
target("Showcase")
set_group("Examples")
set_kind("binary")
add_deps("NazaraAudio", "NazaraGraphics", "NazaraPhysics2D", "NazaraPhysics3D", "NazaraWidgets")
add_deps("PluginAssimp", { links = {} })
add_deps("NazaraAudio", "NazaraGraphics", "NazaraPhysics2D", "NazaraWidgets")
if has_config("embed_plugins") then
add_deps("PluginAssimp")
else
add_deps("PluginAssimp", { links = {} })
end
add_packages("entt")
add_files("main.cpp")
add_defines("NAZARA_ENTT")

View File

@ -2,7 +2,6 @@
#include <Nazara/Platform.hpp>
#include <Nazara/Graphics.hpp>
#include <Nazara/Math/PidController.hpp>
#include <Nazara/Physics3D.hpp>
#include <Nazara/Renderer.hpp>
#include <Nazara/Utility.hpp>
#include <Nazara/Widgets.hpp>

View File

@ -1,5 +1,5 @@
target("WidgetDemo")
add_deps("NazaraGraphics", "NazaraPhysics3D", "NazaraWidgets")
add_deps("NazaraGraphics", "NazaraWidgets")
add_packages("entt")
add_files("main.cpp")
add_defines("NAZARA_ENTT")

View File

@ -9,6 +9,7 @@
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Config.hpp>
#include <Nazara/Utils/Algorithm.hpp>
#include <string>
#ifdef NAZARA_COMPILER_MSVC
@ -37,6 +38,14 @@ namespace Nz
PluginInterface& operator=(const PluginInterface&) = delete;
PluginInterface& operator=(PluginInterface&&) = delete;
};
#ifdef NAZARA_PLUGINS_STATIC
template<typename T>
struct PluginProvider
{
static_assert(AlwaysFalse<T>(), "unknown plugin");
};
#endif
}
#include <Nazara/Core/PluginInterface.inl>

View File

@ -29,7 +29,9 @@ namespace Nz
void AddSearchDirectory(const std::filesystem::path& directoryPath);
template<typename T> Plugin<T> Load(bool activate = true);
#ifndef NAZARA_PLUGINS_STATIC
GenericPlugin Load(const std::filesystem::path& pluginPath, bool activate = true);
#endif
void RemoveSearchDirectory(const std::filesystem::path& directoryPath);

View File

@ -11,8 +11,16 @@ namespace Nz
template<typename T>
Plugin<T> PluginLoader::Load(bool activate)
{
#ifdef NAZARA_PLUGINS_STATIC
std::unique_ptr<T> pluginInterface = PluginProvider<T>::Instantiate();
if (activate && !pluginInterface->Activate())
throw std::runtime_error("failed to activate plugin");
return Plugin<T>({}, std::move(pluginInterface), activate);
#else
GenericPlugin plugin = Load(Utf8Path(T::Filename), activate);
return std::move(plugin).Cast<T>();
#endif
}
}

View File

@ -34,6 +34,7 @@
#include <Nazara/Utility/AbstractTextDrawer.hpp>
#include <Nazara/Utility/Algorithm.hpp>
#include <Nazara/Utility/Animation.hpp>
#include <Nazara/Utility/BasicMainloop.hpp>
#include <Nazara/Utility/Buffer.hpp>
#include <Nazara/Utility/BufferMapper.hpp>
#include <Nazara/Utility/Config.hpp>

View File

@ -31,6 +31,14 @@ namespace Nz
AssimpPlugin& operator=(const AssimpPlugin&) = delete;
AssimpPlugin& operator=(AssimpPlugin&&) = delete;
};
#ifdef NAZARA_PLUGINS_STATIC
template<>
struct PluginProvider<AssimpPlugin>
{
static std::unique_ptr<AssimpPlugin> Instantiate();
};
#endif
}
#include <Nazara/Utility/Plugins/AssimpPlugin.inl>

View File

@ -939,6 +939,15 @@ namespace
};
}
#ifdef NAZARA_PLUGINS_STATIC
namespace Nz
{
std::unique_ptr<AssimpPlugin> PluginProvider<AssimpPlugin>::Instantiate()
{
return std::make_unique<AssimpPluginImpl>();
}
}
#else
extern "C"
{
NAZARA_EXPORT Nz::PluginInterface* PluginLoad()
@ -954,3 +963,4 @@ extern "C"
return plugin.release();
}
}
#endif

View File

@ -4,7 +4,6 @@ if has_config("assimp") then
add_requires("assimp v5.2.3")
target("PluginAssimp")
set_kind("shared")
set_group("Plugins")
add_rpathdirs("$ORIGIN")

View File

@ -4,7 +4,6 @@ if has_config("ffmpeg") then
add_requires("ffmpeg", { configs = { shared = true } })
target("PluginFFmpeg")
set_kind("shared")
set_group("Plugins")
add_rpathdirs("$ORIGIN")

7
plugins/xmake.lua Normal file
View File

@ -0,0 +1,7 @@
if has_config("embed_plugins") then
set_kind("static")
else
set_kind("shared")
end
includes("*/xmake.lua")

View File

@ -24,6 +24,7 @@ namespace Nz
m_directories.push_back(std::filesystem::absolute(directoryPath));
}
#ifndef NAZARA_PLUGINS_STATIC
GenericPlugin PluginLoader::Load(const std::filesystem::path& pluginPath, bool activate)
{
std::filesystem::path path = pluginPath;
@ -60,6 +61,7 @@ namespace Nz
return GenericPlugin(std::move(library), std::move(pluginInterface), activate);
}
#endif
void PluginLoader::RemoveSearchDirectory(const std::filesystem::path& directoryPath)
{

View File

@ -80,7 +80,7 @@ fn main(input: FragIn) -> FragOut
let color = settings.BaseColor;
const if (HasUV)
color *= TextureOverlay.Sample(input.uv);
color *= TextureOverlay.Sample(input.uv).rrra;
const if (HasColor)
color *= input.color;

View File

@ -129,7 +129,7 @@ fn main(input: VertToFrag) -> FragOut
let color = settings.BaseColor;
const if (HasUV)
color *= TextureOverlay.Sample(input.uv);
color *= TextureOverlay.Sample(input.uv).rrra;
const if (HasColor)
color *= input.color;

View File

@ -115,7 +115,7 @@ fn main(input: VertToFrag) -> FragOut
let color = settings.BaseColor;
const if (HasUV)
color *= TextureOverlay.Sample(input.uv);
color *= TextureOverlay.Sample(input.uv).rrra;
const if (HasColor)
color *= input.color;

View File

@ -10,13 +10,16 @@
#include <Nazara/Utils/Endianness.hpp>
#include <frozen/string.h>
#include <frozen/unordered_set.h>
#define STB_IMAGE_STATIC
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#include <Nazara/Utility/Debug.hpp>
namespace Nz
{
namespace
namespace NAZARA_ANONYMOUS_NAMESPACE
{
int StbiEof(void* userdata)
{
@ -98,6 +101,8 @@ namespace Nz
{
ImageLoader::Entry GetImageLoader_STB()
{
NAZARA_USE_ANONYMOUS_NAMESPACE
ImageLoader::Entry loaderEntry;
loaderEntry.extensionSupport = IsSTBSupported;
loaderEntry.streamLoader = LoadSTB;

View File

@ -17,11 +17,12 @@ int main()
resourceDir = "../.." / resourceDir;
Nz::Renderer::Config rendererConfig;
std::cout << "Run using Vulkan? (y/n)" << std::endl;
rendererConfig.preferredAPI = Nz::RenderAPI::OpenGL;
/*std::cout << "Run using Vulkan? (y/n)" << std::endl;
if (std::getchar() == 'y')
rendererConfig.preferredAPI = Nz::RenderAPI::Vulkan;
else
rendererConfig.preferredAPI = Nz::RenderAPI::OpenGL;
rendererConfig.preferredAPI = Nz::RenderAPI::OpenGL;*/
Nz::Modules<Nz::Graphics> nazara(rendererConfig);
@ -29,7 +30,7 @@ int main()
meshParams.center = true;
meshParams.vertexRotation = Nz::EulerAnglesf(0.f, -90.f, 0.f);
meshParams.vertexScale = Nz::Vector3f(0.002f);
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV_Tangent);
meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout::XYZ_Normal_UV);
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
@ -219,6 +220,14 @@ int main()
framePipeline.GetDebugDrawer().DrawLine(Nz::Vector3f::Zero(), Nz::Vector3f::Forward(), Nz::Color::Blue());
for (const Nz::WorldInstancePtr& worldInstance : { modelInstance, modelInstance2 })
{
Nz::Boxf aabb = model.GetAABB();
aabb.Transform(worldInstance->GetWorldMatrix());
framePipeline.GetDebugDrawer().DrawBox(aabb, Nz::Color::Green);
}
viewerInstance.UpdateViewMatrix(Nz::Matrix4f::TransformInverse(viewerPos, camAngles));
viewerInstance.UpdateEyePosition(viewerPos);

29
wasm.config Normal file
View File

@ -0,0 +1,29 @@
{
arch = "wasm32",
assimp = true,
buildir = "build",
ccache = false,
clean = true,
compile_shaders = true,
embed_plugins = true,
embed_rendererbackends = true,
embed_resources = true,
examples = true,
ffmpeg = false,
host = "windows",
kind = "static",
link_openal = true,
mingw = [[C:\Projets\Perso\Softs\mingw64-11.2]],
mode = "debug",
ndk_stdcxx = true,
network = "public",
override_runtime = true,
plat = "wasm",
proxy_pac = "pac.lua",
qt = "C:/Projets/Perso/Libs/Qt",
shadernodes = false,
tests = false,
theme = "default",
unitybuild = false,
usepch = false
}

View File

@ -0,0 +1,56 @@
diff --git a/include/assimp/defs.h b/include/assimp/defs.h
index 05a5e3fd4..8b90edfca 100644
--- a/include/assimp/defs.h
+++ b/include/assimp/defs.h
@@ -126,7 +126,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* GENBOUNDINGBOXES */
//////////////////////////////////////////////////////////////////////////
-#ifdef _MSC_VER
+#ifdef _WIN32
# undef ASSIMP_API
//////////////////////////////////////////////////////////////////////////
@@ -135,7 +135,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ifdef ASSIMP_BUILD_DLL_EXPORT
# define ASSIMP_API __declspec(dllexport)
# define ASSIMP_API_WINONLY __declspec(dllexport)
-# pragma warning (disable : 4251)
+# ifdef _MSC_VER
+# pragma warning (disable : 4251)
+# endif
//////////////////////////////////////////////////////////////////////////
/* Define 'ASSIMP_DLL' before including Assimp to link to ASSIMP in
@@ -149,6 +151,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# define ASSIMP_API_WINONLY
# endif
+# ifdef _MSC_VER
+
/* Force the compiler to inline a function, if possible
*/
# define AI_FORCE_INLINE __forceinline
@@ -157,6 +161,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* to skip dead paths (e.g. after an assertion evaluated to false). */
# define AI_WONT_RETURN __declspec(noreturn)
+# else
+
+# define AI_FORCE_INLINE inline
+# define AI_WONT_RETURN
+
+# endif
+
#elif defined(SWIG)
/* Do nothing, the relevant defines are all in AssimpSwigPort.i */
@@ -170,7 +181,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# define AI_FORCE_INLINE inline
#endif // (defined _MSC_VER)
-#ifdef __GNUC__
+#if defined(__GNUC__) || defined(__MINGW32__)
# define AI_WONT_RETURN_SUFFIX __attribute__((noreturn))
#else
# define AI_WONT_RETURN_SUFFIX

View File

@ -0,0 +1,14 @@
diff --git a/code/Common/ZipArchiveIOSystem.cpp b/code/Common/ZipArchiveIOSystem.cpp
index e0c9883d2..c748b3255 100644
--- a/code/Common/ZipArchiveIOSystem.cpp
+++ b/code/Common/ZipArchiveIOSystem.cpp
@@ -196,7 +196,9 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) {
zlib_filefunc_def mapping;
mapping.zopen_file = (open_file_func)open;
+#ifdef ZOPENDISK64
mapping.zopendisk_file = (opendisk_file_func)opendisk;
+#endif
mapping.zread_file = (read_file_func)read;
mapping.zwrite_file = (write_file_func)write;
mapping.ztell_file = (tell_file_func)tell;

View File

@ -0,0 +1,27 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f48391edf..66f7b726d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -155,22 +155,6 @@ IF (WIN32)
# "VCRUNTIME140.dll not found. Try reinstalling the app.", but give users
# a choice to opt for the shared runtime if they want.
option(USE_STATIC_CRT "Link against the static runtime libraries." OFF)
-
- # The CMAKE_CXX_FLAGS vars can be overriden by some Visual Studio generators, so we use an alternative
- # global method here:
- if (${USE_STATIC_CRT})
- add_compile_options(
- $<$<CONFIG:>:/MT>
- $<$<CONFIG:Debug>:/MTd>
- $<$<CONFIG:Release>:/MT>
- )
- else()
- add_compile_options(
- $<$<CONFIG:>:/MD>
- $<$<CONFIG:Debug>:/MDd>
- $<$<CONFIG:Release>:/MD>
- )
- endif()
ENDIF()
ENDIF()

View File

@ -0,0 +1,22 @@
diff --git a/code/Common/DefaultIOStream.cpp b/code/Common/DefaultIOStream.cpp
index e30f26acd3..17fc44f9a2 100644
--- a/code/Common/DefaultIOStream.cpp
+++ b/code/Common/DefaultIOStream.cpp
@@ -63,7 +63,7 @@ inline int select_fseek(FILE *file, int64_t offset, int origin) {
-#if defined _WIN64 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
+#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
template <>
inline size_t select_ftell<8>(FILE *file) {
return (size_t)::_ftelli64(file);
@@ -149,7 +149,7 @@ size_t DefaultIOStream::FileSize() const {
//
// See here for details:
// https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file
-#if defined _WIN64 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
+#if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
struct __stat64 fileStat;
//using fileno + fstat avoids having to handle the filename
int err = _fstat64(_fileno(mFile), &fileStat);

View File

@ -0,0 +1,120 @@
package("assimp")
set_homepage("https://assimp.org")
set_description("Portable Open-Source library to import various well-known 3D model formats in a uniform manner")
set_license("BSD-3-Clause")
set_urls("https://github.com/assimp/assimp/archive/$(version).zip",
"https://github.com/assimp/assimp.git")
add_versions("v5.2.5", "5384877d53be7b5bbf50c26ab3f054bec91b3df8614372dcd7240f44f61c509b")
add_versions("v5.2.4", "713e9aa035ae019e5f3f0de1605de308d63538897249a2ba3a2d7d40036ad2b1")
add_versions("v5.2.3", "9667cfc8ddabd5dd5e83f3aebb99dbf232fce99f17b9fe59540dccbb5e347393")
add_versions("v5.2.2", "7b833182b89917b3c6e8aee6432b74870fb71f432cc34aec5f5411bd6b56c1b5")
add_versions("v5.2.1", "636fe5c2cfe925b559b5d89e53a42412a2d2ab49a0712b7d655d1b84c51ed504")
add_versions("v5.1.4", "59a00cf72fa5ceff960460677e2b37be5cd1041e85bae9c02828c27ade7e4160")
add_versions("v5.0.1", "d10542c95e3e05dece4d97bb273eba2dfeeedb37a78fb3417fd4d5e94d879192")
add_patches("v5.0.1", path.join(os.scriptdir(), "patches", "5.0.1", "fix-mingw.patch"), "a3375489e2bbb2dd97f59be7dd84e005e7e9c628b4395d7022a6187ca66b5abb")
add_patches("v5.2.1", path.join(os.scriptdir(), "patches", "5.2.1", "fix_zlib_filefunc_def.patch"), "a9f8a9aa1975888ea751b80c8268296dee901288011eeb1addf518eac40b71b1")
add_patches("v5.2.2", path.join(os.scriptdir(), "patches", "5.2.1", "fix_zlib_filefunc_def.patch"), "a9f8a9aa1975888ea751b80c8268296dee901288011eeb1addf518eac40b71b1")
add_patches("v5.2.3", path.join(os.scriptdir(), "patches", "5.2.1", "fix_zlib_filefunc_def.patch"), "a9f8a9aa1975888ea751b80c8268296dee901288011eeb1addf518eac40b71b1")
add_patches("v5.2.3", path.join(os.scriptdir(), "patches", "5.2.3", "cmake_static_crt.patch"), "3872a69976055bed9e40814e89a24a3420692885b50e9f9438036e8d809aafb4")
add_patches("v5.2.4", path.join(os.scriptdir(), "patches", "5.2.4", "fix_x86_windows_build.patch"), "becb4039c220678cf1e888e3479f8e68d1964c49d58f14c5d247c86b4a5c3293")
if not is_host("windows") then
add_extsources("pkgconfig::assimp")
end
if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::assimp")
elseif is_plat("linux") then
add_extsources("pacman::assimp", "apt::libassimp-dev")
elseif is_plat("macosx") then
add_extsources("brew::assimp")
end
add_configs("build_tools", {description = "Build the supplementary tools for Assimp.", default = false, type = "boolean"})
add_configs("double_precision", {description = "Enable double precision processing.", default = false, type = "boolean"})
add_configs("no_export", {description = "Disable Assimp's export functionality (reduces library size).", default = false, type = "boolean"})
add_configs("android_jniiosysystem", {description = "Enable Android JNI IOSystem support.", default = false, type = "boolean"})
add_configs("asan", {description = "Enable AddressSanitizer.", default = false, type = "boolean"})
add_configs("ubsan", {description = "Enable Undefined Behavior sanitizer.", default = false, type = "boolean"})
add_deps("cmake", "zlib")
if is_plat("windows") then
add_syslinks("advapi32")
end
on_load(function (package)
if not package:gitref() and package:version():le("5.1.0") then
package:add("deps", "irrxml")
end
if package:is_plat("linux", "macosx") and package:config("shared") then
package:add("links", "assimp")
end
end)
on_install("windows", "linux", "macosx", "mingw", "wasm", function (package)
local configs = {"-DASSIMP_BUILD_SAMPLES=OFF",
"-DASSIMP_BUILD_TESTS=OFF",
"-DASSIMP_BUILD_DOCS=OFF",
"-DASSIMP_BUILD_FRAMEWORK=OFF",
"-DASSIMP_INSTALL_PDB=ON",
"-DASSIMP_INJECT_DEBUG_POSTFIX=ON",
"-DASSIMP_BUILD_ZLIB=ON",
"-DSYSTEM_IRRXML=ON",
"-DASSIMP_WARNINGS_AS_ERRORS=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
local function add_config_arg(config_name, cmake_name)
table.insert(configs, "-D" .. cmake_name .. "=" .. (package:config(config_name) and "ON" or "OFF"))
end
add_config_arg("shared", "BUILD_SHARED_LIBS")
add_config_arg("double_precision", "ASSIMP_DOUBLE_PRECISION")
add_config_arg("no_export", "ASSIMP_NO_EXPORT")
add_config_arg("asan", "ASSIMP_ASAN")
add_config_arg("ubsan", "ASSIMP_UBSAN")
if package:is_plat("android") then
add_config_arg("android_jniiosysystem", "ASSIMP_ANDROID_JNIIOSYSTEM")
end
if package:is_plat("windows", "linux", "macosx", "mingw") then
add_config_arg("build_tools", "ASSIMP_BUILD_ASSIMP_TOOLS")
else
table.insert(configs, "-DASSIMP_BUILD_ASSIMP_TOOLS=OFF")
end
if not package:gitref() and package:version():lt("v5.2.4") then
-- ASSIMP_WARNINGS_AS_ERRORS is not supported before v5.2.4
if package:is_plat("windows") then
io.replace("code/CMakeLists.txt", "TARGET_COMPILE_OPTIONS(assimp PRIVATE /W4 /WX)", "", {plain = true})
else
io.replace("code/CMakeLists.txt", "TARGET_COMPILE_OPTIONS(assimp PRIVATE -Werror)", "", {plain = true})
end
end
if package:is_plat("mingw") and package:version():lt("v5.1.5") then
-- CMAKE_COMPILER_IS_MINGW has been removed: https://github.com/assimp/assimp/pull/4311
io.replace("CMakeLists.txt", "CMAKE_COMPILER_IS_MINGW", "MINGW", {plain = true})
end
import("package.tools.cmake").install(package, configs)
-- copy pdb
if package:is_plat("windows") then
if package:config("shared") then
os.trycp(path.join(package:buildir(), "bin", "**.pdb"), package:installdir("bin"))
else
os.trycp(path.join(package:buildir(), "lib", "**.pdb"), package:installdir("lib"))
end
end
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <cassert>
void test() {
Assimp::Importer importer;
}
]]}, {configs = {languages = "c++11"}, includes = "assimp/Importer.hpp"}))
end)

View File

@ -0,0 +1,64 @@
add_rules("mode.debug", "mode.release")
option("enable_tools")
set_default(false)
set_showmenu(true)
target("bz2")
set_kind("$(kind)")
set_languages("c89")
add_headerfiles("bzlib.h")
add_files("blocksort.c")
add_files("bzlib.c")
add_files("compress.c")
add_files("crctable.c")
add_files("decompress.c")
add_files("huffman.c")
add_files("randtable.c")
if is_plat("windows") and is_kind("shared") then
set_filename("libbz2.dll")
add_files("libbz2.def")
end
if is_plat("wasm") then
add_defines("BZ_STRICT_ANSI")
end
if has_config("enable_tools") then
target("bzip2")
set_kind("binary")
add_deps("bz2")
add_files("bzip2.c")
after_install(function (target)
-- copy/link additional executables/scripts (behavior is altered by checking the program name)
if target:is_plat("windows", "mingw") then
local binarydir = path.join(target:installdir(), "bin")
os.vcp(path.join(binarydir, "bzip2.exe"), path.join(binarydir, "bzcat.exe"))
os.vcp(path.join(binarydir, "bzip2.exe"), path.join(binarydir, "bunzip2.exe"))
else
local binarydir = path.join(target:installdir(), "bin")
os.ln(path.join(binarydir, "bzip2"), path.join(binarydir, "bzcat"))
os.ln(path.join(binarydir, "bzip2"), path.join(binarydir, "bunzip2"))
-- copy shell scripts
os.vcp("bzdiff", binarydir)
os.vcp("bzgrep", binarydir)
os.vcp("bzmore", binarydir)
-- and renamed copies
os.ln(path.join(binarydir, "bzdiff"), path.join(binarydir, "bzcmp"))
os.ln(path.join(binarydir, "bzgrep"), path.join(binarydir, "bzegrep"))
os.ln(path.join(binarydir, "bzgrep"), path.join(binarydir, "bzfgrep"))
os.ln(path.join(binarydir, "bzmore"), path.join(binarydir, "bzless"))
end
end)
target("bzip2recover")
set_kind("binary")
add_deps("bz2")
add_files("bzip2recover.c")
end

View File

@ -0,0 +1,36 @@
package("bzip2")
set_homepage("https://sourceware.org/bzip2/")
set_description("Freely available, patent free, high-quality data compressor.")
add_urls("https://sourceware.org/pub/bzip2/bzip2-$(version).tar.gz")
add_versions("1.0.8", "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269")
if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::bzip2")
elseif is_plat("linux") then
add_extsources("pacman::bzip2", "apt::libbz2-dev")
elseif is_plat("macosx") then
add_extsources("brew::bzip2")
end
on_install("linux", "macosx", "windows", "android", "iphoneos", "cross", "bsd", "mingw", "wasm", function (package)
local configs = {}
if not package:is_plat("cross", "iphoneos", "android", "wasm") then
configs.enable_tools = true
package:addenv("PATH", "bin")
end
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
import("package.tools.xmake").install(package, configs)
end)
on_test(function (package)
if not package:is_plat("cross", "iphoneos", "android", "wasm") then
os.vrun("bunzip2 --help")
os.vrun("bzcat --help")
os.vrun("bzip2 --help")
end
assert(package:has_cfuncs("BZ2_bzCompressInit", {includes = "bzlib.h"}))
end)

View File

@ -0,0 +1,100 @@
package("libpng")
set_homepage("http://www.libpng.org/pub/png/libpng.html")
set_description("The official PNG reference library")
set_license("libpng-2.0")
set_urls("https://github.com/glennrp/libpng/archive/$(version).zip",
"https://github.com/glennrp/libpng.git")
add_versions("v1.6.37", "c2c50c13a727af73ecd3fc0167d78592cf5e0bca9611058ca414b6493339c784")
add_versions("v1.6.36", "6274d3f761cc80f7f6e2cde6c07bed10c00bc4ddd24c4f86e25eb51affa1664d")
add_versions("v1.6.35", "3d22d46c566b1761a0e15ea397589b3a5f36ac09b7c785382e6470156c04247f")
add_versions("v1.6.34", "7ffa5eb8f9f3ed23cf107042e5fec28699718916668bbce48b968600475208d3")
add_deps("zlib")
if is_plat("linux") then
add_syslinks("m")
end
if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::libpng")
elseif is_plat("linux") then
add_extsources("pacman::libpng", "apt::libpng-dev")
elseif is_plat("macosx") then
add_extsources("brew::libpng")
end
on_install("windows", "mingw", "android", "iphoneos", "cross", "bsd", "wasm", function (package)
io.writefile("xmake.lua", [[
add_rules("mode.debug", "mode.release")
add_requires("zlib")
target("png")
set_kind("$(kind)")
add_files("*.c|example.c|pngtest.c")
if is_arch("x86", "x64", "i386", "x86_64") then
add_files("intel/*.c")
add_defines("PNG_INTEL_SSE_OPT=1")
add_vectorexts("sse", "sse2")
elseif is_arch("arm.*") then
add_files("arm/*.c")
if is_plat("windows") then
add_defines("PNG_ARM_NEON_OPT=1")
add_defines("PNG_ARM_NEON_IMPLEMENTATION=1")
else
add_files("arm/*.S")
add_defines("PNG_ARM_NEON_OPT=2")
end
elseif is_arch("mips.*") then
add_files("mips/*.c")
add_defines("PNG_MIPS_MSA_OPT=2")
elseif is_arch("ppc.*") then
add_files("powerpc/*.c")
add_defines("PNG_POWERPC_VSX_OPT=2")
end
add_headerfiles("*.h")
add_packages("zlib")
if is_kind("shared") and is_plat("windows") then
add_defines("PNG_BUILD_DLL")
end
]])
local configs = {}
if package:config("shared") then
configs.kind = "shared"
elseif not package:is_plat("windows", "mingw") and package:config("pic") ~= false then
configs.cxflags = "-fPIC"
end
if package:is_plat("android") and package:is_arch("armeabi-v7a") then
io.replace("arm/filter_neon.S", ".func", ".hidden", {plain = true})
io.replace("arm/filter_neon.S", ".endfunc", "", {plain = true})
end
os.cp("scripts/pnglibconf.h.prebuilt", "pnglibconf.h")
import("package.tools.xmake").install(package, configs)
end)
on_install("macosx", "linux", function (package)
local configs = {}
table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
if package:config("pic") ~= false then
table.insert(configs, "--with-pic")
end
local cppflags = {}
local ldflags = {}
for _, dep in ipairs(package:orderdeps()) do
local fetchinfo = dep:fetch()
if fetchinfo then
for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
table.insert(cppflags, "-I" .. includedir)
end
for _, linkdir in ipairs(fetchinfo.linkdirs) do
table.insert(ldflags, "-L" .. linkdir)
end
end
end
import("package.tools.autoconf").install(package, configs, {cppflags = cppflags, ldflags = ldflags})
end)
on_test(function (package)
assert(package:has_cfuncs("png_create_read_struct", {includes = "png.h"}))
end)

View File

@ -0,0 +1,171 @@
package("libsdl")
set_homepage("https://www.libsdl.org/")
set_description("Simple DirectMedia Layer")
if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::SDL2")
elseif is_plat("linux") then
add_extsources("pacman::sdl2", "apt::libsdl2-dev")
elseif is_plat("macosx") then
add_extsources("brew::sdl2")
end
set_license("zlib")
add_urls("https://www.libsdl.org/release/SDL2-$(version).zip",
"https://github.com/libsdl-org/SDL/releases/download/release-$(version)/SDL2-$(version).zip", { alias = "archive" })
add_urls("https://github.com/libsdl-org/SDL.git", { alias = "github" })
add_versions("archive:2.0.8", "e6a7c71154c3001e318ba7ed4b98582de72ff970aca05abc9f45f7cbdc9088cb")
add_versions("archive:2.0.12", "476e84d6fcbc499cd1f4a2d3fd05a924abc165b5d0e0d53522c9604fe5a021aa")
add_versions("archive:2.0.14", "2c1e870d74e13dfdae870600bfcb6862a5eab4ea5b915144aff8d75a0f9bf046")
add_versions("archive:2.0.16", "010148866e2226e5469f2879425d28ff7c572c736cb3fb65a0604c3cde6bfab9")
add_versions("archive:2.0.18", "2d96cc82020341f7f5957c42001ad526e15fbb7056be8a74dab302483e97aa24")
add_versions("archive:2.0.20", "cc8b16a326eb082c1f48ca30fdf471acfd2334b69bd7527e65ac58369013a1ba")
add_versions("archive:2.0.22", "9a81ab724e6dcef96c61a4a2ebe7758e5b8bb191794650d276a20d5148fbd50c")
add_versions("archive:2.24.0", "4b065503d45652d5f65d807fe98c757c73af2968727945b596861995bc3b69c2")
add_versions("archive:2.24.2", "7fae98ac4e7b39eb2511fc27c2e84b220ac69b5296ff41f833b967c891f9d2ac")
add_versions("archive:2.26.0", "4a181f158f88676816e4993d7e97e7b48ef273aa6f4e2909c6a85497e9af3e9f")
add_versions("archive:2.26.1", "c038222fcac6ccc448daaa3febcae93fdac401aed12fd60da3b7939529276b1b")
add_versions("github:2.0.8", "release-2.0.8")
add_versions("github:2.0.12", "release-2.0.12")
add_versions("github:2.0.14", "release-2.0.14")
add_versions("github:2.0.16", "release-2.0.16")
add_versions("github:2.0.18", "release-2.0.18")
add_versions("github:2.0.20", "release-2.0.20")
add_versions("github:2.0.22", "release-2.0.22")
add_versions("github:2.24.0", "release-2.24.0")
add_versions("github:2.24.2", "release-2.24.2")
add_versions("github:2.26.0", "release-2.26.0")
add_versions("github:2.26.1", "release-2.26.1")
if is_plat("macosx") then
add_frameworks("OpenGL", "CoreVideo", "CoreAudio", "AudioToolbox", "Carbon", "CoreGraphics", "ForceFeedback", "Metal", "AppKit", "IOKit", "CoreFoundation", "Foundation")
add_syslinks("iconv")
elseif is_plat("linux", "bsd") then
if is_plat("bsd") then
add_deps("libusb")
add_syslinks("usbhid")
end
add_syslinks("pthread", "dl")
elseif is_plat("windows", "mingw") then
add_syslinks("gdi32", "user32", "winmm", "shell32")
end
add_includedirs("include", "include/SDL2")
add_configs("use_sdlmain", {description = "Use SDL_main entry point", default = true, type = "boolean"})
if is_plat("linux") then
add_configs("with_x", {description = "Enables X support (requires it on the system)", default = true, type = "boolean"})
end
on_load(function (package)
if package.components then
if package:config("use_sdlmain") then
package:add("components", "main")
end
package:add("components", "lib")
else
if package:config("use_sdlmain") then
package:add("links", "SDL2main", "SDL2")
package:add("defines", "SDL_MAIN_HANDLED")
else
package:add("links", "SDL2")
end
end
if package:is_plat("linux") and package:config("with_x") then
package:add("deps", "libxext", {private = true})
end
if package:is_plat("macosx") and package:version():ge("2.0.14") then
package:add("frameworks", "CoreHaptics", "GameController")
end
end)
on_component = on_component or function() end
on_component("main", function (package, component)
component:add("links", "SDL2main")
component:add("defines", "SDL_MAIN_HANDLED")
component:add("deps", "lib")
end)
on_component("main", function (package, component)
component:add("links", "SDL2")
end)
on_fetch("linux", "macosx", "bsd", function (package, opt)
if opt.system then
-- use sdl2-config
local sdl2conf = try {function() return os.iorunv("sdl2-config", {"--version", "--cflags", "--libs"}) end}
if sdl2conf then
sdl2conf = os.argv(sdl2conf)
local sdl2ver = table.remove(sdl2conf, 1)
local result = {version = sdl2ver}
for _, flag in ipairs(sdl2conf) do
if flag:startswith("-L") and #flag > 2 then
-- get linkdirs
local linkdir = flag:sub(3)
if linkdir and os.isdir(linkdir) then
result.linkdirs = result.linkdirs or {}
table.insert(result.linkdirs, linkdir)
end
elseif flag:startswith("-I") and #flag > 2 then
-- get includedirs
local includedir = flag:sub(3)
if includedir and os.isdir(includedir) then
result.includedirs = result.includedirs or {}
table.insert(result.includedirs, includedir)
end
elseif flag:startswith("-l") and #flag > 2 then
-- get links
local link = flag:sub(3)
result.links = result.links or {}
table.insert(result.links, link)
elseif flag:startswith("-D") and #flag > 2 then
-- get defines
local define = flag:sub(3)
result.defines = result.defines or {}
table.insert(result.defines, define)
end
end
return result
end
-- finding using sdl2-config didn't work, fallback on pkgconfig
if package.find_package then
return package:find_package("pkgconfig::sdl2", opt)
else
return find_package("pkgconfig::sdl2", opt)
end
end
end)
on_install(function (package)
local configs = {}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DLIBTYPE=" .. (package:config("shared") and "SHARED" or "STATIC"))
local opt
if package:is_plat("linux") then
local cflags = {}
opt = opt or {}
opt.cflags = cflags
for _, depname in ipairs({"libxext", "libx11", "xorgproto"}) do
local dep = package:dep(depname)
if dep then
local depfetch = dep:fetch()
if depfetch then
for _, includedir in ipairs(depfetch.includedirs or depfetch.sysincludedirs) do
table.join2(cflags, "-I" .. includedir)
end
end
end
end
elseif package:is_plat("bsd") then
opt = opt or {}
opt.packagedeps = "libusb"
end
import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
assert(package:has_cfuncs("SDL_Init", {includes = "SDL2/SDL.h", configs = {defines = "SDL_MAIN_HANDLED"}}))
end)

View File

@ -74,6 +74,10 @@ local modules = {
-- NazaraMath is header-only, make it part of the core project
add_headerfiles("include/(Nazara/Math/**.hpp)", "include/(Nazara/Math/**.inl)")
if has_config("embed_plugins") then
add_defines("NAZARA_PLUGINS_STATIC", { public = true })
end
if is_plat("windows", "mingw") then
add_syslinks("ole32")
elseif is_plat("linux") then
@ -131,8 +135,8 @@ local modules = {
add_defines("SDL_VIDEO_DRIVER_COCOA=1")
add_packages("libx11", { links = {} }) -- we only need X11 headers
elseif is_plat("wasm") then
add_cxflags("-s USE_SDL=2")
add_ldflags("-s USE_SDL=2", { public = true })
add_cxflags("-sUSE_SDL=2")
add_ldflags("-sUSE_SDL=2", { public = true })
end
end
},
@ -151,13 +155,7 @@ local modules = {
},
Utility = {
Deps = {"NazaraCore"},
Packages = {"entt", "freetype", "frozen", "ordered_map", "stb"},
Custom = function()
if is_plat("wasm") then
add_cxflags("-s USE_FREETYPE=1")
add_ldflags("-s USE_FREETYPE=1", { public = true })
end
end
Packages = {"entt", "freetype", "frozen", "ordered_map", "stb"}
},
Widgets = {
Deps = {"NazaraGraphics"},
@ -183,6 +181,7 @@ includes("xmake/**.lua")
option("compile_shaders", { description = "Compile nzsl shaders into an includable binary version", default = true })
option("embed_rendererbackends", { description = "Embed renderer backend code into NazaraRenderer instead of loading them dynamically", default = false })
option("embed_resources", { description = "Turn builtin resources into includable headers", default = true })
option("embed_plugins", { description = "Embed enabled plugins code as static libraries", default = false })
option("link_openal", { description = "Link OpenAL in the executable instead of dynamically loading it", default = false })
option("override_runtime", { description = "Override vs runtime to MD in release and MDd in debug", default = true })
option("usepch", { description = "Use precompiled headers to speedup compilation", default = false })
@ -192,13 +191,16 @@ set_project("NazaraEngine")
set_xmakever("2.7.3")
add_requires("chipmunk2d", "dr_wav", "entt 3.10.1", "fmt", "frozen", "kiwisolver", "libflac", "minimp3", "ordered_map", "stb")
add_requires("freetype", { configs = { bzip2 = true, png = true, woff2 = true, zlib = true, debug = is_mode("debug") } })
add_requires("libvorbis", { configs = { with_vorbisenc = false } })
if is_plat("wasm") then
-- Enable some flags for emscripten
add_cxflags("-g", "-sNO_DISABLE_EXCEPTION_CATCHING")
add_ldflags("-g", "-sNO_DISABLE_EXCEPTION_CATCHING", "-sALLOW_MEMORY_GROWTH", "-sWASM_BIGINT")
add_ldflags("-sERROR_ON_WASM_CHANGES_AFTER_LINK", { force = true })
add_cxflags("-sNO_DISABLE_EXCEPTION_CATCHING")
add_ldflags("-sNO_DISABLE_EXCEPTION_CATCHING", "-sALLOW_MEMORY_GROWTH", "-sWASM_BIGINT")
if is_mode("debug") then
add_ldflags("-sERROR_ON_WASM_CHANGES_AFTER_LINK", { force = true })
end
-- we can't use wasm nzsl to compile shaders
if has_config("compile_shaders") then
@ -207,7 +209,6 @@ if is_plat("wasm") then
else
-- these libraries have ports in emscripten
add_requires("libsdl")
add_requires("freetype", { configs = { bzip2 = true, png = true, woff2 = true, zlib = true, debug = is_mode("debug") } })
add_requires("openal-soft", { configs = { shared = true }})
-- these libraries aren't supported on emscripten
@ -215,6 +216,7 @@ else
add_requires("newtondynamics3", { debug = is_plat("windows") and is_mode("debug") }) -- Newton doesn't like compiling in Debug on Linux
end
add_repositories("local-repo xmake-repo")
add_repositories("nazara-engine-repo https://github.com/NazaraEngine/xmake-repo")
add_requires("nazarautils")
add_requires("nzsl", { debug = is_mode("debug"), configs = { with_symbols = not is_mode("release"), shared = not is_plat("wasm") } })
@ -254,15 +256,22 @@ elseif is_mode("releasedbg", "release") then
add_vectorexts("sse", "sse2", "sse3", "ssse3")
end
if is_kind("static") then
add_defines("NAZARA_STATIC")
end
add_includedirs("include")
add_sysincludedirs("thirdparty/include")
set_languages("c89", "cxx17")
set_rundir("./bin/$(plat)_$(arch)_$(mode)")
set_symbols("debug", "hidden")
set_targetdir("./bin/$(plat)_$(arch)_$(mode)")
set_warnings("allextra")
if not is_mode("release") then
set_symbols("debug", "hidden")
end
if is_mode("debug") then
add_defines("NAZARA_DEBUG")
end
@ -391,4 +400,4 @@ end
includes("tools/*.lua")
includes("tests/*.lua")
includes("examples/*.lua")
includes("plugins/*/xmake.lua")
includes("plugins/*.lua")