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

ZBar: add package #5530

Merged
merged 56 commits into from
Oct 21, 2024
Merged

ZBar: add package #5530

merged 56 commits into from
Oct 21, 2024

Conversation

Doekin
Copy link
Contributor

@Doekin Doekin commented Oct 18, 2024

Description

ZBar is an open-source software suite for reading barcodes from various sources, including webcams. Its original development stopped in 2012, and mchehab took the task of keeping it updated with the V4L2 API.

Configuration

ZBar uses autotools and includes various components such as Python bindings, video input, and GUI widgets. For simplicity and portability, it has been ported to xmake, however, only essential configuration options are translated.

io.gsub("include/config.h.in", "# ?undef (.-)\n", "${define %1}\n")
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")

local config = { vers = package:version_str() }
Copy link
Member

Choose a reason for hiding this comment

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

rename to configs


-- get LIB_VERSION from configure.ac
-- format: AC_SUBST([LIB_VERSION], [3:0:3])
configure_ac = io.readfile("configure.ac")
Copy link
Member

Choose a reason for hiding this comment

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

local configure_ac

end
end

import("package.tools.xmake").install(package,config)
Copy link
Member

Choose a reason for hiding this comment

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

add spaces ,

end

if is_plat("macosx") then
add_deps("libiconv", {system = true})
Copy link
Member

Choose a reason for hiding this comment

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

libiconv will find and use system libs first. so you need not add system = true

add_requires("libiconv")

-- add options
option("enable_codebar")
Copy link
Member

Choose a reason for hiding this comment

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

remove enable_ prefix

set_description("whether to build support for " .. code.description)

on_check(function (option)
local enabled_codes = option:dep("enable-codes"):value()
Copy link
Member

Choose a reason for hiding this comment

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

I didn't see it in tools.xmake.install.

add_requires("libiconv")

-- add options
option("enable-codes")
Copy link
Member

Choose a reason for hiding this comment

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

please remove enable- prefix

if is_plat("linux", "bsd") then
add_syslinks("pthread")
end

Copy link
Member

Choose a reason for hiding this comment

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

no any add_configs to set xxx codes options in port/xmake.lua

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, we do need configs in the package description.
By the way, which form is better?

  1. xrepo install -f "qr=true" zbar
  2. xrepo install -f "codes=qr" zbar

For reference, the original configure shell script uses options like the following:
./configure --disable-video --without-gtk --without-python --enable-shared=yes --enable-static=yes --with-pic --enable-codes=ean,databar

Copy link
Member

@waruqi waruqi Oct 19, 2024

Choose a reason for hiding this comment

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

you can use single codes option/config

add_requires("xxx", configs = {codecs = {"qr", "ean", ...})

patch_ver = vers[3] or ""
set_configvar("ZBAR_VERSION_MAJOR", major_ver, {quote = false})
set_configvar("ZBAR_VERSION_MINOR", minor_ver, {quote = false})
set_configvar("ZBAR_VERSION_PATCH", patch_ver, {quote = false})
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The config.h.in file contains content like the following:

/* Program major version (before the '.') as a number */
#undef ZBAR_VERSION_MAJOR

/* Program minor version (after '.') as a number */
#undef ZBAR_VERSION_MINOR

/* Program patch version (after the second '.') as a number */
#undef ZBAR_VERSION_PATCH

I'm not sure how to handle this.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I edit config.h.in to the following?

/* Program major version (before the '.') as a number */
#define ZBAR_VERSION_MAJOR ${VERSION_MAJOR}

/* Program minor version (after '.') as a number */
#define ZBAR_VERSION_MINOR ${VERSION_MINOR}

/* Program patch version (after the second '.') as a number */
#define ZBAR_VERSION_PATCH ${VERSION_ALTER}

Copy link
Member

Choose a reason for hiding this comment

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

right

add_extsources("brew::zbar")
end

add_configs("symbologies", {description = "Select symbologies to compile", default = {"ean","databar","code128","code93","code39","codabar","i25","qrcode","sqcode"}, type = "table"})
Copy link
Member

Choose a reason for hiding this comment

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

add spaces ,


-- add options
option("symbologies")
-- set_default({"ean","databar","code128","code93","code39","codabar","i25","qrcode","sqcode"})
Copy link
Member

Choose a reason for hiding this comment

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

remove comment

set_version(get_config("vers"))

set_configvar("PACKAGE_VERSION", get_config("vers"))
set_configvar("PACKAGE_STRING", "zbar " .. get_config("vers"))
Copy link
Member

Choose a reason for hiding this comment

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

and here

#undef PACKAGE_URL

/* Define to the version of this package. */
#undef PACKAGE_VERSION
Copy link
Member

Choose a reason for hiding this comment

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

here

@waruqi waruqi merged commit 39d41c8 into xmake-io:dev Oct 21, 2024
67 checks passed
@Doekin Doekin deleted the zbar branch October 21, 2024 09:29
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.

2 participants