Add support for i686-win

This commit is contained in:
Tamás Bálint Misius 2021-03-12 21:02:02 +01:00
parent cc2022504a
commit 36e9fdc39d
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
18 changed files with 155 additions and 47 deletions

21
.github/build.sh vendored
View File

@ -4,15 +4,21 @@ set -euo pipefail
IFS=$'\n\t'
if [ -z "${PLATFORM_SHORT-}" ]; then
>&2 echo "PLATFORM_SHORT not set"
>&2 echo "PLATFORM_SHORT not set (lin, mac, win)"
exit 1
fi
if [ -z "${MACHINE_SHORT-}" ]; then
>&2 echo "MACHINE_SHORT not set (x86_64, i686)"
exit 1
fi
if [ -z "${TOOLSET_SHORT-}" ]; then
>&2 echo "TOOLSET_SHORT not set (gcc, clang, mingw)"
exit 1
fi
if [ -z "${STATIC_DYNAMIC-}" ]; then
>&2 echo "STATIC_DYNAMIC not set"
>&2 echo "STATIC_DYNAMIC not set (static, dynamic)"
exit 1
fi
if [ -z "${RELTYPECFG-}" ]; then
>&2 echo "RELTYPECFG not set"
exit 1
@ -23,9 +29,14 @@ if [ -z "${build_sh_init-}" ]; then
for i in C:/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/**/**/VC/Auxiliary/Build/vcvarsall.bat; do
vcvarsall_path=$i
done
if [ $MACHINE_SHORT == "x86_64" ]; then
x64_x86=x64
else
x64_x86=x86
fi
cat << BUILD_INIT_BAT > .github/build_init.bat
@echo off
call "${vcvarsall_path}" x64
call "${vcvarsall_path}" ${x64_x86}
bash -c 'build_sh_init=1 ./.github/build.sh'
BUILD_INIT_BAT
./.github/build_init.bat

View File

@ -39,8 +39,32 @@ jobs:
needs: [release]
strategy:
matrix:
# | lin-x86_64 | mac-x86_64 | win-x86_64 | lin-i686 | mac-i686 | win-i686 |
# --------------+------------+------------+------------+------------+------------+------------+
# gcc-static | | | NO | NO | NO | NO |
# msvc-static | NO | NO | | NO | NO | |
# mingw-static | NO | NO | NO | NO | NO | NO [1] |
# gcc-dynamic | | | NO | NO | NO | NO |
# msvc-dynamic | NO | NO | | NO | NO | |
# mingw-dynamic | NO | NO | NO | NO | NO | NO |
#
# [1] I don't currently care enough about mingw to figure out how to do this.
platform_short: [lin, mac, win]
toolset_short: [gcc, msvc, mingw]
machine_short: [x86_64, i686]
static_dynamic: [static, dynamic]
exclude:
- toolset_short: mingw
- machine_short: i686
platform_short: lin
- machine_short: i686
platform_short: mac
- toolset_short: msvc
platform_short: lin
- toolset_short: msvc
platform_short: mac
- toolset_short: gcc
platform_short: win
include:
- platform_short: lin
os: ubuntu-latest
@ -69,7 +93,7 @@ jobs:
- if: matrix.platform_short == 'lin' && matrix.static_dynamic != 'static'
run: sudo apt update && sudo apt install libluajit-5.1-dev libcurl4-openssl-dev libfftw3-dev zlib1g-dev libsdl2-dev
- run: python -m pip install meson ninja
- run: bash -c 'PLATFORM_SHORT=${{ matrix.platform_short }} STATIC_DYNAMIC=${{ matrix.static_dynamic }} RELTYPECFG=${{ steps.get_type.outputs.RELTYPECFG }} ./.github/build.sh'
- run: bash -c 'PLATFORM_SHORT=${{ matrix.platform_short }} MACHINE_SHORT=${{ matrix.machine_short }} TOOLSET_SHORT=${{ matrix.toolset_short }} STATIC_DYNAMIC=${{ matrix.static_dynamic }} RELTYPECFG=${{ steps.get_type.outputs.RELTYPECFG }} ./.github/build.sh'
- uses: actions/upload-release-asset@v1
if: steps.get_type.outputs.TYPE != 'dev' && matrix.static_dynamic == 'static'
env:
@ -77,10 +101,10 @@ jobs:
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: powder${{ matrix.suffix }}
asset_name: powder-${{ steps.get_type.outputs.NAME }}-${{ matrix.platform_short }}64${{ matrix.suffix }}
asset_name: powder-${{ steps.get_type.outputs.NAME }}-${{ matrix.machine_short }}-${{ matrix.platform_short }}-${{ matrix.toolset_short }}-${{ matrix.static_dynamic }}${{ matrix.suffix }}
asset_content_type: application/zip
- uses: actions/upload-artifact@v2
if: steps.get_type.outputs.TYPE == 'dev' && matrix.static_dynamic == 'static'
with:
path: powder${{ matrix.suffix }}
name: powder-${{ steps.get_type.outputs.NAME }}-${{ matrix.static_dynamic }}-${{ matrix.platform_short }}64${{ matrix.suffix }}
name: powder-${{ steps.get_type.outputs.NAME }}-${{ matrix.machine_short }}-${{ matrix.platform_short }}-${{ matrix.toolset_short }}-${{ matrix.static_dynamic }}${{ matrix.suffix }}

