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

lua-bit32: new package #9707

Merged
merged 1 commit into from
Aug 20, 2019
Merged

lua-bit32: new package #9707

merged 1 commit into from
Aug 20, 2019

Conversation

mstorchak
Copy link
Contributor

provides bit32, a replacement for luabitops

Signed-off-by: Maxim Storchak [email protected]

Maintainer: me
Compile tested: ath79, WNDR3800, r10703+3-e1f588e446
Run tested: ath79, WNDR3800, base system r9880+3-bd3a18bbe4, actually tested in a chroot with r10703+3-e1f588e446

Description:
This package provides bit32, a backport of Lua 5.2 bit manipulation library. It's required for new luaposix.

@mstorchak mstorchak marked this pull request as ready for review August 13, 2019 10:10
@neheb
Copy link
Contributor

neheb commented Aug 14, 2019

Please rebase against current master to fix the buildbot.

@mstorchak
Copy link
Contributor Author

@neheb , done.

@mstorchak mstorchak force-pushed the lua-bit32 branch 2 times, most recently from 71ebdb1 to 43c12b2 Compare August 15, 2019 11:23
provides bit32, a replacement for luabitops

Signed-off-by: Maxim Storchak <[email protected]>
PKG_SRC_NAME:=lua-compat-5.2
PKG_SRC_VERSION:=0.3
PKG_SOURCE_URL=https://codeload.github.com/keplerproject/$(PKG_SRC_NAME)/tar.gz/v$(PKG_SRC_VERSION)?
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

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

Place above PKG_SOURCE_URL.

Copy link
Contributor

Choose a reason for hiding this comment

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

why? based on what?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

That hasn't even merged yet!


PKG_SRC_NAME:=lua-compat-5.2
PKG_SRC_VERSION:=0.3
PKG_SOURCE_URL=https://codeload.github.com/keplerproject/$(PKG_SRC_NAME)/tar.gz/v$(PKG_SRC_VERSION)?
Copy link
Contributor

Choose a reason for hiding this comment

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

get rid of PKG_SRC_NAME. variables are normally not used in URLs unless they change (the version).

Copy link
Contributor

Choose a reason for hiding this comment

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

what requirement is this? where is it documented for contributors?

Copy link
Contributor

Choose a reason for hiding this comment

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

f82287c

I've done this before but was told to replace with normal name.

Copy link
Member

Choose a reason for hiding this comment

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

@neheb, I think you are overextending this requirement. It is only for call, eval or define lines. Note that f82287c does not touch any other lines, and that
git grep '^PKG_SOURCE_URL.*PKG_NAME' f82287c will return 34 lines that were left unchanged.

@hnyman
Copy link
Contributor

hnyman commented Aug 20, 2019

Let's merge this.
luaposix that was already merged for some reason, depends on this and is now broken.

Although package name variables are frowned upon on most of the declarations, I see no real problem this time, as the variable is used just as part of the download path to identify the lua compatibility version.

@hnyman hnyman merged commit afd3968 into openwrt:master Aug 20, 2019
@mstorchak
Copy link
Contributor Author

I'm sorry for not responding in time, I was traveling and didn't have access to internet.
@hnyman , thank you for merging this PR!
@neheb , I introduced PKG_SRC_* variables to avoid duplication. In this case package name doesn't match the name of the repo, and it appears that some parts of the build process depend on repo name.

@mstorchak mstorchak deleted the lua-bit32 branch August 21, 2019 13:09
@PolynomialDivision
Copy link
Member

Can we please backport this package to 19.07.4?

@karlp
Copy link
Contributor

karlp commented Oct 8, 2020

@PolynomialDivision lua bitop is already available, this bit32 package is only for the major version bump in luaposix, which will not be backported. Is lua bitop not sufficient?

@PolynomialDivision
Copy link
Member

PolynomialDivision commented Oct 8, 2020

Ah okay. Thanks!
I have to look. I wrote an exporter that uses bit32. I wanted to make it available under 19.07.4. Maybe I have to change the lib. Thanks for the hint. :)

#13606

@karlp
Copy link
Contributor

karlp commented Oct 9, 2020

Here's some code that will automatically use native (on lua 5.3) or lua bitop, or whwatever else you plugin)

-- Try and figure out a bitop library...
local bitnative, err = loadstring("if 2 & 1<<1 then return true end")
band = nil
bor = nil
lshift = nil
rshift = nil

if bitnative then
        local magic_str = [[
        bor = function(a,b) return a | b end
        band = function(a,b) return a & b end
        lshift = function(a,b) return a << b end
        rshift = function(a,b) return a >> b end
        ]]
        local f, err = loadstring(magic_str)
        if f then f() else print("loadstring failed?!", err) end
        -- sanity
        if band(0xfff, 0x2) ~= 0x2 then error("wat") end
else
	-- try bitop, it's common too
	local hasbit, bit = pcall(require, "bit")
	if hasbit then
		bor = bit.bor
		band = bit.band
		lshift = bit.lshift
		rshift = bit.rshift
	end
end

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.

6 participants