summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-04-01 10:44:17 +0800
committerruki <[email protected]>2017-04-01 10:44:17 +0800
commit42bdac0d7f2a57a91587673d66c6bf1474fbaa1a (patch)
tree82c68216a4d12bda25e175da4f9921db5b6ea413
parent4124df8db74770f526942dbb18c4c834b39b917a (diff)
Fix only position independent executables issue for android program
-rw-r--r--CHANGELOG.md12
-rw-r--r--xmake/core/tool/compiler.lua21
-rw-r--r--xmake/core/tool/linker.lua18
-rw-r--r--xmake/platforms/android/load.lua3
4 files changed, 43 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3f06cff53..308ca40b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
## master (unreleased)
+### New features
+
+* [#65](https://github.com/tboox/xmake/pull/65): Add `set_default` api for target to modify default build and install behavior
+
### Changes
* [#61](https://github.com/tboox/xmake/pull/61): Provide safer `xmake install` and `xmake uninstall` task with administrator permission
@@ -14,6 +18,8 @@
* Fix error tips for checking xmake min version
* [#60](https://github.com/tboox/xmake/issues/60): Fix self-build for macosx and windows
+* [#64](https://github.com/tboox/xmake/issues/64): Fix compile android `armv8-a` error
+* [#50](https://github.com/tboox/xmake/issues/50): Fix only position independent executables issue for android program
## v2.1.2
@@ -235,6 +241,10 @@
## master (开发中)
+### 新特性
+
+* [#65](https://github.com/tboox/xmake/pull/65): 为target添加`set_default`接口用于修改默认的构建所有targets行为
+
### 改进
* [#61](https://github.com/tboox/xmake/pull/61): 提供更加安全的`xmake install` and `xmake uninstall`任务,更友好的处理root安装问题
@@ -247,6 +257,8 @@
* 修复版本检测的错误提示信息
* [#60](https://github.com/tboox/xmake/issues/60): 修复macosx和windows平台的xmake自举编译
+* [#64](https://github.com/tboox/xmake/issues/64): 修复构建android `armv8-a`架构失败问题
+* [#50](https://github.com/tboox/xmake/issues/50): 修复构建android可执行程序,无法运行问题
## v2.1.2
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index c1bc3221e..0fe79c6a4 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -47,17 +47,24 @@ function compiler:_language()
end
-- add flags from the platform
-function compiler:_addflags_from_platform(flags)
+function compiler:_addflags_from_platform(flags, targetkind)
-- add flags
local toolkind = self:get("kind")
for _, flagkind in ipairs(self:_flagkinds()) do
+
+ -- add flags for platform
table.join2(flags, platform.get(flagkind))
+
+ -- add flags for platform and the given taget kind
+ if targetkind ~= nil and platform.get(targetkind) ~= nil then
+ table.join2(flags, platform.get(targetkind)[flagkind])
+ end
end
end
-- add flags from the compiler
-function compiler:_addflags_from_compiler(flags, kind)
+function compiler:_addflags_from_compiler(flags, targetkind)
-- done
for _, flagkind in ipairs(self:_flagkinds()) do
@@ -65,9 +72,9 @@ function compiler:_addflags_from_compiler(flags, kind)
-- add compiler.xxflags
table.join2(flags, self:get(flagkind))
- -- add compiler.kind.xxflags
- if kind ~= nil and self:get(kind) ~= nil then
- table.join2(flags, self:get(kind)[flagkind])
+ -- add compiler.targetkind.xxflags
+ if targetkind ~= nil and self:get(targetkind) ~= nil then
+ table.join2(flags, self:get(targetkind)[flagkind])
end
end
end
@@ -174,10 +181,10 @@ function compiler:compflags(target)
self:_addflags_from_language(flags, target)
-- add flags from the platform
- self:_addflags_from_platform(flags)
+ self:_addflags_from_platform(flags, target:targetkind())
-- add flags from the compiler
- self:_addflags_from_compiler(flags, target:get("kind"))
+ self:_addflags_from_compiler(flags, target:targetkind())
-- remove repeat
flags = table.unique(flags)
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index c1485391c..7f3e2c178 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -41,18 +41,23 @@ local builder = require("tool/builder")
local compiler = require("tool/compiler")
-- add flags from the platform
-function linker:_addflags_from_platform(flags)
+function linker:_addflags_from_platform(flags, targetkind)
-- add flags
local toolkind = self:get("kind")
for _, flagkind in ipairs(self:_flagkinds()) do
+
-- attempt to add special lanugage flags first, .e.g gc-ldflags, dc-arflags
table.join2(flags, platform.get(toolkind .. 'flags') or platform.get(flagkind))
+
+ -- attempt to add special lanugage flags first for target kind, .e.g gc-ldflags, dc-arflags
+ local targetflags = platform.get(targetkind) or {}
+ table.join2(flags, targetflags[toolkind .. 'flags'] or targetflags[flagkind])
end
end
-- add flags from the compiler
-function linker:_addflags_from_compiler(flags, sourcekinds)
+function linker:_addflags_from_compiler(flags, targetkind, sourcekinds)
-- make flags
local flags_of_compiler = {}
@@ -63,8 +68,13 @@ function linker:_addflags_from_compiler(flags, sourcekinds)
local instance, errors = compiler.load(sourcekind)
if instance then
for _, flagkind in ipairs(self:_flagkinds()) do
+
-- attempt to add special lanugage flags first, .e.g gc-ldflags, dc-arflags
table.join2(flags_of_compiler, instance:get(toolkind .. 'flags') or instance:get(flagkind))
+
+ -- attempt to add special lanugage flags first for target kind, .e.g gc-ldflags, dc-arflags
+ local targetflags = instance:get(targetkind) or {}
+ table.join2(flags_of_compiler, targetflags[toolkind .. 'flags'] or targetflags[flagkind])
end
end
end
@@ -205,10 +215,10 @@ function linker:linkflags(target)
self:_addflags_from_language(flags, target)
-- add flags from the platform
- self:_addflags_from_platform(flags)
+ self:_addflags_from_platform(flags, target:targetkind())
-- add flags from the compiler
- self:_addflags_from_compiler(flags, target:sourcekinds())
+ self:_addflags_from_compiler(flags, target:targetkind(), target:sourcekinds())
-- add flags from the linker
self:_addflags_from_linker(flags)
diff --git a/xmake/platforms/android/load.lua b/xmake/platforms/android/load.lua
index 747498aea..e80ff5c89 100644
--- a/xmake/platforms/android/load.lua
+++ b/xmake/platforms/android/load.lua
@@ -51,6 +51,9 @@ function main()
_g.cxxflags = {}
end
+ -- init cxflags and ldflags for the target kind: binary
+ _g.binary = { cxflags = {"-fPIE", "-pie"}, ldflags = {"-fPIE", "-pie"} }
+
-- add flags for the sdk directory of ndk
local ndk = config.get("ndk")
local ndk_sdkver = config.get("ndk_sdkver")