Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Lua API. #5190

Merged
merged 11 commits into from May 2, 2014
Merged

New Lua API. #5190

merged 11 commits into from May 2, 2014

Conversation

pchote
Copy link
Member

@pchote pchote commented Apr 25, 2014

This introduces a new scripting API built on Eluant and the native lua library. The main focus of this implementation was building a self-consistent and self-documenting API (generated using the --lua-docs utility command, and available on the wiki). Secondary benefits are that it is faster than Kopilua and doesn't leak memory everywhere.

This is going to take a while to properly review, so i'm filing this now. There are two is one main TODOs left to finish:

  • Packaging changes: we can use the system lua for linux platforms, but will need to ship lua on Windows and OSX. We should also credit the new thirdparty bits in AUTHORS.
  • Eluant.dll includes a bunch of now-redundant changes. I need to create a public fork, revert the changes we don't need, and file upstream prs for the ones that we do.

This implements enough of the API for the shellmaps, but no more. A future PR will introduce a ScriptPlayerProperties implementation that exposes mission objectives and victory conditions.

@DanAE111
Copy link

That's a lot of code, i think you deserve a beer!

@Mailaender
Copy link
Member

You will need to change the package-all.sh, Makefile install section and the NSIS file for the Windows installer.

@ghost
Copy link

ghost commented Apr 25, 2014

🍻

@@ -74,6 +74,9 @@
<Package>mono.nat</Package>
<HintPath>..\thirdparty\Mono.Nat.dll</HintPath>
</Reference>
<Reference Include="Eluant">
<HintPath>..\Eluant.dll</HintPath>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be "..\thirdparty\Eluant.dll"

@pchote
Copy link
Member Author

pchote commented Apr 26, 2014

Thanks for the detailed review @pavlos256! I'll start working through these over the next couple of days.

}

[Desc("Calls a function after a specified delay.")]
public void RunAfterDelay(int delay, LuaFunction function)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should move to Trigger.AfterDelay(int ticks, LuaFunction func).

@pchote
Copy link
Member Author

pchote commented Apr 26, 2014

Figured it was easier to get this out of the way now. Fixed nits, and sorted out the Eluant changes. See https://github.com/pchote/Eluant/ for the custom version included in this pr.

@@ -240,5 +243,40 @@ public void Kill(Actor attacker)

health.Value.InflictDamage(this, attacker, health.Value.MaxHP, null, true);
}

#region Scripting interface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make this and the other Lua-augmented classes partial, with all the Lua-specific bits in their own file?

@pchote
Copy link
Member Author

pchote commented Apr 26, 2014

Updated with default parameter support, addressing @obrakmann's concern.


