From 9af9b5f205cfd588a16e1164bd033c22ce2107fc Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 8 Feb 2014 16:09:29 -0800 Subject: [PATCH] Port AMBuild scripts to Windows. --- AMBuildScript | 36 ++++++++++++++++++++++++++++++++++++ amxmodx/AMBuilder | 7 +++++++ compiler/amxxpc/AMBuilder | 9 +++++++-- dlls/geoip/AMBuilder | 3 +++ dlls/regex/AMBuilder | 2 ++ dlls/sockets/AMBuilder | 3 +++ dlls/sqlite/AMBuilder | 17 ++++++++++++++--- 7 files changed, 72 insertions(+), 5 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index af8abe5b..bcea765e 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -117,6 +117,42 @@ class AMXXConfig(object): '-fno-exceptions', '-fno-rtti', ] + elif cxx.name == 'msvc': + if builder.options.debug == '1': + cfg.cflags += ['/MTd'] + cfg.linkflags += ['/NODEFAULTLIB:libcmt'] + else: + cfg.cflags += ['/MT'] + cfg.defines += [ + '_CRT_SECURE_NO_DEPRECATE', + '_CRT_SECURE_NO_WARNINGS', + '_CRT_NONSTDC_NO_DEPRECATE', + '_ITERATOR_DEBUG_LEVEL=0', + ] + cfg.cflags += [ + '/W3', + ] + cfg.cxxflags += [ + '/EHsc', + '/GR-', + '/TP', + ] + cfg.linkflags += [ + '/MACHINE:X86', + '/SUBSYSTEM:WINDOWS', + 'kernel32.lib', + 'user32.lib', + 'gdi32.lib', + 'winspool.lib', + 'comdlg32.lib', + 'advapi32.lib', + 'shell32.lib', + 'ole32.lib', + 'oleaut32.lib', + 'uuid.lib', + 'odbc32.lib', + 'odbccp32.lib', + ] # Optimization if builder.options.opt == '1': diff --git a/amxmodx/AMBuilder b/amxmodx/AMBuilder index b114c591..df90d73d 100644 --- a/amxmodx/AMBuilder +++ b/amxmodx/AMBuilder @@ -23,6 +23,13 @@ elif builder.target_platform == 'linux': binary.Dep('JIT/natives-x86.o'), binary.Dep('JIT/helpers-x86.o'), ] +elif builder.target_platform == 'windows': + jit_objects = [ + binary.Dep('JIT/amxexecn.obj'), + binary.Dep('JIT/amxjitsn.obj'), + binary.Dep('JIT/helpers-x86.obj'), + binary.Dep('JIT/natives-x86.obj'), + ] binary.compiler.linkflags += jit_objects diff --git a/compiler/amxxpc/AMBuilder b/compiler/amxxpc/AMBuilder index 6d26f9e0..8ecdb096 100644 --- a/compiler/amxxpc/AMBuilder +++ b/compiler/amxxpc/AMBuilder @@ -6,7 +6,9 @@ binary = AMXX.Program(builder, 'amxxpc') binary.compiler.defines += [ 'AMX_ANSIONLY', ] -binary.compiler.cxxflags.remove('-fno-exceptions') + +if builder.target_platform != 'windows': + binary.compiler.cxxflags.remove('-fno-exceptions') if builder.target_platform == 'linux': binary.compiler.postlink += [ @@ -16,7 +18,10 @@ if builder.target_platform == 'linux': elif builder.target_platform == 'mac': binary.compiler.postlink += [binary.Dep('libz-darwin.a')] elif builder.target_platform == 'windows': - binary.compiler.postlink += [binary.Dep('zlib.lib')] + binary.compiler.defines += ['_MBCS'] + binary.compiler.linkflags += [binary.Dep('zlib.lib')] + binary.compiler.linkflags.remove('/SUBSYSTEM:WINDOWS') + binary.compiler.linkflags.append('/SUBSYSTEM:CONSOLE') binary.sources = [ 'amx.cpp', diff --git a/dlls/geoip/AMBuilder b/dlls/geoip/AMBuilder index 8d0b0d01..cd3ce025 100644 --- a/dlls/geoip/AMBuilder +++ b/dlls/geoip/AMBuilder @@ -9,4 +9,7 @@ binary.sources = [ 'geoip_amxx.cpp', ] +if builder.target_platform == 'windows': + binary.compiler.postlink += ['ws2_32.lib'] + AMXX.modules += [builder.Add(binary)] diff --git a/dlls/regex/AMBuilder b/dlls/regex/AMBuilder index cdb16f33..d1436354 100644 --- a/dlls/regex/AMBuilder +++ b/dlls/regex/AMBuilder @@ -10,6 +10,8 @@ elif builder.target_platform == 'mac': elif builder.target_platform == 'windows': binary.compiler.postlink += [binary.Dep('lib_win\\pcre.lib')] +binary.compiler.defines += ['PCRE_STATIC'] + binary.sources = [ 'sdk/amxxmodule.cpp', 'module.cpp', diff --git a/dlls/sockets/AMBuilder b/dlls/sockets/AMBuilder index f6e7cd15..cbdf3ad8 100644 --- a/dlls/sockets/AMBuilder +++ b/dlls/sockets/AMBuilder @@ -8,4 +8,7 @@ binary.sources = [ 'sockets.cpp', ] +if builder.target_platform == 'windows': + binary.compiler.postlink += ['wsock32.lib', 'ws2_32.lib'] + AMXX.modules += [builder.Add(binary)] diff --git a/dlls/sqlite/AMBuilder b/dlls/sqlite/AMBuilder index 62c06cd4..3d2903df 100644 --- a/dlls/sqlite/AMBuilder +++ b/dlls/sqlite/AMBuilder @@ -5,6 +5,7 @@ binary = AMXX.MetaModule(builder, 'sqlite') binary.compiler.cxxincludes += [ os.path.join(builder.currentSourcePath, 'sqlitepp'), os.path.join(builder.currentSourcePath, 'thread'), + os.path.join(builder.currentSourcePath, 'sqlite-source'), ] binary.compiler.defines += [ 'SM_DEFAULT_THREADER', @@ -14,7 +15,7 @@ binary.compiler.defines += [ if builder.target_platform == 'linux': binary.compiler.postlink += ['-lpthread'] -binary.sources = [ +binary.sources += [ 'basic_sql.cpp', 'handles.cpp', 'module.cpp', @@ -23,7 +24,6 @@ binary.sources = [ 'oldcompat_sql.cpp', 'thread/BaseWorker.cpp', 'thread/ThreadWorker.cpp', - 'thread/PosixThreads.cpp', 'sqlitepp/SqliteQuery.cpp', 'sqlitepp/SqliteResultSet.cpp', 'sqlitepp/SqliteDatabase.cpp', @@ -47,7 +47,6 @@ binary.sources = [ 'sqlite-source/main.c', 'sqlite-source/opcodes.c', 'sqlite-source/os.c', - 'sqlite-source/os_unix.c', 'sqlite-source/pager.c', 'sqlite-source/parse.c', 'sqlite-source/pragma.c', @@ -71,4 +70,16 @@ binary.sources = [ 'sqlite-source/where.c', ] +if builder.target_platform == 'windows': + binary.sources += [ + 'thread/WinThreads.cpp', + 'sqlite-source/os_win.c', + ] +else: + binary.sources += [ + 'thread/PosixThreads.cpp', + 'sqlite-source/os_unix.c', + ] + + AMXX.modules += [builder.Add(binary)]