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.
libshit/tools/ci_conf.windows.rb

141 lines
4.6 KiB
Ruby

require_relative 'linux'
# https://daviddeley.com/autohotkey/parameters/parameters.htm#CPP
# https://archive.vn/LTgTs
refine String do
def winescape
# Diff to unix: removed ^ (escape in cmd), ' (not special, but might cause
# confusion between all these unix code)
if self =~ %r{^[0-9a-zA-Z%+,./:=@_-]+$}
dup
else
s = gsub(/(\\*)"/, '\1\1"').sub(/(\\+)$/, '\1\1').gsub(/[<>|&()"^]/, '\0')
"^\"#{s}^\""
end
end
end
refine Enumerable do
def winjoin; map(&:winescape).join ' '; end
end
win_common = -> sysroot, ver, inc, lib32, lib64 do
case opt.architecture
when 'x86'
msvc_triplet = 'i386-pc-windows-msvc'
libs = lib32
when 'amd64'
msvc_triplet = 'x86_64-pc-windows-msvc'
libs = lib64
else
fail "Architecture #{opt.architecture} not supported on windows"
end
tgt = ['-target', msvc_triplet, "-fms-compatibility-version=#{ver}"]
env.ASFLAGS.concat tgt
opt.compile_flags.concat tgt
env.LINKFLAGS.concat tgt
opt.compile_flags.concat(inc.map do |d|
%W(-Xclang -internal-isystem -Xclang #{sysroot}/#{d})
end.flatten)
env.LINKFLAGS.concat libs.map {|d| "-L#{sysroot}/#{d}" }
end
win_cond = -> { opt.os.start_with? 'windows' }
step :windows_opts, always_after: :arch_opts, before: :os_opts, cond: win_cond do
fail "Windows only supports clang_msvc" unless opt.compiler.start_with? 'clang_msvc'
opt.config_opts.append '--lua-dll', '--all-bundled'
opt.triplet_oses = %w(mingw32) # clang-msvc doesn't use this...
env.WINRC = find_gnu_prefixed 'windres' # but mingw dep does...
opt.shlib_pattern = '%s.dll'
opt.executable_pattern = '%s.exe'
case opt.os
when 'windows'
when 'windows_xp'
opt.config_opts.append '--min-windows-version=5.1'
when 'windows_vista'
opt.config_opts.append '--min-windows-version=6.0'
when 'windows_7'
opt.config_opts.append '--min-windows-version=6.1'
when 'windows_8'
opt.config_opts.append '--min-windows-version=6.2'
when 'windows_81'
opt.config_opts.append '--min-windows-version=6.3'
else
fail "Unsupported windows version #{opt.os.inspect}"
end
case opt.compiler
when 'clang_msvc12'
win_common[
opt.msvc12_sysroot, '18',
%w(include win_sdk/include/um win_sdk/include/shared),
%w(lib win_sdk/lib/winv6.3/um/x86),
%w(lib/amd64 win_sdk/lib/winv6.3/um/x64)]
# libc++ doesn't work with this old msvc libs
when 'clang_msvc1411'
win_common[
opt.msvc1411_sysroot, '19.11.25547',
%w(include win_sdk/include/ucrt win_sdk/include/um win_sdk/include/shared),
%w(lib/x86 win_sdk/lib/ucrt/x86 win_sdk/lib/winv6.3/um/x86),
%w(lib/x64 win_sdk/lib/ucrt/x64 win_sdk/lib/winv6.3/um/x64)]
opt.config_opts.append '--all-bundled', '--with-stdlib=bundle-libc++'
else
fail "Unsupported compiler #{opt.compiler.inspect}"
end
end
def rec; rec; end
test_step :test_wine, cond: win_cond do
# unshare -r: overlayfs does a `chmod 0` on the work directory which is a
# complete bullshit and you can't delete it normally. We could recursively fix
# permisssions, but `unshare -r` looks much simpler :p
clean = %w(unshare -r rm -rf wine_upper wine_tmp wine_mount)
run opt.run_dir, clean
run opt.run_dir, 'mkdir', '-p', 'wine_upper', 'wine_tmp', 'wine_mount'
res = Linux.clonens_wait do
einfo 'Entered user+mount+pid namespace'
dst = File.join opt.run_dir, 'wine_mount'
einfo "Mounting overlayfs at #{dst}"
Linux.mount 'none', dst, 'overlay', 0,
"lowerdir=#{ENV['HOME']}/.wine,"\
"upperdir=#{opt.run_dir}/wine_upper,"\
"workdir=#{opt.run_dir}/wine_tmp,volatile"
env.WINEPREFIX = dst
# wine produces shittons of stub warnings in dbgeng while running the tests,
# they're only needed for stacktraces and not critical, so just ignore them
env.WINEDEBUG = 'fixme-dbgeng'
run opt.run_dir, 'wine', *get_test_cmdline
run opt.run_dir, 'wineserver', '-k'
end
ensure
run opt.run_dir, clean
end
def qemu_step name, &blk
cond = -> { blk[] && opt.get("#{name}_img") }
test_step :"test_qemu_#{name}", cond: cond do
cmd = get_test_cmdline
cmd[0].delete_prefix! 'build/' or fail
to_copy = opt.executables.map {|e| "build/#{opt.executable_pattern % e}" }
to_copy << 'build/lua53.dll' if File.exist? 'build/lua53.dll'
exe = rel_from File.join(opt.tools_dir, 'vmrun.sh'), opt.run_dir
Linux.clonens_wait do
Linux.up_lo
img = opt.get "#{name}_img"
run opt.run_dir, exe, img, '1234', cmd.winjoin, *to_copy
end
end
end
xp_cond = -> { opt.os == 'windows_xp' && opt.architecture == 'x86' }
qemu_step "winxp_kvm", &xp_cond
qemu_step "winxp_qemu", &xp_cond
qemu_step "win7", &win_cond