From ca5307a8f03f72bc1c20e9fa11daddc309157cd3 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 29 Nov 2019 12:56:57 +0300 Subject: Use switch in buildfile --- libmysqlclient/mysql/buildfile | 99 ++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/libmysqlclient/mysql/buildfile b/libmysqlclient/mysql/buildfile index 8f8c8e8..85af149 100644 --- a/libmysqlclient/mysql/buildfile +++ b/libmysqlclient/mysql/buildfile @@ -13,12 +13,6 @@ bsd = ($tclass == 'bsd') macos = ($tclass == 'macos') windows = ($tclass == 'windows') -msvc_runtime = ($tsys == 'win32-msvc') - -gcc = ($c.class == 'gcc') -msvc = ($c.class == 'msvc') -clang_msvc = ($c.id == 'clang' && $msvc_runtime) - # Windows-specific utilities. # mysys_win32 = my_conio my_windac my_winerr my_winfile win_timers @@ -144,20 +138,17 @@ cc.poptions += -DHAVE_CONFIG_H \ -D_USE_MATH_DEFINES \ -DDBUG_OFF -if! $windows +switch $tclass { - cc.poptions += -D_FILE_OFFSET_BITS=64 + case 'windows' + cc.poptions += -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -DNOGDI \ + -DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_MBCS - if $linux - cc.poptions += -D_GNU_SOURCE -} -else -{ - cc.poptions += -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -DNOGDI -DNOMINMAX \ - -DWIN32_LEAN_AND_MEAN -D_MBCS + case 'linux' + cc.poptions += -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE - if $msvc - cc.coptions += /GS /fp:precise /Zc:wchar_t /Zc:forScope + default + cc.poptions += -D_FILE_OFFSET_BITS=64 } # Note that we add "-I$src_root" for the headers auto-generating machinery to @@ -201,50 +192,62 @@ else # Disable the 'POSIX name for this item is deprecated' warnings. # -if $clang_msvc +if ($c.id == 'clang' && $tsys == 'win32-msvc') cc.coptions += -Wno-deprecated-declarations -if $msvc +switch $c.class { - # Disable warnings that pop up with /W3. - # - cc.coptions += /wd4018 /wd4068 /wd4091 /wd4101 /wd4146 /wd4244 /wd4267 \ - /wd4477 /wd4700 /wd4805 /wd4996 -} -elif $gcc -{ - cc.coptions += -ffunction-sections -fdata-sections -fno-omit-frame-pointer - - # Disable warnings that pop up with -Wall -Wextra. Upstream doesn't seem to - # care about these and it is not easy to disable specific warnings in a way - # that works across compilers/version (some -Wno-* options are only - # recognized in newer versions). There are still some warnings left that - # appear for certain platforms/compilers. We pass them through but disable - # treating them as errors. - # - cc.coptions += -Wno-all -Wno-extra -Wno-error + case 'gcc' + { + cc.coptions += -ffunction-sections -fdata-sections -fno-omit-frame-pointer + + # Disable warnings that pop up with -Wall -Wextra. Upstream doesn't seem to + # care about these and it is not easy to disable specific warnings in a way + # that works across compilers/version (some -Wno-* options are only + # recognized in newer versions). There are still some warnings left that + # appear for certain platforms/compilers. We pass them through but disable + # treating them as errors. + # + cc.coptions += -Wno-all -Wno-extra -Wno-error + } + case 'msvc' + { + cc.coptions += /GS /fp:precise /Zc:wchar_t /Zc:forScope + + # Disable warnings that pop up with /W3. + # + cc.coptions += /wd4018 /wd4068 /wd4091 /wd4101 /wd4146 /wd4244 /wd4267 \ + /wd4477 /wd4700 /wd4805 /wd4996 + } } -if! $windows +switch $tclass, $tsys { - # On Linux the upstream package also passes the cmake-generated libmysql.ver - # file. The symbols it contains are hard-coded into libmysql/CMakeList.txt. - # We have dropped the file for now. - # - if $linux + case 'windows', 'mingw32' + cc.libs += -ladvapi32 + + case 'windows' + cc.libs += advapi32.lib + + case 'linux' { + # The upstream package also passes the cmake-generated libmysql.ver file. + # The symbols it contains are hard-coded into libmysql/CMakeList.txt. We + # have dropped the file for now. + # # Make sure all symbols are resolvable. # - libs{mysqlclient}: cc.loptions += -Wl,--no-undefined + cc.loptions += -Wl,--no-undefined + + cc.libs += -ldl -lpthread -lm -lrt } - cc.libs += ($bsd ? -lexecinfo : -ldl) -lpthread -lm + case 'bsd' + cc.libs += -lexecinfo -lpthread -lm - if $linux - cc.libs += -lrt # Posix timers. + default + cc.libs += -ldl -lpthread -lm } -else - cc.libs += $regex.apply(advapi32, '(.+)', $msvc_runtime ? '\1.lib' : '-l\1') # Export options. # -- cgit v1.1