summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-04 21:11:06 +0800
committerruki <[email protected]>2020-04-04 21:11:06 +0800
commitd656204be63f729a9e7b60f509af1fc3450726cc (patch)
tree165c71c6a202a2d43c590cf16959449968e10f47
parent82c4738ba1f8c7839d272b5e9d7e818efa97bdbf (diff)
add codesign
-rw-r--r--xmake/modules/detect/tools/find_codesign.lua53
-rw-r--r--xmake/modules/private/tools/codesign.lua47
-rw-r--r--xmake/rules/xcode/framework/xmake.lua6
3 files changed, 106 insertions, 0 deletions
diff --git a/xmake/modules/detect/tools/find_codesign.lua b/xmake/modules/detect/tools/find_codesign.lua
new file mode 100644
index 000000000..2dc5d0b75
--- /dev/null
+++ b/xmake/modules/detect/tools/find_codesign.lua
@@ -0,0 +1,53 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file find_codesign.lua
+--
+
+-- imports
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
+
+-- find codesign
+--
+-- @param opt the arguments, e.g. {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local codesign = find_codesign()
+-- local codesign, version = find_codesign({version = true})
+--
+-- @endcode
+--
+function main(opt)
+
+ -- only for macosx
+ if not is_host("macosx") then
+ return
+ end
+
+ -- init options
+ opt = opt or {}
+ opt.check = function (program)
+ os.execv(program, {"-d", "/bin/echo"})
+ end
+
+ -- find program
+ return find_program(opt.program or "codesign", opt)
+end
diff --git a/xmake/modules/private/tools/codesign.lua b/xmake/modules/private/tools/codesign.lua
new file mode 100644
index 000000000..b9b7f05a0
--- /dev/null
+++ b/xmake/modules/private/tools/codesign.lua
@@ -0,0 +1,47 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file codesign.lua
+--
+
+-- imports
+import("lib.detect.find_tool")
+
+-- main entry
+function main (programdir)
+
+ -- get codesign
+ local codesign = find_tool("codesign")
+ if not codesign then
+ return
+ end
+
+ -- get codesign_allocate
+ local codesign_allocate
+ local xcode_sdkdir = get_config("xcode")
+ if xcode_sdkdir then
+ codesign_allocate = path.join(xcode_sdkdir, "Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate")
+ end
+
+ -- do sign
+ local argv = {"--force", "--timestamp=none"}
+ table.insert(argv, "--sign")
+ table.insert(argv, "-")
+ table.insert(argv, programdir)
+ os.vrunv(codesign.program, argv, {envs = {CODESIGN_ALLOCATE = codesign_allocate}})
+end
+
diff --git a/xmake/rules/xcode/framework/xmake.lua b/xmake/rules/xcode/framework/xmake.lua
index dca0097a2..304ba0ea0 100644
--- a/xmake/rules/xcode/framework/xmake.lua
+++ b/xmake/rules/xcode/framework/xmake.lua
@@ -69,6 +69,9 @@ rule("xcode.framework")
after_build(function (target)
+ -- imports
+ import("private.tools.codesign")
+
-- get framework directory
local frameworkdir = path.absolute(target:data("xcode.frameworkdir"))
local headersdir = path.join(frameworkdir, "Versions", "A", "Headers")
@@ -110,6 +113,9 @@ rule("xcode.framework")
os.ln("Versions/Current/Resources", "Resources")
os.ln(path.join("Versions/Current", target_filename), target_filename)
os.cd(oldir)
+
+ -- do codesign
+ codesign(path.join(frameworkdir, "Versions", "A"))
end)
on_install(function (target)