View File

@ -18,6 +18,24 @@ copt_x86 = host_machine.cpu_family() in [ 'x86_64', 'x86' ]
copt_64bit = host_machine.cpu_family() in [ 'x86_64', 'aarch64' ]
copt_msvc = cpp_compiler.get_id() in [ 'msvc' ]
if cpp_compiler.get_id() in [ 'msvc' ]
copt_compiler = 'msvc'
elif cpp_compiler.get_id() in [ 'gcc' ]
copt_compiler = 'gcc'
else
warning('unsupported compiler: ' + cpp_compiler.get_id() + '; you are on your own')
copt_compiler = 'gcc'
endif
if host_machine.cpu_family() in [ 'x86_64' ]
copt_architecture = 'x86_64'
elif host_machine.cpu_family() in [ 'x86' ]
copt_architecture = 'i686'
else
warning('unsupported architecture: ' + host_machine.cpu_family() + '; you are on your own')
copt_architecture = 'i686'
endif
if host_machine.system() in [ 'linux', 'freebsd' ]
copt_platform = 'lin'
elif host_machine.system() in [ 'windows' ]
@ -25,7 +43,8 @@ elif host_machine.system() in [ 'windows' ]
elif host_machine.system() in [ 'darwin' ]
copt_platform = 'mac'
else
error('unsupported platform: ' + host_machine.system())
warning('unsupported platform: ' + host_machine.system() + '; you are on your own')
copt_platform = 'lin'
endif
if get_option('ogli') or get_option('oglr')
@ -34,7 +53,7 @@ endif
uopt_static = get_option('static')
use_tpt_libs = 'no'
tpt_libs_vtag = 'v20210103095432'
tpt_libs_vtag = 'v20210320221332'
if uopt_static == 'system'
if copt_platform == 'win'
error('no way to find static system libraries on windows')
@ -47,10 +66,26 @@ else
endif
endif
if use_tpt_libs != 'no'
if host_machine.cpu_family() != 'x86_64'
error('we do not currently provide prebuilt @0@ libraries for @1@ on @2@'.format(use_tpt_libs, host_machine.system(), host_machine.cpu_family()))
nope = false
if copt_architecture == 'i686' and (copt_platform != 'win' or copt_compiler != 'msvc')
nope = true
endif
tpt_libs = subproject('tpt-libs-prebuilt-@0@64-@1@-@2@'.format(copt_platform, use_tpt_libs, tpt_libs_vtag))
if copt_architecture == 'x86_64' and (copt_platform == 'lin' or copt_platform == 'mac') and copt_compiler != 'gcc'
nope = true
endif
if copt_architecture == 'x86_64' and copt_platform == 'win' and copt_compiler == 'gcc'
nope = true
endif
quad_compiler = copt_compiler
if use_tpt_libs == 'dynamic' and copt_platform == 'win'
# DLLs should be compatible with anything, right?
quad_compiler = 'msvc'
endif
quad = '@0@-@1@-@2@-@3@'.format(copt_architecture, copt_platform, quad_compiler, use_tpt_libs)
if nope
error('no prebuilt @0@ libraries are currently provided'.format(quad))
endif
tpt_libs = subproject('tpt-libs-prebuilt-@0@-@1@'.format(quad, tpt_libs_vtag))
endif
uopt_native = get_option('native')
@ -179,14 +214,15 @@ endif
if copt_platform == 'win'
other_dep = tpt_libs.get_variable('other_dep')
sdl2main_dep = tpt_libs.get_variable('sdl2main_dep')
args_ccomp_win = [ '-D_WIN32_WINNT=0x0501' ]
project_c_args += args_ccomp_win
project_cpp_args += args_ccomp_win
windows_mod = import('windows')
if uopt_static != 'none'
conf_data.set('CURL_STATICLIB', true)
conf_data.set('ZLIB_WINAPI', true)
if copt_architecture == 'x86_64'
conf_data.set('ZLIB_WINAPI', true)
endif
else
foreach input_and_output : tpt_libs.get_variable('config_dlls')
configure_file(input: input_and_output[0], output: input_and_output[1], copy: true)
@ -252,7 +288,6 @@ if get_option('build_powder')
]
if copt_platform == 'win'
powder_deps += other_dep
powder_deps += sdl2main_dep
endif
executable(
'powder',
@ -292,7 +327,6 @@ if get_option('build_font')
]
if copt_platform == 'win'
font_deps += other_dep
font_deps += sdl2main_dep
endif
executable(
'font',

View File

@ -29,7 +29,7 @@ ByteString ExecutableName()
ByteString ret;
#if defined(WIN)
using Char = wchar_t;
#else
#elif defined(LIN)
using Char = char;
#endif
#if defined(WIN)
@ -209,3 +209,24 @@ std::wstring WinWiden(const ByteString &source)
#endif
}
#ifdef WIN
# undef main // thank you sdl
int main(int argc, char *argv[]);
int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
int argc;
wchar_t **wargv = CommandLineToArgvW(GetCommandLineW(), &argc);
std::vector<ByteString> argv;
for (auto i = 0; i < argc; ++i)
{
argv.push_back(Platform::WinNarrow(std::wstring(wargv[i])));
}
std::vector<char *> argp;
for (auto &arg : argv)
{
argp.push_back(&arg[0]);
}
return main(argc, &argp[0]);
}
#endif

