libshit

Just some random shit
git clone https://git.neptards.moe/neptards/libshit.git
Log | Files | Refs | Submodules | README | LICENSE

ci_conf.windows.rb (4740B)


      1 require_relative 'linux'
      2 
      3 # https://daviddeley.com/autohotkey/parameters/parameters.htm#CPP
      4 # https://archive.vn/LTgTs
      5 refine String do
      6   def winescape
      7     # Diff to unix: removed ^ (escape in cmd), ' (not special, but might cause
      8     # confusion between all these unix code)
      9     if self =~ %r{^[0-9a-zA-Z%+,./:=@_-]+$}
     10       dup
     11     else
     12       s = gsub(/(\\*)"/, '\1\1"').sub(/(\\+)$/, '\1\1').gsub(/[<>|&()"^]/, '\0')
     13       "^\"#{s}^\""
     14     end
     15   end
     16 end
     17 refine Enumerable do
     18   def winjoin; map(&:winescape).join ' '; end
     19 end
     20 
     21 win_common = -> sysroot, ver, inc, lib32, lib64 do
     22   case opt.architecture
     23   when 'x86'
     24     msvc_triplet = 'i386-pc-windows-msvc'
     25     libs = lib32
     26   when 'amd64'
     27     msvc_triplet = 'x86_64-pc-windows-msvc'
     28     libs = lib64
     29   else
     30     fail "Architecture #{opt.architecture} not supported on windows"
     31   end
     32 
     33   tgt = ['-target', msvc_triplet, "-fms-compatibility-version=#{ver}"]
     34   env.ASFLAGS.concat tgt
     35   opt.compile_flags.concat tgt
     36   env.LINKFLAGS.concat tgt
     37 
     38   opt.compile_flags.concat(inc.map do |d|
     39     %W(-Xclang -internal-isystem -Xclang #{sysroot}/#{d})
     40   end.flatten)
     41   env.LINKFLAGS.concat libs.map {|d| "-L#{sysroot}/#{d}" }
     42 end
     43 
     44 win_cond = -> { opt.os.start_with? 'windows' }
     45 step :windows_opts, always_after: :arch_opts, before: :os_opts, cond: win_cond do
     46   fail "Windows only supports clang_msvc" unless opt.compiler.start_with? 'clang_msvc'
     47   opt.config_opts.append '--lua-dll', '--all-bundled'
     48 
     49   opt.triplet_oses = %w(mingw32) # clang-msvc doesn't use this...
     50   env.WINRC = find_gnu_prefixed 'windres' # but mingw dep does...
     51 
     52   opt.shlib_pattern = '%s.dll'
     53   opt.executable_pattern = '%s.exe'
     54 
     55   case opt.os
     56   when 'windows'
     57   when 'windows_xp'
     58     opt.config_opts.append '--min-windows-version=5.1'
     59   when 'windows_vista'
     60     opt.config_opts.append '--min-windows-version=6.0'
     61   when 'windows_7'
     62     opt.config_opts.append '--min-windows-version=6.1'
     63   when 'windows_8'
     64     opt.config_opts.append '--min-windows-version=6.2'
     65   when 'windows_81'
     66     opt.config_opts.append '--min-windows-version=6.3'
     67   else
     68     fail "Unsupported windows version #{opt.os.inspect}"
     69   end
     70 
     71   case opt.compiler
     72   when 'clang_msvc12'
     73     win_common[
     74       opt.msvc12_sysroot, '18',
     75       %w(include win_sdk/include/um win_sdk/include/shared),
     76       %w(lib win_sdk/lib/winv6.3/um/x86),
     77       %w(lib/amd64 win_sdk/lib/winv6.3/um/x64)]
     78     # libc++ doesn't work with this old msvc libs
     79   when 'clang_msvc1411'
     80     win_common[
     81       opt.msvc1411_sysroot, '19.11.25547',
     82       %w(include win_sdk/include/ucrt win_sdk/include/um win_sdk/include/shared),
     83       %w(lib/x86 win_sdk/lib/ucrt/x86 win_sdk/lib/winv6.3/um/x86),
     84       %w(lib/x64 win_sdk/lib/ucrt/x64 win_sdk/lib/winv6.3/um/x64)]
     85     opt.config_opts.append '--all-bundled', '--with-stdlib=bundle-libc++'
     86   else
     87     fail "Unsupported compiler #{opt.compiler.inspect}"
     88   end
     89 end
     90 
     91 def rec; rec; end
     92 
     93 test_step :test_wine, cond: win_cond do
     94   # unshare -r: overlayfs does a `chmod 0` on the work directory which is a
     95   # complete bullshit and you can't delete it normally. We could recursively fix
     96   # permisssions, but `unshare -r` looks much simpler :p
     97   clean = %w(unshare -r rm -rf wine_upper wine_tmp wine_mount)
     98 
     99   run opt.run_dir, clean
    100   run opt.run_dir, 'mkdir', '-p', 'wine_upper', 'wine_tmp', 'wine_mount'
    101   res = Linux.clonens_wait do
    102     einfo 'Entered user+mount+pid namespace'
    103     dst = File.join opt.run_dir, 'wine_mount'
    104     einfo "Mounting overlayfs at #{dst}"
    105     Linux.mount 'none', dst, 'overlay', 0,
    106                 "lowerdir=#{ENV['HOME']}/.wine,"\
    107                 "upperdir=#{opt.run_dir}/wine_upper,"\
    108                 "workdir=#{opt.run_dir}/wine_tmp,volatile"
    109 
    110     env.WINEPREFIX = dst
    111     # wine produces shittons of stub warnings in dbgeng while running the tests,
    112     # they're only needed for stacktraces and not critical, so just ignore them
    113     env.WINEDEBUG = 'fixme-dbgeng'
    114     run opt.run_dir, 'wine', *get_test_cmdline
    115     run opt.run_dir, 'wineserver', '-k'
    116   end
    117 ensure
    118   run opt.run_dir, clean
    119 end
    120 
    121 def qemu_step name, &blk
    122   cond = -> { blk[] && opt.get("#{name}_img") }
    123   test_step :"test_qemu_#{name}", cond: cond do
    124     cmd = get_test_cmdline
    125     cmd[0].delete_prefix! 'build/' or fail
    126     to_copy = opt.executables.map {|e| "build/#{opt.executable_pattern % e}" }
    127     to_copy << 'build/lua53.dll' if File.exist? 'build/lua53.dll'
    128 
    129     exe = rel_from File.join(opt.tools_dir, 'vmrun.sh'), opt.run_dir
    130     Linux.clonens_wait do
    131       Linux.up_lo
    132       img = opt.get "#{name}_img"
    133       run opt.run_dir, exe, img, '1234', cmd.winjoin, *to_copy
    134     end
    135   end
    136 end
    137 xp_cond = -> { opt.os == 'windows_xp' && opt.architecture == 'x86' }
    138 qemu_step "winxp_kvm", &xp_cond
    139 qemu_step "winxp_qemu", &xp_cond
    140 qemu_step "win7", &win_cond