From ff6d0c4e7dd28051258bbfbeb3d7be0ed39f5091 Mon Sep 17 00:00:00 2001 From: Pauli Date: Wed, 4 Jul 2018 23:35:07 +0300 Subject: [PATCH 1/4] Fix memory return calling convention in ruby bindings Calling convention for memory return is that caller allocates (in stack) memory to hold returned object. Then caller passes the pointer to callee as implicit first parameter. references: https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI https://msdn.microsoft.com/en-us/library/7572ztz4.aspx Fixes #1209 --- plugins/ruby/codegen.pl | 19 ++++++++++++++++++- plugins/ruby/ruby-autogen-defs.rb | 8 ++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins/ruby/codegen.pl b/plugins/ruby/codegen.pl index ad5f4b239..2a12a1bea 100755 --- a/plugins/ruby/codegen.pl +++ b/plugins/ruby/codegen.pl @@ -462,8 +462,13 @@ sub render_class_vmethods { push @lines_rb, "def $name(" . join(', ', @argnames) . ')'; indent_rb { my $args = join('', map { ", $_" } @argargs); - my $call = "DFHack.vmethod_call(self, $voff$args)"; my $ret = $meth->findnodes('child::ret-type')->[0]; + my $call; + if (!$ret or $ret->getAttribute('ld:meta') ne 'primitive') { + $call = "DFHack.vmethod_call(self, $voff$args)"; + } else { + $call = "DFHack.vmethod_call_mem_return(self, $voff, rv$args)"; + } render_class_vmethod_ret($call, $ret); }; push @lines_rb, 'end'; @@ -534,6 +539,18 @@ sub render_class_vmethod_ret { }; push @lines_rb, "end._at(ptr) if ptr != 0"; } + elsif ($retmeta eq 'primitive') + { + my $subtype = $ret->getAttribute('ld:subtype'); + if ($subtype eq 'stl-string') { + push @lines_rb, "rv = DFHack::StlString.cpp_new"; + push @lines_rb, $call; + push @lines_rb, "rv"; + } else { + print "Unknown return subtype for $call\n"; + push @lines_rb, "nil"; + } + } else { print "vmethod unkret $call\n"; diff --git a/plugins/ruby/ruby-autogen-defs.rb b/plugins/ruby/ruby-autogen-defs.rb index ca5d82393..10727894d 100644 --- a/plugins/ruby/ruby-autogen-defs.rb +++ b/plugins/ruby/ruby-autogen-defs.rb @@ -994,6 +994,14 @@ module DFHack vmethod_arg(a3), vmethod_arg(a4), vmethod_arg(a5)) end + def self.vmethod_call_mem_return(obj, voff, r0=0, a0=0, a1=0, a2=0, a3=0, a4=0) + this = obj._memaddr + vt = df.get_vtable_ptr(this) + fptr = df.memory_read_ptr(vt + voff) + vmethod_do_call(vmethod_arg(r0), fptr, this, vmethod_arg(a0), vmethod_arg(a1), vmethod_arg(a2), + vmethod_arg(a3), vmethod_arg(a4)) + end + def self.vmethod_arg(arg) case arg when nil, false; 0 From 7486423e6d8edd9d46c1791c8a2246b3e737c5a9 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Wed, 11 Jul 2018 16:57:52 -0500 Subject: [PATCH 2/4] Add CMakeSettings.json for MSVC 2017. MSVC 2017 is binary-compatible with MSVC 2015, so it's safe to allow CMake to be used from within Visual Studio 2017. --- .gitignore | 1 + CMakeLists.txt | 4 +- CMakeSettings.json | 305 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 308 insertions(+), 2 deletions(-) create mode 100644 CMakeSettings.json diff --git a/.gitignore b/.gitignore index 4d3986c67..1c47520cd 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,4 @@ tags #VS is annoying about this one. /build/win64/DF_PATH.txt /build/win32/DF_PATH.txt +/.vs diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d6118c65..b2fb036fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,8 +44,8 @@ if(UNIX) endif() if(WIN32) - if((NOT MSVC) OR (NOT MSVC_VERSION STREQUAL 1900)) - message(SEND_ERROR "MSVC 2015 is required") + if((NOT MSVC) OR (MSVC_VERSION LESS 1900) OR (MSVC_VERSION GREATER 1919)) + message(SEND_ERROR "MSVC 2015 or 2017 is required") endif() endif() diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 000000000..eef8fdb2e --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,305 @@ +{ + // See https://go.microsoft.com//fwlink/?linkid=834763 for more information about this file. + "configurations": [ + { + "name": "MSVC 32 Debug", + "generator": "Visual Studio 14 2015", + "configurationType": "RelWithDebInfo", + "intelliSenseMode": "windows-msvc-x86", + "variables": [ + { + "name": "DFHACK_BUILD_ARCH", + "value": "32" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + }, + { + "name": "REMOVE_SYMBOLS_FROM_DF_STUBS", + "value": "0" + } + ], + "installRoot": "${thisFileDir}/build/win32/DF" + }, + { + "name": "MSVC 32 Release", + "generator": "Visual Studio 14 2015", + "configurationType": "Release", + "intelliSenseMode": "windows-msvc-x86", + "variables": [ + { + "name": "DFHACK_BUILD_ARCH", + "value": "32" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + } + ], + "installRoot": "${thisFileDir}/build/win32/DF" + }, + { + "name": "MSVC 64 Debug", + "generator": "Visual Studio 14 2015 Win64", + "configurationType": "RelWithDebInfo", + "intelliSenseMode": "windows-msvc-x64", + "variables": [ + { + "name": "DFHACK_BUILD_ARCH", + "value": "64" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + }, + { + "name": "REMOVE_SYMBOLS_FROM_DF_STUBS", + "value": "0" + } + ], + "installRoot": "${thisFileDir}/build/win64/DF" + }, + { + "name": "MSVC 64 Release", + "generator": "Visual Studio 14 2015 Win64", + "configurationType": "Release", + "intelliSenseMode": "windows-msvc-x64", + "variables": [ + { + "name": "DFHACK_BUILD_ARCH", + "value": "64" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + } + ], + "installRoot": "${thisFileDir}/build/win64/DF" + }, + { + "name": "GCC 32 Debug", + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/tmp/dfhack-${workspaceHash}/src", + "remoteBuildRoot": "/tmp/dfhack-${workspaceHash}/debug-32", + "rsyncCommandArgs": "--exclude=build --include=.git", + "remoteCopySources": true, + "cmakeExecutable": "$(which cmake)/..", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "intelliSenseMode": "linux-gcc-x86", + "variables": [ + { + "name": "DFHACK_BUILD_ARCH", + "value": "32" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + }, + { + "name": "REMOVE_SYMBOLS_FROM_DF_STUBS", + "value": "0" + } + ] + }, + { + "name": "GCC 32 Release", + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/tmp/dfhack-${workspaceHash}/src", + "remoteBuildRoot": "/tmp/dfhack-${workspaceHash}/release-32", + "rsyncCommandArgs": "--exclude=build --include=.git", + "remoteCopySources": true, + "cmakeExecutable": "$(which cmake)/..", + "generator": "Unix Makefiles", + "configurationType": "Release", + "intelliSenseMode": "linux-gcc-x86", + "variables": [ + { + "name": "DFHACK_BUILD_ARCH", + "value": "32" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + } + ] + }, + { + "name": "GCC 64 Debug", + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/tmp/dfhack-${workspaceHash}/src", + "remoteBuildRoot": "/tmp/dfhack-${workspaceHash}/debug-64", + "rsyncCommandArgs": "--exclude=build --include=.git", + "remoteCopySources": true, + "cmakeExecutable": "$(which cmake)/..", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "intelliSenseMode": "linux-gcc-x64", + "variables": [ + { + "name": "DFHACK_BUILD_ARCH", + "value": "64" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + }, + { + "name": "REMOVE_SYMBOLS_FROM_DF_STUBS", + "value": "0" + } + ] + }, + { + "name": "GCC 64 Release", + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/tmp/dfhack-${workspaceHash}/src", + "remoteBuildRoot": "/tmp/dfhack-${workspaceHash}/release-64", + "rsyncCommandArgs": "--exclude=build --include=.git", + "remoteCopySources": true, + "cmakeExecutable": "$(which cmake)/..", + "generator": "Unix Makefiles", + "configurationType": "Release", + "intelliSenseMode": "linux-gcc-x64", + "variables": [ + { + "name": "DFHACK_BUILD_ARCH", + "value": "64" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + } + ] + }, + { + "name": "GCC 4.8 32 Debug", + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/tmp/dfhack-${workspaceHash}/src", + "remoteBuildRoot": "/tmp/dfhack-${workspaceHash}/debug-32-48", + "rsyncCommandArgs": "--exclude=build --include=.git", + "remoteCopySources": true, + "cmakeExecutable": "$(which cmake)/..", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "intelliSenseMode": "linux-gcc-x86", + "variables": [ + { + "name": "CMAKE_C_COMPILER", + "value": "gcc-4.8" + }, + { + "name": "CMAKE_CXX_COMPILER", + "value": "g++-4.8" + }, + { + "name": "DFHACK_BUILD_ARCH", + "value": "32" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + }, + { + "name": "REMOVE_SYMBOLS_FROM_DF_STUBS", + "value": "0" + } + ] + }, + { + "name": "GCC 4.8 32 Release", + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/tmp/dfhack-${workspaceHash}/src", + "remoteBuildRoot": "/tmp/dfhack-${workspaceHash}/release-32-48", + "rsyncCommandArgs": "--exclude=build --include=.git", + "remoteCopySources": true, + "cmakeExecutable": "$(which cmake)/..", + "generator": "Unix Makefiles", + "configurationType": "Release", + "intelliSenseMode": "linux-gcc-x86", + "variables": [ + { + "name": "CMAKE_C_COMPILER", + "value": "gcc-4.8" + }, + { + "name": "CMAKE_CXX_COMPILER", + "value": "g++-4.8" + }, + { + "name": "DFHACK_BUILD_ARCH", + "value": "32" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + } + ] + }, + { + "name": "GCC 4.8 64 Debug", + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/tmp/dfhack-${workspaceHash}/src", + "remoteBuildRoot": "/tmp/dfhack-${workspaceHash}/debug-64-48", + "rsyncCommandArgs": "--exclude=build --include=.git", + "remoteCopySources": true, + "cmakeExecutable": "$(which cmake)/..", + "generator": "Unix Makefiles", + "configurationType": "RelWithDebInfo", + "intelliSenseMode": "linux-gcc-x64", + "variables": [ + { + "name": "CMAKE_C_COMPILER", + "value": "gcc-4.8" + }, + { + "name": "CMAKE_CXX_COMPILER", + "value": "g++-4.8" + }, + { + "name": "DFHACK_BUILD_ARCH", + "value": "64" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + }, + { + "name": "REMOVE_SYMBOLS_FROM_DF_STUBS", + "value": "0" + } + ] + }, + { + "name": "GCC 4.8 64 Release", + "remoteMachineName": "${defaultRemoteMachineName}", + "remoteCMakeListsRoot": "/tmp/dfhack-${workspaceHash}/src", + "remoteBuildRoot": "/tmp/dfhack-${workspaceHash}/release-64-48", + "rsyncCommandArgs": "--exclude=build --include=.git", + "remoteCopySources": true, + "cmakeExecutable": "$(which cmake)/..", + "generator": "Unix Makefiles", + "configurationType": "Release", + "intelliSenseMode": "linux-gcc-x64", + "variables": [ + { + "name": "CMAKE_C_COMPILER", + "value": "gcc-4.8" + }, + { + "name": "CMAKE_CXX_COMPILER", + "value": "g++-4.8" + }, + { + "name": "DFHACK_BUILD_ARCH", + "value": "64" + }, + { + "name": "BUILD_STONESENSE", + "value": "1" + } + ] + } + ] +} From 7f523f4be2cf4171a68dda685d37d553f9e5f067 Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 12 Jul 2018 10:30:57 -0400 Subject: [PATCH 3/4] Mention the need to initialize new submodules after `git pull` too See #1361 --- docs/Compile.rst | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/Compile.rst b/docs/Compile.rst index 7d7dbeccd..18b0dc9b2 100644 --- a/docs/Compile.rst +++ b/docs/Compile.rst @@ -33,13 +33,16 @@ To get the latest development code (develop branch), clone as above and then:: Generally, you should only need to clone DFHack once. -**Important note regarding submodule update and changing branches**: - -You must run ``git submodule update`` every time you change branches, -such as when switching between the master and develop branches or vice versa. -If a submodule only exists on the newer branch, you also need to run -``git submodule update --init``. Failure to do this may result in strange -build errors or "not a known DF version" errors. +**Important note regarding submodule update after pulling or changing branches**: + +You must run ``git submodule update`` every time you change branches, such as +when switching between the master and develop branches or vice versa. You also +must run it after pulling any changes to submodules from the DFHack repo. If a +submodule only exists on the newer branch, or if a commit you just pulled +contains a new submodule, you need to run ``git submodule update --init``. +Failure to do this may result in a variety of errors, including ``fatal: +does not exist`` when using Git, errors when building DFHack, and ``not a known +DF version`` when starting DF. **More notes**: From 242dabfdb0ab91a288b8dd65e027b805fce0e53d Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 12 Jul 2018 14:44:29 -0400 Subject: [PATCH 4/4] Update scripts/rejuvenate.lua --- docs/changelog.txt | 4 ++++ scripts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index d444f914b..01f026da5 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -48,6 +48,10 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Misc Improvements - Reduced time for designation jobs from tools like `digv` to be assigned workers - `embark-assistant`: switched to standard scrolling keys, improved spacing slightly +- `rejuvenate`: + - Added ``-all`` argument to apply to all citizens + - Added ``-force`` to include units under 20 years old + - Clarified documentation ## API - Added to ``Units`` module: diff --git a/scripts b/scripts index 6849148e8..801499ab6 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 6849148e8694f5da415cd6920dd9094c352110de +Subproject commit 801499ab67e28bc017e72397ce3c9fddad1829a2