diff --git a/.gitignore b/.gitignore index 75af3bbf..8692a2f5 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,5 @@ Thumbs.db # AMXX plugin build related files plugins/compile.dat plugins/compiled/ + +build_deps/ diff --git a/.travis.yml b/.travis.yml index 0237f218..5dfce31c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ addons: - linux-libc-dev - gcc-multilib - g++-multilib + - nasm sources: - llvm-toolchain-precise-3.7 - ubuntu-toolchain-r-test @@ -23,4 +24,4 @@ script: - mkdir build && cd build - PATH="~/.local/bin:$PATH" - CC=clang-3.7 CXX=clang-3.7 python ../configure.py --enable-optimize - - ambuild \ No newline at end of file + - ambuild diff --git a/AMBuildScript b/AMBuildScript index 7c4388bf..12f361ed 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -20,6 +20,7 @@ class AMXXConfig(object): self.utf8rewind = None self.csx_app = None self.stdcxx_path = None + self.nasm_path = None def use_auto_versioning(self): if builder.backend != 'amb2': @@ -105,6 +106,31 @@ class AMXXConfig(object): if not self.mysql_path: raise Exception('Could not find MySQL! Try passing --mysql to configure.py.') + def detectNASM(self): + import subprocess + + nasm_paths = [ + getattr(builder.options, 'nasm_path', 'nasm'), + ] + if builder.target_platform == 'windows': + nasm_paths += [os.path.join( + builder.sourcePath, + 'build_deps', + 'nasm', + 'nasm.exe') + ] + + for nasm_path in nasm_paths: + try: + subprocess.check_output([nasm_path, '-v']) + self.nasm_path = nasm_path + break + except: + pass + + if self.nasm_path is None: + raise Exception('Could not find a suitable path for nasm') + # Returns list of lines of output from the compiler @staticmethod def invokeCompiler(args): @@ -369,11 +395,42 @@ class AMXXConfig(object): binary = context.compiler.Program(name) return self.AddVersioning(binary) + def AddAssembly(self, context, binary, input_file, output_file, includes=[], extra_argv=[]): + if builder.target_platform == 'windows': + obj_type = 'win32' + elif builder.target_platform == 'linux': + obj_type = 'elf32' + elif builder.target_platform == 'mac': + obj_type = 'macho32' + + input_path = os.path.join(context.currentSourcePath, input_file) + output_path = output_file + + argv = [ + self.nasm_path, + '-I{0}{1}'.format(context.currentSourcePath, os.sep), + input_path, + '-f', obj_type, + '-o', output_path, + ] + extra_argv + + extra_includes = [] + for include_file in includes: + extra_includes.append(os.path.join(context.currentSourcePath, include_file)) + + cmd_node, output_nodes = context.AddCommand( + inputs = [input_path] + extra_includes, + argv = argv, + outputs = [output_path]) + + binary.compiler.linkflags += [output_nodes[0]] + AMXX = AMXXConfig() AMXX.detectProductVersion() AMXX.detectMetamod() AMXX.detectHlsdk() AMXX.detectMysql() +AMXX.detectNASM() AMXX.configure() if AMXX.use_auto_versioning(): diff --git a/amxmodx/AMBuilder b/amxmodx/AMBuilder index 92da4709..815271f7 100644 --- a/amxmodx/AMBuilder +++ b/amxmodx/AMBuilder @@ -9,36 +9,25 @@ binary.compiler.defines += [ 'HAVE_STDINT_H', ] +AMXX.AddAssembly(builder, binary, 'helpers-x86.asm', 'helpers-asm.obj') +AMXX.AddAssembly(builder, binary, 'natives-x86.asm', 'natives-asm.obj') +AMXX.AddAssembly(builder, binary, 'amxexecn.asm', 'amxexecn-asm.obj', + includes=['amxdefn.asm']) +AMXX.AddAssembly(builder, binary, 'amxjitsn.asm', 'amxjitsn-asm.obj', + includes=['amxdefn.asm'], + # Opcode sizes must be maximum width for patching to work. + extra_argv=['-O0']) + if builder.target_platform == 'mac': - jit_objects = [ - binary.Dep('JIT/amxexecn-darwin.o'), - binary.Dep('JIT/amxjitsn-darwin.o'), - binary.Dep('JIT/natives-darwin-x86.o'), - binary.Dep('JIT/helpers-darwin-x86.o'), - ] binary.compiler.postlink += [ '-Wl,-read_only_relocs,suppress' ] -elif builder.target_platform == 'linux': - jit_objects = [ - binary.Dep('JIT/amxexecn.o'), - binary.Dep('JIT/amxjitsn.o'), - 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 += [ '/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1', '/SECTION:.data,RW', ] -binary.compiler.linkflags += jit_objects binary.compiler.linkflags += [AMXX.zlib.binary, AMXX.hashing.binary, AMXX.utf8rewind.binary] binary.sources = [ diff --git a/amxmodx/JIT/amxexecn-darwin.o b/amxmodx/JIT/amxexecn-darwin.o deleted file mode 100644 index b215a7fb..00000000 Binary files a/amxmodx/JIT/amxexecn-darwin.o and /dev/null differ diff --git a/amxmodx/JIT/amxexecn.o b/amxmodx/JIT/amxexecn.o deleted file mode 100755 index a4970395..00000000 Binary files a/amxmodx/JIT/amxexecn.o and /dev/null differ diff --git a/amxmodx/JIT/amxexecn.obj b/amxmodx/JIT/amxexecn.obj deleted file mode 100755 index ba9b1d77..00000000 Binary files a/amxmodx/JIT/amxexecn.obj and /dev/null differ diff --git a/amxmodx/JIT/amxjitsn-darwin.o b/amxmodx/JIT/amxjitsn-darwin.o deleted file mode 100644 index 1a6d578d..00000000 Binary files a/amxmodx/JIT/amxjitsn-darwin.o and /dev/null differ diff --git a/amxmodx/JIT/amxjitsn.o b/amxmodx/JIT/amxjitsn.o deleted file mode 100755 index 2a4375ed..00000000 Binary files a/amxmodx/JIT/amxjitsn.o and /dev/null differ diff --git a/amxmodx/JIT/amxjitsn.obj b/amxmodx/JIT/amxjitsn.obj deleted file mode 100755 index c96c9a8e..00000000 Binary files a/amxmodx/JIT/amxjitsn.obj and /dev/null differ diff --git a/amxmodx/JIT/helpers-darwin-x86.o b/amxmodx/JIT/helpers-darwin-x86.o deleted file mode 100644 index 38447509..00000000 Binary files a/amxmodx/JIT/helpers-darwin-x86.o and /dev/null differ diff --git a/amxmodx/JIT/helpers-x86.o b/amxmodx/JIT/helpers-x86.o deleted file mode 100644 index 1d7e9590..00000000 Binary files a/amxmodx/JIT/helpers-x86.o and /dev/null differ diff --git a/amxmodx/JIT/helpers-x86.obj b/amxmodx/JIT/helpers-x86.obj deleted file mode 100644 index d9268b7f..00000000 Binary files a/amxmodx/JIT/helpers-x86.obj and /dev/null differ diff --git a/amxmodx/JIT/natives-amd64.o b/amxmodx/JIT/natives-amd64.o deleted file mode 100755 index ed6413e2..00000000 Binary files a/amxmodx/JIT/natives-amd64.o and /dev/null differ diff --git a/amxmodx/JIT/natives-darwin-x86.o b/amxmodx/JIT/natives-darwin-x86.o deleted file mode 100644 index 9ad779d2..00000000 Binary files a/amxmodx/JIT/natives-darwin-x86.o and /dev/null differ diff --git a/amxmodx/JIT/natives-x86.o b/amxmodx/JIT/natives-x86.o deleted file mode 100755 index b8f58393..00000000 Binary files a/amxmodx/JIT/natives-x86.o and /dev/null differ diff --git a/amxmodx/JIT/natives-x86.obj b/amxmodx/JIT/natives-x86.obj deleted file mode 100755 index 60855c6a..00000000 Binary files a/amxmodx/JIT/natives-x86.obj and /dev/null differ diff --git a/amxmodx/msvc12/amxmodx_mm.vcxproj b/amxmodx/msvc12/amxmodx_mm.vcxproj index 5ced2abd..e1675884 100644 --- a/amxmodx/msvc12/amxmodx_mm.vcxproj +++ b/amxmodx/msvc12/amxmodx_mm.vcxproj @@ -96,6 +96,14 @@ false .data,RW + + cd .. +md -p JIT 2>NUL +%NASM_PATH%nasm.exe -f win32 helpers-x86.asm -o JIT/helpers-x86.obj +%NASM_PATH%nasm.exe -f win32 natives-x86.asm -o JIT/natives-x86.obj +%NASM_PATH%nasm.exe -f win32 amxexecn.asm -o JIT/amxexecn.obj +%NASM_PATH%nasm.exe -O0 -f win32 amxjitsn.asm -o JIT/amxjitsn.obj + @@ -148,6 +156,14 @@ false .data,RW + + cd .. +md -p JIT 2>NUL +%NASM_PATH%nasm.exe -f win32 helpers-x86.asm -o JIT/helpers-x86.obj +%NASM_PATH%nasm.exe -f win32 natives-x86.asm -o JIT/natives-x86.obj +%NASM_PATH%nasm.exe -f win32 amxexecn.asm -o JIT/amxexecn.obj +%NASM_PATH%nasm.exe -O0 -f win32 amxjitsn.asm -o JIT/amxjitsn.obj + @@ -474,4 +490,4 @@ - + \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 6fa4a461..71556206 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,6 +3,11 @@ clone_folder: c:\projects\amxmodx install: - git submodule update --init --recursive - 'c:' +- mkdir c:\nasm +- set PATH=c:\nasm\nasm-2.13.03;%PATH% +- curl -o "c:\nasm\nasm.zip" http://www.nasm.us/pub/nasm/releasebuilds/2.13.03/win32/nasm-2.13.03-win32.zip +- chdir c:\nasm +- 7z x nasm.zip - chdir c:\projects - git clone https://github.com/alliedmodders/ambuild - git clone https://github.com/alliedmodders/metamod-hl1 @@ -22,5 +27,5 @@ build_script: - '"%VS120COMNTOOLS%\vsvars32.bat"' - mkdir build - cd build -- c:\python27\python ../configure.py --enable-optimize -- c:\python27\scripts\ambuild \ No newline at end of file +- c:\python27\python ../configure.py --enable-optimize --nasm="C:\nasm\nasm-2.13.03\nasm.exe" +- c:\python27\scripts\ambuild diff --git a/configure.py b/configure.py index 6c8ab69d..567b09fd 100644 --- a/configure.py +++ b/configure.py @@ -30,4 +30,6 @@ run.options.add_option('--mysql', type='string', dest='mysql_path', default='', help='Path to MySQL') run.options.add_option('--disable-auto-versioning', action='store_true', dest='disable_auto_versioning', default=False, help='Disable the auto versioning script') +run.options.add_option('--nasm', type='string', dest='nasm_path', + default='nasm', help='Path to NASM') run.Configure() diff --git a/support/checkout-deps.sh b/support/checkout-deps.sh index 0153595f..df15be39 100755 --- a/support/checkout-deps.sh +++ b/support/checkout-deps.sh @@ -5,6 +5,22 @@ if [ ! -d "amxmodx" ]; then git clone --recursive https://github.com/alliedmodders/amxmodx.git fi +if [ ! -d "amxmodx/build_deps" ]; then + mkdir amxmodx/build_deps +fi + +download_archive () +{ + if [ `command -v wget` ]; then + wget "$url" -O "$dest" + elif [ `command -v curl` ]; then + curl -o $dest $url + else + echo "Failed to locate wget or curl. Please install one of these programs." + exit 1 + fi +} + if [ "$1" != "--no-mysql" ]; then ismac=0 iswin=0 @@ -34,14 +50,9 @@ if [ "$1" != "--no-mysql" ]; then fi if [ ! -d "mysql-5.5" ]; then - if [ `command -v wget` ]; then - wget $mysqlurl -O mysql.$archive_ext - elif [ `command -v curl` ]; then - curl -o mysql.$archive_ext $mysqlurl - else - echo "Failed to locate wget or curl. Install one of these programs to download MySQL." - exit 1 - fi + url=$mysqlurl + dest=mysql.$archive_ext + download_archive $decomp mysql.$archive_ext mv $mysqlver mysql-5.5 rm mysql.$archive_ext @@ -95,3 +106,15 @@ if [ $? -eq 1 ]; then python setup.py install --user fi fi + +if [ $iswin -eq 1 ]; then + if [ ! -d "amxmodx/build_deps/nasm-2.13.03" ]; then + url=http://www.nasm.us/pub/nasm/releasebuilds/2.13.03/win32/nasm-2.13.03-win32.zip + dest=amxmodx/build_deps/nasm-2.13.03-win32.zip + download_archive + cd amxmodx/build_deps + unzip nasm-2.13.03-win32.zip + rm nasm-2.13.03-win32.zip + mv nasm-2.13.03 nasm + fi +fi