Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add microsoft gltf-sdk #6159

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions packages/g/gltf-sdk/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package("gltf-sdk")
set_homepage("https://github.com/microsoft/glTF-SDK")
set_description("glTF-SDK is a C++ Software Development Kit for glTF (GL Transmission Format -https://github.com/KhronosGroup/glTF).")
set_license("MIT")

add_urls("https://github.com/microsoft/glTF-SDK/archive/refs/tags/$(version).tar.gz",
"https://github.com/microsoft/glTF-SDK.git", {
version = function (version)
return "r" .. version:gsub("+", ".")
end
})

add_versions("1.9.6+0", "f3049d2b8ecebb914f634496918ab645f7ce452a67a5b4210e7354dc7c0059ab")

add_deps("cmake")
add_deps("rapidjson")

on_install(function (package)
local configs = {
"-DENABLE_UNIT_TESTS=OFF",
"-DENABLE_SAMPLES=OFF",
"-DRAPIDJSON_BUILD_DOC=OFF",
"-DRAPIDJSON_BUILD_EXAMPLES=OFF",
"-DRAPIDJSON_BUILD_TESTS=OFF",
}
Comment on lines +19 to +25
Copy link
Contributor

@luadebug luadebug Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local configs = {
"-DENABLE_UNIT_TESTS=OFF",
"-DENABLE_SAMPLES=OFF",
"-DRAPIDJSON_BUILD_DOC=OFF",
"-DRAPIDJSON_BUILD_EXAMPLES=OFF",
"-DRAPIDJSON_BUILD_TESTS=OFF",
}
os.rm("External")
io.replace("Build/CMake/Modules/GLTFPlatform.cmake", "elseif (MSVC)", "elseif (MSVC OR MINGW)", {plain = true})
io.replace("Build/CMake/Modules/GLTFPlatform.cmake", "install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${PROJECT_NAME}.pdb DESTINATION ${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME})", "", {plain = true})
io.replace("Build/CMake/Modules/GLTFPlatform.cmake", "${CMAKE_SOURCE_DIR}/Built/Out/${platform}/$<CONFIG>/${PROJECT_NAME}", "lib", {plain = true})
io.replace("GLTFSDK/CMakeLists.txt",
"CreateGLTFInstallTargets(GLTFSDK ${Platform})",
"CreateGLTFInstallTargets(GLTFSDK ${Platform})\ninstall(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Inc/GLTFSDK DESTINATION ${CMAKE_INSTALL_PREFIX}/include)", {plain = true})
io.replace("CMakeLists.txt", "/MP", "", {plain = true})
io.replace("CMakeLists.txt", "if(NOT IOS)", "if(1)", {plain = true})
io.replace("CMakeLists.txt", "if(NOT RapidJSON_FOUND)", "if(0)", {plain = true})
io.replace("CMakeLists.txt", "find_package(GTest CONFIG)", "", {plain = true})
io.replace("CMakeLists.txt", "if(NOT GTest_FOUND)", "if(0)", {plain = true})
local configs = {
"-DENABLE_UNIT_TESTS=OFF",
"-DENABLE_SAMPLES=OFF",
}

Dunno seems its good to limit linux because it uses powershell OR MAYBE EVEN MORE IDK.

find_program(POWERSHELL_PATH NAMES pwsh powershell NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH)

add_custom_command(
    OUTPUT ${CMAKE_BINARY_DIR}/GeneratedFiles/SchemaJson.h
    COMMAND ${POWERSHELL_PATH}

But we can make binary package of this maybe? https://github.com/PowerShell/PowerShell/releases/tag/v7.4.6
Or using existing grabbing mechanism from nuget, but im not sure it will be fine for linux and others %_%
https://www.nuget.org/packages/PowerShell/#supportedframeworks-body-tab
Yet without pwsh/powershell packaged its

on_install("windows", "mingw@windows,msys", function (package)

I believe...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use binary package for windows. but only for windows. There will be compatibility issues on Linux

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, I will take a look.

table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
import("package.tools.cmake").install(package, configs)
end)

on_test(function (package)
assert(package:check_cxxsnippets({test = [[
void test() {
using namespace Microsoft::glTF;
const Color3 c1 = { 0.0f, 0.0f, 0.0f };
Color3 c = c1.ToGamma();
}
]]}, {configs = {languages = "c++14"}, includes = {"GLTFSDK/Color.h"}}))
end)
Loading