Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 04eb4dc050
Fetching contributors…

Cannot retrieve contributors at this time

executable file 204 lines (172 sloc) 5.155 kb
#!/usr/bin/ruby
=begin
droid-wrapper : Android toolchain wrapper script
version 1.0.5
Copyright 2009-2010, Takuya Murakami, Yoshiaki Okuyama.
Author:
Takuya Murakami <tmurakam at tmurakam.org>
Yoshiaki Okuyama <okuyam2y at gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
=end
debug = false
if (ENV["DROID_WRAPPER_DEBUG"])
debug = true
end
droid_root = ENV["DROID_ROOT"]
if (!droid_root)
STDERR.puts "You must specify DROID_ROOT"
exit 1
end
droid_target = ENV["DROID_TARGET"]
if (!droid_target)
STDERR.puts "You must specify DROID_TARGET"
exit 1
end
droid_host = ENV["DROID_HOST"]
if (!droid_host)
droid_host = "linux-x86"
end
toolver = "4.2.1"
toolchain = "#{droid_root}/prebuilt/#{droid_host}/toolchain/arm-eabi-#{toolver}"
alib = "#{droid_root}/out/target/product/#{droid_target}/obj/lib"
# many compiler/linker flags were extracted from
# build/core/combo/linux-arm.mk file.
cflags =
[
"-DANDROID",
"-msoft-float",
"-fpic",
"-ffunction-sections",
"-funwind-tables",
"-fstack-protector",
"-fno-short-enums",
"-fno-exceptions",
"-fmessage-length=0",
"-Wno-multichar",
#"-mthumb-interwork",
"-I#{droid_root}/system/core/include",
"-I#{droid_root}/hardware/libhardware/include",
"-I#{droid_root}/hardware/libhardware_legacy/include",
"-I#{droid_root}/hardware/ril/include",
"-I#{droid_root}/dalvik/libnativehelper/include",
"-I#{droid_root}/frameworks/base/include",
"-I#{droid_root}/frameworks/base/opengl/include",
"-I#{droid_root}/external/skia/include",
"-I#{droid_root}/out/target/product/#{droid_target}/obj/include",
"-I#{droid_root}/bionic/libc/arch-arm/include",
"-I#{droid_root}/bionic/libc/include",
"-I#{droid_root}/bionic/libstdc++/include",
"-I#{droid_root}/bionic/libc/kernel/common",
"-I#{droid_root}/bionic/libc/kernel/arch-arm",
"-I#{droid_root}/bionic/libm/include",
"-I#{droid_root}/bionic/libm/include/arch/arm",
"-I#{droid_root}/bionic/libthread_db/include",
"-I#{droid_root}/bionic/libm/arm",
"-I#{droid_root}/bionic/libm",
"-I#{droid_root}/out/target/product/#{droid_target}/obj/SHARED_LIBRARIES/libm_intermediates"
]
link_args =
[
"-Bdynamic",
"-Wl,-T,#{droid_root}/build/core/armelf.x",
"-Wl,-dynamic-linker,/system/bin/linker",
"-Wl,--gc-sections",
"-Wl,-z,nocopyreloc",
"-Wl,--no-undefined",
"-Wl,-rpath-link=#{alib}",
"-Wl,-rpath,/system/lib",
"-L#{alib}",
"-nostdlib",
"#{alib}/crtbegin_dynamic.o",
"#{toolchain}/lib/gcc/arm-eabi/#{toolver}/libgcc.a",
"#{alib}/crtend_android.o",
"-lc",
"-lm"
]
shlib_args =
[
"-nostdlib",
"-Wl,-T,#{droid_root}/build/core/armelf.xsc",
"-Wl,--gc-sections",
"-Wl,-shared,-Bsymbolic",
"-L#{alib}",
"-Wl,--no-whole-archive",
"-lc",
"-lm",
"-Wl,--no-undefined",
"#{toolchain}/lib/gcc/arm-eabi/#{toolver}/interwork/libgcc.a",
"-Wl,--whole-archive",
"-Wl,--warn-unresolved-symbols"
]
### check myself
prog = nil
oprog = nil
if ($0 =~ /^.*-([^-]+)$/)
oprog = $1
prog = "#{toolchain}/bin/arm-eabi-#{$1}"
else
STDERR.puts "internal error: invalid command name."
exit 1
end
isLD = false
if (oprog == "ld")
isLD = true
end
### parse command line options
if (["ar", "nm", "objcopy", "objdump", "ranlib", "strip"].include?(oprog))
mode = "passthrough"
else
mode = "link"
ARGV.each do |arg|
case arg
when "-c", "-S", "-E", "-r"
mode = "compile"
when "-shared"
mode = "shlib"
end
end
end
### generate command line
argv = ARGV
case mode
when "compile"
argv = cflags + ARGV
when "link"
if (!isLD)
argv = cflags + link_args + ARGV
else
argv = link_args + ARGV
end
when "shlib"
if (!isLD)
argv = cflags + shlib_args + ARGV
else
argv = shlib_args + ARGV
end
end
# remove -Wl options for linker
if (isLD)
argv2 = Array.new
argv.each do |arg|
if (arg =~ /^-Wl,(.*)$/)
argv2 += $1.split(/,/)
else
argv2.push(arg)
end
end
argv = argv2
end
# Note: Behavior of this command line might differ from
# following exec call, because each arguments are not quoted.
puts "droid-debug(#{mode}): #{prog} #{argv.join(" ")}" if (debug)
exec [prog, prog], *argv
Jump to Line
Something went wrong with that request. Please try again.