conan-io / wishlist

This repo is to propose libraries, frameworks, and code in general that users would like to have in conan
MIT License
49 stars 5 forks source link

Package LuaJIT #157

Closed redagito closed 3 years ago

redagito commented 6 years ago

The JIT version of the popular Lua scripting language. Lua: www.lua.org LuaJIT: www.luajit.org

I found 2 conan packages for this but an "official" package would be nice https://github.com/int010h/conan-luajit https://github.com/gsage/conan-luajit-rocks (this one includes a package manager for lua: luarocks)

tomazos commented 4 years ago

I tried to use the int010h one but I couldn't get it to work on Windows, so I ended up hand-writing a conanfile.py that gets the canonical luajit tarball and uses its native build system:

from conans import ConanFile, tools

class LuajitConan(ConanFile):
    name = "luajit"
    version = "2.0.5"
    license = "MIT"
    author = "Andrew Tomazos <andrewtomazos@gmail.com>"
    url = "https://luajit.org"
    topics = ("lua",)
    description = "a Just-In-Time Compiler for Lua"
    settings = "os", "compiler", "build_type", "arch"

    def source(self):
        tools.get("https://luajit.org/download/LuaJIT-2.0.5.tar.gz")

    def build(self):
        if self.settings.os == "Windows":
            with tools.chdir("LuaJIT-2.0.5/src"):
                self.run("msvcbuild static")
        else:
            with tools.chdir("LuaJIT-2.0.5"):
                self.run('make')

    def package(self):
        ljs = "LuaJIT-2.0.5/src"
        if self.settings.os == "Windows":
            self.copy("luajit.exe", dst="bin", src=ljs)
            self.copy("lua51.lib", dst="lib", src=ljs)
        else:
            self.copy("luajit", dst="bin", src=ljs)
            self.copy("libluajit.a", dst="lib", src=ljs)
        self.copy("lua.h", dst="include", src=ljs)
        self.copy("lualib.h", dst="include", src=ljs)
        self.copy("lauxlib.h", dst="include", src=ljs)
        self.copy("luaconf.h", dst="include", src=ljs)
        self.copy("lua.hpp", dst="include", src=ljs)
        self.copy("luajit.h", dst="include", src=ljs)

    def package_info(self):
        if self.settings.os == "Windows":
            self.cpp_info.libs = ["lua51"]
        else:
            self.cpp_info.libs = ["luajit"]

It's tested on Linux and Windows - but it doesn't use cmake. Feel free to use it or adapt it as needed.

Croydon commented 3 years ago

Done via https://github.com/conan-io/conan-center-index/pull/5090