summaryrefslogtreecommitdiff
path: root/lua_scripts/argvenvp_gcc.lua
diff options
context:
space:
mode:
authorLauri Leukkunen <lle@rahina.org>2008-01-18 02:29:22 +0200
committerLauri Leukkunen <lle@rahina.org>2008-01-18 02:29:22 +0200
commit433e970dbadd8d09336f86cca158ba3be986f377 (patch)
treecedc2713234e99e8712e0612ccb2691cee4e5189 /lua_scripts/argvenvp_gcc.lua
parent7307a37971734ef388424d91ad386c5fe3219942 (diff)
Separate gcc argv mangling rule generation to argvenvp_gcc.lua
Signed-off-by: Lauri Leukkunen <lle@rahina.org>
Diffstat (limited to 'lua_scripts/argvenvp_gcc.lua')
-rw-r--r--lua_scripts/argvenvp_gcc.lua141
1 files changed, 141 insertions, 0 deletions
diff --git a/lua_scripts/argvenvp_gcc.lua b/lua_scripts/argvenvp_gcc.lua
new file mode 100644
index 0000000..fc954f1
--- /dev/null
+++ b/lua_scripts/argvenvp_gcc.lua
@@ -0,0 +1,141 @@
+-- Copyright (C) 2008 Lauri Leukkunen <lle@rahina.org>
+-- Licensed under MIT license
+
+-- Here is the necessary plumbing to generate gcc related
+-- argv/envp manglings
+
+gcc_compilers = {
+"cc",
+"gcc",
+"c++",
+"g++",
+"cpp",
+"f77",
+"g77"
+}
+
+gcc_linkers = {
+"ld"
+}
+
+gcc_tools = {
+"addr2line",
+"ar",
+"as",
+"c++filt",
+"gccbug",
+"gcov",
+"nm",
+"objcopy",
+"objdump",
+"ranlib",
+"readelf",
+"size",
+"strings",
+"strip"
+}
+
+argvmods = {}
+
+gcc_bindir = os.getenv("SBOX_CROSS_GCC_DIR")
+gcc_subst_prefix = os.getenv("SBOX_CROSS_GCC_SUBST_PREFIX")
+gcc_extra_args = os.getenv("SBOX_EXTRA_CROSS_COMPILER_ARGS")
+gcc_block_args = os.getenv("SBOX_BLOCK_CROSS_COMPILER_ARGS")
+ld_extra_args = os.getenv("SBOX_EXTRA_CROSS_LD_ARGS")
+ld_block_args = os.getenv("SBOX_BLOCK_CROSS_LD_ARGS")
+host_gcc_bindir = os.getenv("SBOX_HOST_GCC_DIR")
+host_gcc_subst_prefix = os.getenv("SBOX_HOST_GCC_SUBST_PREFIX")
+host_gcc_extra_args = os.getenv("SBOX_EXTRA_HOST_COMPILER_ARGS")
+host_gcc_block_args = os.getenv("SBOX_BLOCK_HOST_COMPILER_ARGS")
+
+-- The trick with ":" .. is to have a non-prefixed gcc call caught here
+for prefix in string.gmatch(":" .. os.getenv("SBOX_CROSS_GCC_PREFIX_LIST"), "[^:]*") do
+ for i = 1, table.maxn(gcc_compilers) do
+ tmp = {}
+ tmp.name = prefix .. gcc_compilers[i]
+ tmp.new_filename = gcc_bindir .. "/" .. gcc_subst_prefix .. gcc_compilers[i]
+ tmp.add_tail = {}
+ tmp.remove = {}
+ if (gcc_extra_args) then
+ for gcc_extra in string.gmatch(gcc_extra_args, "[^ ]+") do
+ table.insert(tmp.add_tail, gcc_extra)
+ end
+ end
+ if (gcc_block_args) then
+ for gcc_block in string.gmatch(gcc_block_args, "[^ ]+") do
+ table.insert(tmp.remove, gcc_block)
+ end
+ end
+ argvmods[tmp.name] = tmp
+ end
+
+ -- just map the filename for linkers and tools
+ for i = 1, table.maxn(gcc_linkers) do
+ tmp = {}
+ tmp.name = prefix .. gcc_linkers[i]
+ tmp.new_filename = gcc_bindir .. "/" .. gcc_subst_prefix .. gcc_linkers[i]
+ tmp.add_tail = {}
+ tmp.remove = {}
+ if (ld_extra_args) then
+ for ld_extra in string.gmatch(ld_extra_args, "[^ ]+") do
+ table.insert(tmp.add_tail, ld_extra)
+ end
+ end
+ if (ld_block_args) then
+ for ld_block in string.gmatch(ld_block_args, "[^ ]+") do
+ table.insert(tmp.remove, ld_block)
+ end
+ end
+ argvmods[tmp.name] = tmp
+ end
+ for i = 1, table.maxn(gcc_tools) do
+ tmp = {}
+ tmp.name = prefix .. gcc_tools[i]
+ tmp.new_filename = gcc_bindir .. "/" .. gcc_subst_prefix .. gcc_tools[i]
+ argvmods[tmp.name] = tmp
+ end
+end
+
+
+-- deal with host-gcc functionality, disables mapping
+for prefix in string.gmatch(os.getenv("SBOX_HOST_GCC_PREFIX_LIST"), "[^:]+") do
+ for i = 1, table.maxn(gcc_compilers) do
+ tmp = {}
+ tmp.name = prefix .. gcc_compilers[i]
+ tmp.new_filename = host_gcc_bindir .. "/" .. host_gcc_subst_prefix .. gcc_compilers[i]
+ tmp.add_tail = {}
+ tmp.remove = {}
+ tmp.disable_mapping = 1
+ if (host_gcc_extra_args) then
+ for gcc_extra in string.gmatch(host_gcc_extra_args, "[^ ]+") do
+ table.insert(tmp.add_tail, gcc_extra)
+ end
+ end
+ if (host_gcc_block_args) then
+ for gcc_block in string.gmatch(host_gcc_block_args, "[^ ]+") do
+ table.insert(tmp.remove, gcc_block)
+ end
+ end
+ argvmods[tmp.name] = tmp
+ end
+
+ -- just map the filename for linkers and tools
+ for i = 1, table.maxn(gcc_linkers) do
+ tmp = {}
+ tmp.name = prefix .. gcc_linkers[i]
+ tmp.new_filename = host_gcc_bindir .. "/" .. host_gcc_subst_prefix .. gcc_linkers[i]
+ tmp.disable_mapping = 1
+ argvmods[tmp.name] = tmp
+ end
+ for i = 1, table.maxn(gcc_tools) do
+ tmp = {}
+ tmp.name = prefix .. gcc_tools[i]
+ tmp.new_filename = host_gcc_bindir .. "/" .. host_gcc_subst_prefix .. gcc_tools[i]
+ tmp.disable_mapping = 1
+ argvmods[tmp.name] = tmp
+ end
+end
+
+-- end of gcc related generation
+
+