From d48ce70c83bb7d149043df4f6b8dcd2067a2ec32 Mon Sep 17 00:00:00 2001 From: nillerusr Date: Mon, 24 Apr 2023 16:06:58 +0000 Subject: [PATCH] add macos workflow, fix filesystem_async max thread count --- .github/workflows/build.yml | 18 +++++++++++++++ .github/workflows/tests.yml | 9 ++++++++ appframework/sdlmgr.cpp | 2 +- appframework/wscript | 9 ++++---- bitmap/ImageByteSwap.cpp | 14 +++--------- bitmap/imageformat.cpp | 2 -- filesystem/filesystem_async.cpp | 11 +++++---- scripts/build-macos-amd64.sh | 8 +++++++ scripts/tests-macos-amd64.sh | 7 ++++++ tier2/renderutils.cpp | 2 +- utils/unittest/unittest.cpp | 2 +- wscript | 40 ++++++++++++++++++--------------- 12 files changed, 79 insertions(+), 45 deletions(-) create mode 100755 scripts/build-macos-amd64.sh create mode 100755 scripts/tests-macos-amd64.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c29e52e6c..39c8aadd99 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -91,3 +91,21 @@ jobs: - name: Build dedicated linux-amd64 run: | scripts/build-ubuntu-amd64.sh -d + + build-macos-amd64: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v2 + - name: Build macos-amd64 + run: | + scripts/build-macos-amd64.sh + + build-dedicated-macos-amd64: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v2 + - name: Build dedicated macos-amd64 + run: | + scripts/build-macos-amd64.sh -d diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c21d0a55aa..d8adc5ab08 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,6 +21,15 @@ jobs: run: | scripts/tests-ubuntu-amd64.sh + tests-macos-amd64: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v2 + - name: Run tests macos-amd64 + run: | + scripts/tests-macos-amd64.sh + tests-windows-i386: runs-on: windows-2019 diff --git a/appframework/sdlmgr.cpp b/appframework/sdlmgr.cpp index bad06f1b52..dd5ee2c234 100644 --- a/appframework/sdlmgr.cpp +++ b/appframework/sdlmgr.cpp @@ -2224,7 +2224,7 @@ GLMDisplayDB *CSDLMgr::GetDisplayDB( void ) } #ifndef OSX -# include "glmdisplaydb_linuxwin.inl" +#include "glmdisplaydb_linuxwin.inl" #endif diff --git a/appframework/wscript b/appframework/wscript index 0fea261a1c..f8ded31835 100755 --- a/appframework/wscript +++ b/appframework/wscript @@ -24,11 +24,10 @@ def build(bld): source += [ 'sdlmgr.cpp' ] - - if bld.env.DEST_OS == 'darwin': - source += [ - 'glmrendererinfo_osx.mm' - ] + + if bld.env.DEST_OS == 'darwin' and bld.env.GL: + source += ['glmrendererinfo_osx.mm'] + if bld.env.DEST_OS == 'win32': source += [ diff --git a/bitmap/ImageByteSwap.cpp b/bitmap/ImageByteSwap.cpp index 57217f1558..44fc5fa662 100644 --- a/bitmap/ImageByteSwap.cpp +++ b/bitmap/ImageByteSwap.cpp @@ -88,14 +88,7 @@ namespace ImageLoader Assert( IsFormatValidForConversion( imageFormat ) ); -#if !defined( DX_TO_GL_ABSTRACTION ) && !defined( NO_X360_XDK ) - if ( IsPC() ) - { - // running as a win32 tool, data is in expected order - // for conversion code - return; - } - +#ifdef _X360 // running on 360 and converting, input data must be x86 order // swap to ensure conversion code gets valid data XGENDIANTYPE xEndian; @@ -137,7 +130,7 @@ namespace ImageLoader { Assert( IsFormatValidForConversion( imageFormat ) ); -#if !defined( DX_TO_GL_ABSTRACTION ) && !defined( NO_X360_XDK ) +#ifdef _X360 // It would have been nice to use the 360 D3DFORMAT bit encodings, but the codes // are different for win32, and this routine is used by a win32 library to // manipulate 360 data, so there can be no reliance on D3DFORMAT bits @@ -201,7 +194,7 @@ namespace ImageLoader { Assert( IsFormatValidForConversion( imageFormat ) ); -#if !defined( DX_TO_GL_ABSTRACTION ) && !defined( NO_X360_XDK ) +#ifdef _X360 XGENDIANTYPE xEndian; switch ( imageFormat ) { @@ -256,5 +249,4 @@ namespace ImageLoader } #endif } - } diff --git a/bitmap/imageformat.cpp b/bitmap/imageformat.cpp index c2222653a4..6e2c99c183 100644 --- a/bitmap/imageformat.cpp +++ b/bitmap/imageformat.cpp @@ -288,13 +288,11 @@ int GetNumMipMapLevels( int width, int height, int depth ) // Turn off warning about FOURCC formats below... #pragma warning (disable:4063) -#ifdef DX_TO_GL_ABSTRACTION #ifndef MAKEFOURCC #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) #endif //defined(MAKEFOURCC) -#endif //----------------------------------------------------------------------------- // convert back and forth from D3D format to ImageFormat, regardless of // whether it's supported or not diff --git a/filesystem/filesystem_async.cpp b/filesystem/filesystem_async.cpp index 769ed017c2..493b1b7050 100644 --- a/filesystem/filesystem_async.cpp +++ b/filesystem/filesystem_async.cpp @@ -659,8 +659,9 @@ void CBaseFileSystem::InitAsync() Msg( "Async I/O disabled from command line\n" ); return; } - +#ifndef UNITTESTS if ( VCRGetMode() == VCR_Disabled ) +#endif { // create the i/o thread pool m_pThreadPool = CreateThreadPool(); @@ -668,7 +669,6 @@ void CBaseFileSystem::InitAsync() ThreadPoolStartParams_t params; params.iThreadPriority = 0; params.bIOThreads = true; - params.nThreadsMax = 4; // Limit count of IO threads to a maximum of 4. if ( IsX360() ) { // override defaults @@ -678,11 +678,10 @@ void CBaseFileSystem::InitAsync() params.bUseAffinityTable = true; params.iAffinityTable[0] = XBOX_PROCESSOR_3; } - else if( IsPC() ) + else { - // override defaults - // maximum # of async I/O thread on PC is 2 - params.nThreads = 1; + params.nThreadsMax = MIN(params.nThreads, 4); // Limit count of IO threads to a maximum of 4. + params.nStackSize = 256*1024; } if ( !m_pThreadPool->Start( params, "IOJob" ) ) diff --git a/scripts/build-macos-amd64.sh b/scripts/build-macos-amd64.sh new file mode 100755 index 0000000000..de0e8cfd1c --- /dev/null +++ b/scripts/build-macos-amd64.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +git submodule init && git submodule update + +brew install sdl2 + +./waf configure -T debug --64bits --disable-warns $* && +./waf build diff --git a/scripts/tests-macos-amd64.sh b/scripts/tests-macos-amd64.sh new file mode 100755 index 0000000000..ff4e46b278 --- /dev/null +++ b/scripts/tests-macos-amd64.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +git submodule init && git submodule update +./waf configure -T release --sanitize=address,undefined --disable-warns --tests -8 --prefix=out/ $* && +./waf install && +cd out && +DYLD_LIBRARY_PATH=bin/ ./unittest || exit 1 diff --git a/tier2/renderutils.cpp b/tier2/renderutils.cpp index 9b35e9fbac..1c4870d8d3 100644 --- a/tier2/renderutils.cpp +++ b/tier2/renderutils.cpp @@ -12,7 +12,7 @@ #include "materialsystem/imaterial.h" #include "tier0/vprof.h" #include "tier0/basetypes.h" -#ifndef DEDICATED +#ifdef DX_TO_GL_ABSTRACTION #include "togl/rendermechanism.h" #endif diff --git a/utils/unittest/unittest.cpp b/utils/unittest/unittest.cpp index 9135c67cf8..898e86e7ad 100644 --- a/utils/unittest/unittest.cpp +++ b/utils/unittest/unittest.cpp @@ -128,7 +128,7 @@ bool CUnitTestApp::Create() while ((dir = readdir(d)) != NULL) { int len = strlen(dir->d_name); - if( len > 2 && strcmp(dir->d_name+len-3, ".so") == 0) + if( len > 2 && strcmp(dir->d_name+len-strlen(DLL_EXT_STRING), DLL_EXT_STRING) == 0) { static char path[2048]; snprintf(path, sizeof(path), "tests/%s", dir->d_name); diff --git a/wscript b/wscript index 7441473c29..ada484c561 100644 --- a/wscript +++ b/wscript @@ -159,15 +159,17 @@ def define_platform(conf): conf.env.DEDICATED = conf.options.DEDICATED conf.env.TESTS = conf.options.TESTS conf.env.TOGLES = conf.options.TOGLES - conf.env.GL = conf.options.GL + conf.env.GL = conf.options.GL and not conf.options.TESTS and not conf.options.DEDICATED conf.env.OPUS = conf.options.OPUS if conf.options.DEDICATED: conf.options.SDL = False -# conf.options.GL = False conf.define('DEDICATED', 1) - if conf.options.GL and not conf.options.TESTS: + if conf.options.TESTS: + conf.define('UNITTESTS', 1) + + if conf.env.GL: conf.env.append_unique('DEFINES', [ 'DX_TO_GL_ABSTRACTION', 'GL_GLEXT_PROTOTYPES', @@ -177,6 +179,9 @@ def define_platform(conf): if conf.options.TOGLES: conf.env.append_unique('DEFINES', ['TOGLES']) + if conf.options.TESTS: + conf.define('UNITTESTS', 1) + if conf.options.SDL and not conf.options.TESTS: conf.env.SDL = 1 conf.define('USE_SDL', 1) @@ -323,6 +328,20 @@ def check_deps(conf): for i in a: conf.check_cc(lib = i) + if conf.env.DEST_OS == "darwin": + conf.check(lib='iconv', uselib_store='ICONV') + conf.env.FRAMEWORK_APPKIT = "AppKit" + conf.env.FRAMEWORK_IOKIT = "IOKit" + conf.env.FRAMEWORK_FOUNDATION = "Foundation" + conf.env.FRAMEWORK_COREFOUNDATION = "CoreFoundation" + conf.env.FRAMEWORK_COREGRAPHICS = "CoreGraphics" + conf.env.FRAMEWORK_OPENGL = "OpenGL" + conf.env.FRAMEWORK_CARBON = "Carbon" + conf.env.FRAMEWORK_APPLICATIONSERVICES = "ApplicationServices" + conf.env.FRAMEWORK_CORESERVICES = "CoreServices" + conf.env.FRAMEWORK_COREAUDIO = "CoreAudio" + conf.env.FRAMEWORK_AUDIOTOOLBOX = "AudioToolbox" + conf.env.FRAMEWORK_SYSTEMCONFIGURATION = "SystemConfiguration" if conf.options.TESTS: return @@ -361,21 +380,6 @@ def check_deps(conf): conf.check(lib='android_support', uselib_store='ANDROID_SUPPORT') conf.check(lib='opus', uselib_store='OPUS') - if conf.env.DEST_OS == "darwin": - conf.check(lib='iconv', uselib_store='ICONV') - conf.env.FRAMEWORK_APPKIT = "AppKit" - conf.env.FRAMEWORK_IOKIT = "IOKit" - conf.env.FRAMEWORK_FOUNDATION = "Foundation" - conf.env.FRAMEWORK_COREFOUNDATION = "CoreFoundation" - conf.env.FRAMEWORK_COREGRAPHICS = "CoreGraphics" - conf.env.FRAMEWORK_OPENGL = "OpenGL" - conf.env.FRAMEWORK_CARBON = "Carbon" - conf.env.FRAMEWORK_APPLICATIONSERVICES = "ApplicationServices" - conf.env.FRAMEWORK_CORESERVICES = "CoreServices" - conf.env.FRAMEWORK_COREAUDIO = "CoreAudio" - conf.env.FRAMEWORK_AUDIOTOOLBOX = "AudioToolbox" - conf.env.FRAMEWORK_SYSTEMCONFIGURATION = "SystemConfiguration" - if conf.env.DEST_OS == 'win32': conf.check(lib='libz', uselib_store='ZLIB', define_name='USE_ZLIB') # conf.check(lib='nvtc', uselib_store='NVTC')