From 152fcc35c71ced75ac8d4dbd08c367c2ddd5585d Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Tue, 18 Aug 2026 18:35:23 +0800 Subject: [PATCH 1/2] feat(mikktspace): add LLAR formula --- .../CMakeLists.txt | 20 ++++ .../mikktspace_llar.gox | 111 ++++++++++++++++++ mmikk/MikkTSpace/versions.json | 4 + 3 files changed, 135 insertions(+) create mode 100644 mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/CMakeLists.txt create mode 100644 mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/mikktspace_llar.gox create mode 100644 mmikk/MikkTSpace/versions.json diff --git a/mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/CMakeLists.txt b/mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/CMakeLists.txt new file mode 100644 index 0000000..4d45d6e --- /dev/null +++ b/mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.15) +project(mikktspace LANGUAGES C) + +add_library(mikktspace ${MIKKTSPACE_SRC_DIR}/mikktspace.c) +target_include_directories(mikktspace PUBLIC ${MIKKTSPACE_SRC_DIR}) +set_target_properties(mikktspace PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + +include(CheckFunctionExists) +check_function_exists(pow HAVE_MATH_SYSTEM) +if(NOT HAVE_MATH_SYSTEM) + target_link_libraries(mikktspace PRIVATE m) +endif() + +include(GNUInstallDirs) +install(TARGETS mikktspace + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install(FILES ${MIKKTSPACE_SRC_DIR}/mikktspace.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/mikktspace_llar.gox b/mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/mikktspace_llar.gox new file mode 100644 index 0000000..801f1b8 --- /dev/null +++ b/mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/mikktspace_llar.gox @@ -0,0 +1,111 @@ +import ( + "os" + "path/filepath" + "slices" + "strings" +) + +const consumerSource = `#include +#include + +static int GetNumFaces(const SMikkTSpaceContext *pContext) +{ + return 0; +} + +int main() +{ + SMikkTSpaceInterface sInterface = {NULL}; + sInterface.m_getNumFaces = GetNumFaces; + + SMikkTSpaceContext sContext = {NULL}; + sContext.m_pInterface = &sInterface; + + genTangSpaceDefault(&sContext); + + return 0; +} +` + +id "mmikk/MikkTSpace" + +fromVer "3e895b49d05ea07e4c2133156cfa94369e19e409" + +defaults { + "shared": "OFF", + "fPIC": "ON", +} + +filter => { + for name, values in target.options { + if name != "shared" && name != "fPIC" { + return false + } + for value in values { + if value != "ON" && value != "OFF" { + return false + } + } + } + return true +} + +onBuild ctx => { + installDir := ctx.outputDir + cmakeLists := ctx.Proj.readFile("3e895b49d05ea07e4c2133156cfa94369e19e409/CMakeLists.txt")! + os.writeFile(filepath.join(ctx.SourceDir, "CMakeLists.txt"), cmakeLists, 0o644)! + + shared := target.options["shared"][0] == "ON" + fPIC := target.options["fPIC"][0] == "ON" + c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) + c.define "MIKKTSPACE_SRC_DIR", ctx.SourceDir + c.defineBool "BUILD_SHARED_LIBS", shared + c.defineBool "CMAKE_POSITION_INDEPENDENT_CODE", fPIC + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + os.writeFile(filepath.join(licenseDir, "LICENSE"), os.readFile(filepath.join(ctx.SourceDir, "mikktspace.h"))!, 0o644)! + + flags := []string{ + "-I" + filepath.join(installDir, "include"), + "-L" + filepath.join(installDir, "lib"), + "-lmikktspace", + } + if !shared && (slices.contains(target.require["os"], "linux") || slices.contains(target.require["os"], "freebsd")) { + flags <- "-lm" + } + ctx.setMetadata strings.join(flags, " ") +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + sourcePath := filepath.join(testDir, "consumer.c") + os.writeFile(sourcePath, []byte(consumerSource), 0o644)! + binary := filepath.join(testDir, "consumer") + shared := target.options["shared"][0] == "ON" + args := []string{ + "-I" + filepath.join(installDir, "include"), + sourcePath, + "-L" + filepath.join(installDir, "lib"), + "-lmikktspace", + "-o", binary, + } + if !shared && (slices.contains(target.require["os"], "linux") || slices.contains(target.require["os"], "freebsd")) { + args <- "-lm" + } + exec "cc", args... + lastErr! + + if shared { + os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! + os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! + } + exec binary + lastErr! +} diff --git a/mmikk/MikkTSpace/versions.json b/mmikk/MikkTSpace/versions.json new file mode 100644 index 0000000..835acd0 --- /dev/null +++ b/mmikk/MikkTSpace/versions.json @@ -0,0 +1,4 @@ +{ + "path": "mmikk/MikkTSpace", + "deps": {} +} From 11cff6976bac73a542fb9caeacd95f81052ec07e Mon Sep 17 00:00:00 2001 From: Rick Guo Date: Wed, 19 Aug 2026 17:27:47 +0800 Subject: [PATCH 2/2] fix(mikktspace): publish complete pkg-config metadata --- .../mikktspace_llar.gox | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/mikktspace_llar.gox b/mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/mikktspace_llar.gox index 801f1b8..e6fb4fe 100644 --- a/mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/mikktspace_llar.gox +++ b/mmikk/MikkTSpace/3e895b49d05ea07e4c2133156cfa94369e19e409/mikktspace_llar.gox @@ -1,8 +1,6 @@ import ( "os" "path/filepath" - "slices" - "strings" ) const consumerSource = `#include @@ -69,15 +67,22 @@ onBuild ctx => { os.mkdirAll(licenseDir, 0o755)! os.writeFile(filepath.join(licenseDir, "LICENSE"), os.readFile(filepath.join(ctx.SourceDir, "mikktspace.h"))!, 0o644)! - flags := []string{ - "-I" + filepath.join(installDir, "include"), - "-L" + filepath.join(installDir, "lib"), - "-lmikktspace", - } - if !shared && (slices.contains(target.require["os"], "linux") || slices.contains(target.require["os"], "freebsd")) { - flags <- "-lm" - } - ctx.setMetadata strings.join(flags, " ") + pcDir := filepath.join(installDir, "lib", "pkgconfig") + os.mkdirAll(pcDir, 0o755)! + pc := `prefix=$${pcfiledir}/../.. +includedir=$${prefix}/include +libdir=$${prefix}/lib + +Name: mikktspace +Description: MikkTSpace tangent-space generation library +Version: 3e895b49d05ea07e4c2133156cfa94369e19e409 +Libs: -L$${libdir} -lmikktspace -lm +Cflags: -I$${includedir} +` + os.writeFile(filepath.join(pcDir, "mikktspace.pc"), []byte(pc), 0o644)! + + pkgconfig.use installDir + ctx.setMetadata pkgconfig.lookup("mikktspace")! } onTest ctx => { @@ -88,24 +93,19 @@ onTest ctx => { sourcePath := filepath.join(testDir, "consumer.c") os.writeFile(sourcePath, []byte(consumerSource), 0o644)! binary := filepath.join(testDir, "consumer") - shared := target.options["shared"][0] == "ON" - args := []string{ - "-I" + filepath.join(installDir, "include"), - sourcePath, - "-L" + filepath.join(installDir, "lib"), - "-lmikktspace", - "-o", binary, - } - if !shared && (slices.contains(target.require["os"], "linux") || slices.contains(target.require["os"], "freebsd")) { - args <- "-lm" - } - exec "cc", args... - lastErr! + pkgconfig.use installDir + flags := pkgconfig.lookup("mikktspace")! + flagsFile := filepath.join(testDir, "mikktspace.flags") + os.writeFile(flagsFile, []byte(flags), 0o644)! + + args := []string{sourcePath, "-o", binary, "@" + flagsFile} + cc! args... + + shared := target.options["shared"][0] == "ON" if shared { os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! } - exec binary - lastErr! + exec! binary }