View File

@ -430,6 +430,10 @@ void EngineProcess()
#endif
}
#ifdef main
# undef main // thank you sdl
#endif
int main(int argc, char * argv[])
{
currentWidth = WINDOWW;

View File

@ -54,12 +54,8 @@ void writeFile(ByteString filename, std::vector<char> & fileData)
}
}
// * On windows, sdl2 (which gets included somewhere along the way) defines
// main away to some identifier which sdl2main calls. The renderer is not
// linked against sdl2main, so we get an undefined reference to main. This
// can be fixed by removing the macro.
#ifdef main
# undef main
# undef main // thank you sdl
#endif
int main(int argc, char *argv[])

View File

@ -693,6 +693,10 @@ int GuessBestScale()
return guess;
}
#ifdef main
# undef main // thank you sdl
#endif
int main(int argc, char * argv[])
{
#if defined(_DEBUG) && defined(_MSC_VER)

View File

@ -377,7 +377,9 @@ static int opt_ip6_setmembership(lua_State *L, p_socket ps, int level, int name)
lua_gettable(L, 3);
if (!lua_isstring(L, -1))
luaL_argerror(L, 3, "string 'multiaddr' field expected");
#ifndef _WIN32 // for some reason, this just doesn't seem to want to exist in ws2_32 on win32 but works fine on win64 -- LBPHacker
if (!inet_pton(AF_INET6, lua_tostring(L, -1), &val.ipv6mr_multiaddr))
#endif
luaL_argerror(L, 3, "invalid 'multiaddr' ip address");
lua_pushstring(L, "interface");
lua_gettable(L, 3);

View File

@ -0,0 +1,6 @@
[wrap-file]
directory = tpt-libs-prebuilt-i686-win-msvc-dynamic-v20210320221332
source_url = https://github.com/The-Powder-Toy/tpt-libs/releases/download/v20210320221332/tpt-libs-prebuilt-i686-win-msvc-dynamic-v20210320221332.zip
source_filename = tpt-libs-prebuilt-i686-win-msvc-dynamic-v20210320221332.zip
source_hash = 9589cc47f30bb1f1b19496d5355bade6a8fe84c09de5f4ce4ce394386c3cdb95

View File

@ -0,0 +1,6 @@
[wrap-file]
directory = tpt-libs-prebuilt-i686-win-msvc-static-v20210320221332
source_url = https://github.com/The-Powder-Toy/tpt-libs/releases/download/v20210320221332/tpt-libs-prebuilt-i686-win-msvc-static-v20210320221332.zip
source_filename = tpt-libs-prebuilt-i686-win-msvc-static-v20210320221332.zip
source_hash = c3f8174885766df351be0597dc98315bb99e4b39a58d3b2d629956642b6c64bf

View File

@ -1,6 +0,0 @@
[wrap-file]
directory = tpt-libs-prebuilt-lin64-static-v20210103095432
source_url = https://github.com/The-Powder-Toy/tpt-libs/releases/download/v20210103095432/tpt-libs-prebuilt-lin64-static-v20210103095432.zip
source_filename = tpt-libs-prebuilt-lin64-static-v20210103095432.zip
source_hash = d2ede0e8fb54802789cbd729397cb8083151cbbf8219cdc0d70844e0a03196f4

View File

@ -1,6 +0,0 @@
[wrap-file]
directory = tpt-libs-prebuilt-mac64-static-v20210103095432
source_url = https://github.com/The-Powder-Toy/tpt-libs/releases/download/v20210103095432/tpt-libs-prebuilt-mac64-static-v20210103095432.zip
source_filename = tpt-libs-prebuilt-mac64-static-v20210103095432.zip
source_hash = 5b1e20dd5ef6bd4220cb6d3cc8b5aa5d3ae20a8b89ec05ef56958fcf58085e7a

View File

@ -1,6 +0,0 @@
[wrap-file]
directory = tpt-libs-prebuilt-win64-dynamic-v20210103095432
source_url = https://github.com/The-Powder-Toy/tpt-libs/releases/download/v20210103095432/tpt-libs-prebuilt-win64-dynamic-v20210103095432.zip
source_filename = tpt-libs-prebuilt-win64-dynamic-v20210103095432.zip
source_hash = 84226bce4c89028479f9c41860cfae3ed07bfbabf9f4316f11cffa0bf8964624

View File

@ -1,6 +0,0 @@
[wrap-file]
directory = tpt-libs-prebuilt-win64-static-v20210103095432
source_url = https://github.com/The-Powder-Toy/tpt-libs/releases/download/v20210103095432/tpt-libs-prebuilt-win64-static-v20210103095432.zip
source_filename = tpt-libs-prebuilt-win64-static-v20210103095432.zip
source_hash = b60bc426655e9bb8583998aff5c004ed3e61c3ceac7b28c3a9834bef46c43437

View File

@ -0,0 +1,6 @@
[wrap-file]
directory = tpt-libs-prebuilt-x86_64-lin-gcc-static-v20210320221332
source_url = https://github.com/The-Powder-Toy/tpt-libs/releases/download/v20210320221332/tpt-libs-prebuilt-x86_64-lin-gcc-static-v20210320221332.zip
source_filename = tpt-libs-prebuilt-x86_64-lin-gcc-static-v20210320221332.zip
source_hash = 9b2c0031f724e3f66447f74f3975af8da9f9fa4dff717f21e58dd3ef525af7a9

View File

@ -0,0 +1,6 @@
[wrap-file]
directory = tpt-libs-prebuilt-x86_64-mac-gcc-static-v20210320221332
source_url = https://github.com/The-Powder-Toy/tpt-libs/releases/download/v20210320221332/tpt-libs-prebuilt-x86_64-mac-gcc-static-v20210320221332.zip
source_filename = tpt-libs-prebuilt-x86_64-mac-gcc-static-v20210320221332.zip
source_hash = 478f9fe93376439b2b9f07f22009433a264ebb40f11fa493f6b12f6540392125

View File

@ -0,0 +1,6 @@
[wrap-file]
directory = tpt-libs-prebuilt-x86_64-win-msvc-dynamic-v20210320221332
source_url = https://github.com/The-Powder-Toy/tpt-libs/releases/download/v20210320221332/tpt-libs-prebuilt-x86_64-win-msvc-dynamic-v20210320221332.zip
source_filename = tpt-libs-prebuilt-x86_64-win-msvc-dynamic-v20210320221332.zip
source_hash = 622b81d1438857e9bf955ed59035e2e99d050b53f4a04befbb4feda4a259e68d

View File

@ -0,0 +1,6 @@
[wrap-file]
directory = tpt-libs-prebuilt-x86_64-win-msvc-static-v20210320221332
source_url = https://github.com/The-Powder-Toy/tpt-libs/releases/download/v20210320221332/tpt-libs-prebuilt-x86_64-win-msvc-static-v20210320221332.zip
source_filename = tpt-libs-prebuilt-x86_64-win-msvc-static-v20210320221332.zip
source_hash = 20d647a5fd64c1bb7118ed8843c21845bcf648f39efa925b2a38757c0eb8f562