You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.9 KiB
Ruby
112 lines
3.9 KiB
Ruby
require_relative 'linux'
|
|
|
|
def strip fname
|
|
d = opt.run_dir
|
|
base = File.join d, fname
|
|
return unless !File.exist?("#{base}.strip_stamp") ||
|
|
File.mtime(base) != File.mtime("#{base}.strip_stamp")
|
|
|
|
run d, %W(objcopy --only-keep-debug #{fname} #{fname}.debug)
|
|
run d, %W(chmod -x #{fname}.debug)
|
|
run d, %W(strip --strip-unneeded -R .comment -R .GCC.command.line -R .gnu_debuglink #{fname})
|
|
run d, %W(objcopy --add-gnu-debuglink=#{fname}.debug #{fname})
|
|
run d, %W(touch -r#{fname} #{fname}.strip_stamp)
|
|
end
|
|
|
|
lin_cond = -> { opt.os.start_with? 'linux' }
|
|
step :linux_opts, always_after: :default_values, before: :os_opts, cond: lin_cond do
|
|
opt.triplet_oses = %w(linux-gnu)
|
|
opt.shlib_pattern = 'lib%s.so'
|
|
opt.executable_pattern = '%s'
|
|
|
|
opt.valgrind_opts = %W(
|
|
--suppressions=#{File.join opt.tools_dir, 'valgrind.supp'}
|
|
--leak-check=full
|
|
--track-origins=yes
|
|
--show-leak-kinds=all
|
|
)
|
|
end
|
|
|
|
step :linux_strip, always_after: :default_values, after: :do_build,
|
|
before: :build, cond: lin_cond do
|
|
next if [false, "false", "no"].include? opt.strip
|
|
opt.executables.each do |e|
|
|
strip "build/#{e}" if File.exist? File.join(opt.run_dir, "build/#{e}")
|
|
end
|
|
end
|
|
|
|
test_step :test_valgrind, cond: -> { !opt.is_cross && opt.os.start_with?('linux') } do
|
|
Linux.clonens_wait do
|
|
run opt.run_dir, 'valgrind', *opt.valgrind_opts, '--',
|
|
*get_test_cmdline, '-tce=*[no_valgrind]*'
|
|
end
|
|
end
|
|
|
|
# steamrt
|
|
srt_cond = -> do
|
|
opt.os == 'linux_steamrt' && opt.architecture == 'amd64' &&
|
|
opt.steamrt_amd64_sysroot
|
|
end
|
|
step :linux_steamrt_opts, always_after: :linux_opts, before: :os_opts,
|
|
cond: srt_cond do
|
|
sysroot = opt.steamrt_amd64_sysroot
|
|
opt.config_opts.append '--all-bundled'
|
|
|
|
opt.compile_flags.append '--sysroot', sysroot
|
|
env.LINKFLAGS.append '--sysroot', sysroot
|
|
|
|
# define: old glibc doesn't know about clang
|
|
if opt.compiler.start_with? 'clang'
|
|
opt.compile_flags.append \
|
|
'-D__extern_always_inline=extern __always_inline __attribute__((__gnu_inline__))'
|
|
end
|
|
|
|
# -lrt only needed with glibc < 2.17
|
|
env.LINKFLAGS.concat %w(-Wl,--as-needed -lpthread -lrt -Wl,--no-as-needed)
|
|
|
|
env.PKG_CONFIG_PATH = Dir.glob "#{sysroot.globescape}/usr/lib/{,*/}pkgconfig"
|
|
env.PKG_CONFIG_SYSROOT_DIR = sysroot
|
|
opt.steamrt_sysroot_ld_library_path =
|
|
Dir.glob("#{sysroot.globescape}/{,usr/}lib/{,*-linux-gnu}").join ':'
|
|
end
|
|
|
|
test_step :test_linux_steamrt_chroot, cond: -> { !opt.is_cross && srt_cond[] } do
|
|
uid = Process.uid
|
|
gid = Process.gid
|
|
pid = Linux.clone Linux::CLONE_NEWUSER | Linux::CLONE_NEWPID |
|
|
Linux::CLONE_NEWNS | Linux::CLONE_NEWIPC | Linux::CLONE_NEWNET do
|
|
einfo "Chroot into #{opt.steamrt_amd64_sysroot}"
|
|
Linux.uid_gid_map uid, gid
|
|
Dir.chdir opt.steamrt_amd64_sysroot
|
|
Linux.mount '/', '/', nil, Linux::MS_REC | Linux::MS_PRIVATE
|
|
Linux.mount 'none', 'proc', 'proc', Linux::MS_NOSUID | Linux::MS_NODEV |
|
|
Linux::MS_RDONLY
|
|
Linux.mount '/dev', 'dev', nil, Linux::MS_BIND | Linux::MS_REC
|
|
Linux.mount opt.run_dir, 'test', nil, Linux::MS_BIND | Linux::MS_REC
|
|
Dir.chroot '.'
|
|
run '/test', *get_test_cmdline
|
|
rescue Exception
|
|
puts $!.full_message
|
|
exit! 1
|
|
end
|
|
Process.wait pid
|
|
fail "Subprocess failed: #{$?}" unless $?.success?
|
|
end
|
|
|
|
test_step :test_linux_steamrt_qemu, cond: srt_cond do
|
|
qemu_args = %W(
|
|
-E LD_LIBRARY_PATH=#{opt.steamrt_sysroot_ld_library_path}
|
|
)
|
|
if opt.architecture == 'amd64'
|
|
run opt.tools_dir, env.HOST_CC || env.CC, '-O2', '-shared',
|
|
'qemu_vdso_fix_linux_amd64.c', '-o', 'qemu_vdso_fix_linux_amd64.so'
|
|
out = File.join opt.tools_dir, 'qemu_vdso_fix_linux_amd64.so'
|
|
qemu_args.append '-E', "LD_PRELOAD=#{out}"
|
|
end
|
|
|
|
env.QEMU_CPU = 'u3-64bit-minimal'
|
|
env.QEMU_EXECVE = which 'qemu-x86_64'
|
|
env.QEMU_LD_PREFIX = opt.steamrt_amd64_sysroot
|
|
run opt.run_dir, 'qemu-x86_64', *qemu_args, '--', *get_test_cmdline
|
|
end
|