namespace OpenRA
{
/// <summary>
/// 3d World vector for describing offsets and distances - 1024 units = 1 cell.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the XmlDoc here? It integrates into IDE tooltips and is kinda helpful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency. They aren't used anywhere else in the codebase.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, we should document this somehow though #4372.

@pavlos256
Copy link
Contributor

I think Eluant.dll should be added to the Makefile's COMMON_LIBS

@pchote
Copy link
Member Author

pchote commented Apr 26, 2014

I think Eluant.dll should be added to the Makefile's COMMON_LIBS

It already is?

@pavlos256
Copy link
Contributor

You're right, it's there. Sorry, I was probably looking at the wrong branch.

@Smilex
Copy link
Contributor

Smilex commented Apr 27, 2014

Overall I'd recommend you break lines more often.

@pchote
Copy link
Member Author

pchote commented Apr 27, 2014

Updated with the more fixes.

# Copy files for OpenRA.Game.exe and OpenRA.Editor.exe as well as all dependencies.
make install-all prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR"

# Native library dependencies
cp "$DEPSDIR"/* "$PWD/packaging/linux/$ROOTDIR/usr/lib/openra/" || exit 3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this here instead of in the Makefile will probably break all thirdparty package installation upon update.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand they probably don't want our native binaries bundled so I guess it is okay.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are OS-specific deps, so we don't want to do this in the (theoretically) platform-agnostic makefile.
In the best case, we would then need to go and delete these files again in the OSX packaging script, which is ugly.

Mailaender added a commit that referenced this pull request May 2, 2014
@Mailaender Mailaender merged commit 1a432e9 into OpenRA:bleed May 2, 2014
@Mailaender
Copy link
Member

This was difficult labour. Thanks.

@Mailaender
Copy link
Member

Pinging downstream maintainers @cerebrum, @ckorn and @hasufell as we made a tough decision to bundle native libraries, because of http://www.mono-project.com/Config_DllMap limitations and new versions not being available in LTS distributions. This will require some additional sed fixes to use system libraries in your packaging scripts.

@Mailaender
Copy link
Member

Also pinging @xaionaro as this might disrupt the Hetzner auto-update scripts as make dependencies && make install won't be enough.

@hasufell
Copy link

hasufell commented May 2, 2014

I decided to fix this upstream https://build.opensuse.org/request/show/232302 instead.

That does not look right. These kind of things should never happen. Instead, someone needs to make debian stop this crap. Otherwise it should be fixed on related consumer packages, not library level... but I don't know about openSUSE policies. Also mind that the pkgconfig files of lua are hacked as well.

If there is something actually wrong, then it can be fixed upstream at lua. Instead debian uses wrong approaches to ship lua and ends up in their current mess.

If we don't follow common interfaces and standards and add random hacks like debian does, then we encourage people to do the same and help spreading wrong usage of distro-specific pkgconfig files, uncommon library SONAMES and so on.

This isn't the first time happening, there was way more serious breakage (like skype linking to non-existing SONAMES and modified libraries only present in debian). Make people aware that debian is bad for development and don't do as they do just because it's the easiest workaround.

@Mailaender
Copy link
Member

I agree and hate Debian/Ubuntu for it, but sadly they are the distribution the majority uses or bases their own ones upon. Also note how you just received a WONTFIX 1 year ago without further comment. This does not convince me that we can start to reason with them. In the end you are always fucked, because you get treated with "It works on Ubuntu, not on SUSE, you suck!" and everyone claims that Linux is not a sophisticated work platform because no one adheres to standards.

I will probably experiment with http://software.opensuse.org/package/openra and invent a make native-dependencies or share the sed strings required to have this use system dependencies instead. Maybe even for the platform-independent CLI DLLs in thirdparty. We will see.

@obrakmann
Copy link
Contributor

FWIW, the naming convention used by Debian's lua packages is in accordance with their policy manual. Good luck persuading them to change that.

@hasufell
Copy link

hasufell commented May 2, 2014

FWIW, the naming convention used by Debian's lua packages is in accordance with their policy manual. Good luck persuading them to change that.

It wouldn't be so bad if they provide a proper abstraction layer that prevents people from using these library names directly. FYI... gentoo does a lot of very terrible hackery to make python, ruby etc work the way we want. But that is hidden from the developer/user. In contrast... changing names of pkgconfig files is so terrible, that I don't know what to say.

I will probably experiment with http://software.opensuse.org/package/openra and invent a make native-dependencies or share the sed strings required to have this use system dependencies instead. Maybe even for the platform-independent CLI DLLs in thirdparty. We will see.

Can you not just fix that in the code, so that it tries to load different libs in that order: liblua.so.5.1, liblua.so.5, liblua.so, liblua5.1.so?

Also mind that lua upstream doesn't even support shared libs in the first place (as in, no target in the Makefile). They were unable to get it working on all supported platforms without libtool (they didn't explain what's wrong with libtool). Not sure why that is any reason, but anyway. Just saying that the "5.1" etc are pretty much guesswork. That however isn't a problem as long as you use the pkg-config files which obviously isn't possible here. So technically... this is already an unsupported (but reasonable) hack, since static-only libs are a security problem.

@Mailaender
Copy link
Member

In IRC I was told that @xamarin uses *.dll.config.in files that get configured during the build to workaround the issue that it always uses the last entry, not the first matching. We can investigate that.

@xaionaro
Copy link
Contributor

xaionaro commented May 2, 2014

@Mailaender:

Also pinging @xaionaro as this might disrupt the Hetzner auto-update scripts as make dependencies && make install won't be enough.

Does current bleed servers work right? (on Hetzner)

@Mailaender
Copy link
Member

@xaionaro Yes, it does work. Looks like the dedicated servers don't require Lua at all.

@xaionaro
Copy link
Contributor

xaionaro commented May 2, 2014

@Mailaender, ok. Anyway notify me when the release/playtest will be, please :)

@Mailaender
Copy link
Member

We are also trying to persuade @lua to properly support shared libraries.

@hasufell
Copy link

hasufell commented May 4, 2014

On an almost unrelated note: is it possible to use the static lib with C#? I don't know enough about that language and mono.

@Mailaender
Copy link
Member

You always use some kind of wrapper. See https://github.com/cdhowie/Eluant/blob/master/Eluant/LuaApi.cs on how the bindings interact with the Lua DLL.

@hasufell
Copy link

hasufell commented May 4, 2014

You always use some kind of wrapper. See https://github.com/cdhowie/Eluant/blob/master/Eluant/LuaApi.cs on how the bindings interact with the Lua DLL.

That doesn't tell me if you can achieve the same with a static lib.

@Unit158
Copy link
Contributor

Unit158 commented May 4, 2014

I think you would need to compile the static lib into mono, which is not desired.

@hasufell
Copy link

hasufell commented May 4, 2014

I think you would need to compile the static lib into mono, which is not desired.

Ouch, yeah.

@Mailaender
Copy link
Member

I addressed Linux packaging in #5365 and #5391 to ease the process and prefer system dependencies again. Please contribute your distributions lsb_release -is output and .so name policy.

@Mailaender
Copy link
Member

I brought back the jets in https://github.com/Mailaender/OpenRA/compare/migs-lua-desert-shellmap but I am not sure if it is worth bringing them back as I don't really see them on my small laptop screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet