summaryrefslogtreecommitdiff
path: root/xmake/plugins/project/xcode2/get_xcode_info.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-07-02 10:02:42 +0800
committerGitHub <[email protected]>2025-07-02 10:02:42 +0800
commit5cbbc97e495e58cfb37994939a24aa6c6b0b4267 (patch)
treef91f1580174a48ab84b9e60ccd51720143f226ea /xmake/plugins/project/xcode2/get_xcode_info.lua
parent5659468ff81b1c80576a03a88b0402483b436172 (diff)
Update get_xcode_info.lua
Diffstat (limited to 'xmake/plugins/project/xcode2/get_xcode_info.lua')
-rw-r--r--xmake/plugins/project/xcode2/get_xcode_info.lua49
1 files changed, 36 insertions, 13 deletions
diff --git a/xmake/plugins/project/xcode2/get_xcode_info.lua b/xmake/plugins/project/xcode2/get_xcode_info.lua
index 05fe21895..d8d6d3b6f 100644
--- a/xmake/plugins/project/xcode2/get_xcode_info.lua
+++ b/xmake/plugins/project/xcode2/get_xcode_info.lua
@@ -39,6 +39,22 @@ function _get_project_modes()
return ret_modes
end
+-- tranlate path
+function _translate_path(filepath, outputdir)
+ filepath = path.translate(filepath)
+ if filepath == "" then
+ return ""
+ end
+ if path.is_absolute(filepath) then
+ if filepath:startswith(project.directory()) then
+ return path.relative(filepath, outputdir)
+ end
+ return filepath
+ else
+ return path.relative(path.absolute(filepath), outputdir)
+ end
+end
+
function _add_PBXFileReference(xcinfo, file_info)
local obj = {}
obj.explicitFileType = file_info.explicitFileType
@@ -112,23 +128,30 @@ end
function _add_PBXShellScriptBuildPhase(xcinfo, target)
local obj = {}
- obj.shellScript = [[
-cd \"]] .. os.projectdir() .. [[\"
-XMAKE_BIN=\"]] .. os.programfile() .. [[\"
+ local shellscript = {}
+ local projectdir = _translate_path(os.projectdir(), xcinfo.project_dir)
+ if projectdir ~= "." then
+ table.insert(shellscript, "cd " .. projectdir)
+ end
+ table.insert(shellscript, [[
+export XMAKE_PROGRAM_FILE=\"]] .. os.programfile() .. [[\"
+export XMAKE_PROGRAM_DIR=\"]] .. os.programdir() .. [[\"
+export XMAKE_COLORTERM=\"nocolor\"
+
# Running xmake scripts.
-${XMAKE_BIN} f -y -m ${CONFIGURATION} -p ${PLATFORM_NAME} -a ${NATIVE_ARCH} -o ${BUILD_DIR}
-${XMAKE_BIN} build ${TARGET_NAME}\n# Running xmake install scripts.
-XMAKE_BUILD_DIR=${BUILD_DIR}/${PLATFORM_NAME}/${NATIVE_ARCH}/${CONFIGURATION}
+${XMAKE_PROGRAM_FILE} f -y -m ${CONFIGURATION} -p ${PLATFORM_NAME} -a ${NATIVE_ARCH} -o ${BUILD_DIR} || exit -1
+${XMAKE_PROGRAM_FILE} build ${TARGET_NAME} || exit -1
+
# Copy files to build path.
-if test -e ${CONFIGURATION_BUILD_DIR}
-then
+XMAKE_BUILD_DIR=${BUILD_DIR}/${PLATFORM_NAME}/${NATIVE_ARCH}/${CONFIGURATION}
+if test -e ${CONFIGURATION_BUILD_DIR}; then
rm -r ${CONFIGURATION_BUILD_DIR}/*
fi
-if test -e ${XMAKE_BUILD_DIR}
-then
+if test -e ${XMAKE_BUILD_DIR}; then
cp -r ${XMAKE_BUILD_DIR}/* ${CONFIGURATION_BUILD_DIR}
fi
-]]
+]])
+ obj.shellScript = table.concat(shellscript, "\n")
local uuid = xcinfo:gen_uuid()
xcinfo.sections.PBXShellScriptBuildPhase = xcinfo.sections.PBXShellScriptBuildPhase or {}
xcinfo.sections.PBXShellScriptBuildPhase[uuid] = obj
@@ -181,7 +204,7 @@ function _add_PBXNativeTarget(xcinfo, target_name, target)
product_file.explicitFileType = "wrapper.application"
else
product_file.explicitFileType = "com.apple.product-type.tool"
- end
+ end
end
if is_app_bundle then
product_file.name = target:filename() .. ".app"
@@ -274,4 +297,4 @@ function main(outputdir)
table.insert(main_group.children, project_obj.productRefGroup)
return xcinfo
-end \ No newline at end of file
+end