diff options
| author | ruki <[email protected]> | 2023-04-29 21:46:33 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-04-29 21:46:33 +0800 |
| commit | 5075fc82edcb714df4f34f4dec34268ee2914d49 (patch) | |
| tree | 381c95f16e2c9e699b1115d9dae8f211d3a01c77 /xmake/rules/xcode | |
| parent | 63e4d08d20a935acf47ac86beb587e9261b78506 (diff) | |
improve metal rule #3694
Diffstat (limited to 'xmake/rules/xcode')
| -rw-r--r-- | xmake/rules/xcode/metal/xmake.lua | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/xmake/rules/xcode/metal/xmake.lua b/xmake/rules/xcode/metal/xmake.lua index 9484b8fea..bf041c305 100644 --- a/xmake/rules/xcode/metal/xmake.lua +++ b/xmake/rules/xcode/metal/xmake.lua @@ -23,37 +23,17 @@ -- @see https://developer.apple.com/documentation/metal/libraries/building_a_library_with_metal_s_command-line_tools -- rule("xcode.metal") - - -- support add_files("*.metal") set_extensions(".metal") - on_load(function (target) - local cross - if target:is_plat("macosx") then - cross = "xcrun -sdk macosx " - elseif target:is_plat("iphoneos") then - cross = target:is_arch("i386", "x86_64") and "xcrun -sdk iphonesimulator " or "xcrun -sdk iphoneos " - elseif target:is_plat("watchos") then - cross = target:is_arch("i386") and "xcrun -sdk watchsimulator " or "xcrun -sdk watchos " - elseif target:is_plat("appletvos") then - cross = target:is_arch("i386", "x86_64") and "xcrun -sdk appletvsimulator " or "xcrun -sdk appletvos " - else - raise("unknown platform for xcode!") - end - target:data_set("xcode.metal.cross", cross) - end) - -- build *.metal to *.air on_buildcmd_file(function (target, batchcmds, sourcefile, opt) -- get metal - import("core.tool.toolchain") import("lib.detect.find_tool") - local cross = target:data("xcode.metal.cross") - local metal = assert(find_tool("metal", {program = cross .. " metal"}), "metal command not found!") + local xcode = assert(target:toolchain("xcode"), "xcode not fount!") + local metal = assert(find_tool("metal", {program = path.join(xcode:bindir(), "metal")}), "metal command not found!") -- get xcode toolchain - local xcode = toolchain.load("xcode", {plat = target:plat(), arch = target:arch()}) local target_minver = xcode:config("target_minver") local xcode_sysroot = xcode:config("xcode_sysroot") @@ -124,13 +104,11 @@ rule("xcode.metal") end -- get metallib - import("core.tool.toolchain") import("lib.detect.find_tool") - local cross = target:data("xcode.metal.cross") - local metallib = assert(find_tool("metallib", {program = cross .. " metallib"}), "metallib command not found!") + local xcode = assert(target:toolchain("xcode"), "xcode not fount!") + local metallib = assert(find_tool("metallib", {program = path.join(xcode:bindir(), "metallib")}), "metallib command not found!") -- get xcode toolchain - local xcode = toolchain.load("xcode", {plat = target:plat(), arch = target:arch()}) local xcode_sysroot = xcode:config("xcode_sysroot") -- add commands |
