ar命令使用-M选项支持脚本输入,创建一个AR脚本, 包含所i有.o文件, 在eclipse里修改ar命令选项 ${COMMAND} -M “${workspace_loc:/netxduo/ar_script.txt}”。
创建ar脚本的powershell脚本代码:
[C] 纯文本查看 复制代码 # File: generate_ar_script.ps1
# Located at the root of the netxduo project
# Change the current directory to where the script is located
Push-Location $PSScriptRoot
# Directory containing the .o files
$debugDir = "./Debug"
# Get all .o files from the directory recursively
$oFiles = Get-ChildItem -Path $debugDir -Filter "*.o" -Recurse | ForEach-Object { $_.FullName }
# Begin creating the ar script
$arScript = @()
$arScript += "create libnetxduo.a"
$oFiles | ForEach-Object { $arScript += "ADDMOD $_" }
$arScript += "SAVE"
$arScript += "END"
# Output the ar script to a file
$arScript -join "`n" | Out-File "ar_script.txt" -Encoding ascii
# Return to the original directory
Pop-Location
Write-Output "AR Script generated successfully!"
输出文件参考ar_script.txt
|