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

Add Libqrcodegencpp #182

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions deps.macos/80-qrcodegencpp.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
autoload -Uz log_debug log_error log_info log_status log_output

## Dependency Information
local name='qrcodegencpp'
local version='1.8.0'
local url='https://github.com/nayuki/QR-Code-generator.git'
local hash='720f62bddb7226106071d4728c292cb1df519ceb'
local url_cmake='https://github.com/EasyCoding/qrcodegen-cmake.git'
local hash_cmake='c57623d48a2d422b0f908dcf22d56d603e56c0e4'

## Build Steps
setup() {
log_info "Setup (%F{3}${target}%f)"
setup_dep ${url} ${hash}

mkdir -p qrcodegen-cmake-${version}
pushd qrcodegen-cmake-${version}
dep_checkout ${url_cmake} ${hash_cmake}
popd
}

clean() {
cd ${dir}

if [[ ${clean_build} -gt 0 && -d build_${arch} ]] {
log_info "Clean build directory (%F{3}${target}%f)"

rm -rf build_${arch}
}
}

patch() {
autoload -Uz apply_patch

log_info "Patch (%F{3}${target}%f)"

cd ${dir}

cp -R qrcodegen-cmake-${version}/(cmake|CMakeLists.txt) .
}

config() {
autoload -Uz mkcd progress

log_info "Config (%F{3}${target}%f)"

local _onoff=(OFF ON)

args=(
${cmake_flags}
-DBUILD_SHARED_LIBS="${_onoff[(( shared_libs + 1 ))]}"
)

cd ${dir}
log_debug "CMake configure options: ${args}"
progress cmake -S . -B build_${arch} -G Ninja ${args}
}

build() {
autoload -Uz mkcd

log_info "Build (%F{3}${target}%f)"

cd ${dir}
cmake --build build_${arch} --config ${config}
}

install() {
autoload -Uz progress

log_info "Install (%F{3}${target}%f)"

args=(
--install "build_${arch}"
--config "${config}"
)

cd ${dir}
progress cmake ${args}
}

fixup() {
cd ${dir}

log_info "Fixup (%F{3}${target}%f)"

rm -rf ${target_config[output_dir]}/include/qrcodegen
rm -rf ${target_config[output_dir]}/lib/cmake/qrcodegen
rm -rf ${target_config[output_dir]}/lib/pkgconfig/qrcodegen.pc
rm -rf ${target_config[output_dir]}/lib/libqrcodegen.*

if (( shared_libs )) {
local -a dylib_files=(${target_config[output_dir]}/lib/libqrcodegencpp*.dylib(.))

autoload -Uz fix_rpaths
fix_rpaths ${dylib_files}

if [[ ${config} == (Release|MinSizeRel) ]] {
dsymutil ${dylib_files}
strip -x ${dylib_files}
}

for file (${target_config[output_dir]}/lib/cmake/qrcodegencpp/qrcodegencpp-targets-*.cmake) {
sed -i '' 's/libqrcodegencpp.*.dylib/libqrcodegencpp.dylib/' "${file}"
}
} else {
rm -rf -- ${target_config[output_dir]}/lib/libqrcodegencpp*.(dylib|dSYM)(N)
}
}
111 changes: 111 additions & 0 deletions deps.windows/60-qrcodegencpp.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
param(
[string] $Name = 'qrcodegencpp',
[string] $Version = '1.8.0',
[string] $Uri = 'https://github.com/nayuki/QR-Code-generator.git',
[string] $Hash = '720f62bddb7226106071d4728c292cb1df519ceb',
[string] $UriCMake = 'https://github.com/EasyCoding/qrcodegen-cmake.git',
[string] $HashCMake = 'c57623d48a2d422b0f908dcf22d56d603e56c0e4'
)

function Setup {
Setup-Dependency -Uri $Uri -Hash $Hash -DestinationPath "$Path/src"
Setup-Dependency -Uri $UriCMake -Hash $HashCMake -DestinationPath "$Path/qrcodegen-cmake"
}

function Clean {
Set-Location "$Path/src"

if ( Test-Path "build_${Target}" ) {
Log-Information "Clean build directory (${Target})"
Remove-Item -Path "build_${Target}" -Recurse -Force
}
}

function Patch {
Log-Information "Patch (${Target})"
Set-Location $Path

$Items = @(
@{
Path = "qrcodegen-cmake/CMakeLists.txt"
Destination = "src"
ErrorAction = 'SilentlyContinue'
}
@{
Path = "qrcodegen-cmake/cmake"
Destination = "src"
Recurse = $true
ErrorAction = 'SilentlyContinue'
}
)

$Items | ForEach-Object {
$Item = $_
Copy-Item @Item
}
}

function Configure {
Log-Information "Configure (${Target})"
Set-Location "$Path/src"

$OnOff = @('OFF', 'ON')
$Options = @(
$CmakeOptions
"-DBUILD_SHARED_LIBS:BOOL=$($OnOff[$script:Shared.isPresent])"
)

Invoke-External cmake -S . -B "build_${Target}" @Options
}

function Build {
Log-Information "Build (${Target})"
Set-Location "$Path/src"

$Options = @(
'--build', "build_${Target}"
'--config', $Configuration
)

if ( $VerbosePreference -eq 'Continue' ) {
$Options += '--verbose'
}

Invoke-External cmake @Options
}

function Install {
Log-Information "Install (${Target})"
Set-Location "$Path/src"

$Options = @(
'--install', "build_${Target}"
'--config', $Configuration
)

if ( $Configuration -match "(Release|MinSizeRel)" ) {
$Options += '--strip'
}

Invoke-External cmake @Options
}

function Fixup {
Log-Information "Fixup (${Target})"
Set-Location $Path

$Items = @(
@{ FullPath = "$($ConfigData.OutputPath)/include/qrcodegen" }
@{ FullPath = "$($ConfigData.OutputPath)/lib/cmake/qrcodegen" }
@{ FullPath = "$($ConfigData.OutputPath)/lib/pkgconfig/qrcodegen.pc" }
@{ FullPath = "$($ConfigData.OutputPath)/lib/qrcodegen.*" }
@{ FullPath = "$($ConfigData.OutputPath)/bin/qrcodegen.*" }
)

$Items | ForEach-Object {
$Item = $_
if ( Test-Path $Item.FullPath ) {
Remove-Item -Recurse -Force $Item.FullPath
}
}
}
91 changes: 91 additions & 0 deletions licenses/qrcodegencpp/QR-Code-generator/Readme.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
QR Code generator library
=========================


Introduction
------------

This project aims to be the best, clearest QR Code generator library in multiple languages. The primary goals are flexible options and absolute correctness. Secondary goals are compact implementation size and good documentation comments.

Home page with live JavaScript demo, extensive descriptions, and competitor comparisons: [https://www.nayuki.io/page/qr-code-generator-library](https://www.nayuki.io/page/qr-code-generator-library)


Features
--------

Core features:

* Available in 6 programming languages, all with nearly equal functionality: Java, TypeScript/JavaScript, Python, Rust, C++, C
* Significantly shorter code but more documentation comments compared to competing libraries
* Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard
* Output format: Raw modules/pixels of the QR symbol
* Detects finder-like penalty patterns more accurately than other implementations
* Encodes numeric and special-alphanumeric text in less space than general text
* Open-source code under the permissive MIT License

Manual parameters:

* User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data
* User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one
* User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number
* User can create a list of data segments manually and add ECI segments

Optional advanced features (Java only):

* Encodes Japanese Unicode text in kanji mode to save a lot of space compared to UTF-8 bytes
* Computes optimal segment mode switching for text with mixed numeric/alphanumeric/general/kanji parts

More information about QR Code technology and this library's design can be found on the project home page.


Examples
--------

The code below is in Java, but the other language ports are designed with essentially the same API naming and behavior.

```java
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.List;
import javax.imageio.ImageIO;
import io.nayuki.qrcodegen.*;

// Simple operation
QrCode qr0 = QrCode.encodeText("Hello, world!", QrCode.Ecc.MEDIUM);
BufferedImage img = toImage(qr0, 4, 10); // See QrCodeGeneratorDemo
ImageIO.write(img, "png", new File("qr-code.png"));

// Manual operation
List<QrSegment> segs = QrSegment.makeSegments("3141592653589793238462643383");
QrCode qr1 = QrCode.encodeSegments(segs, QrCode.Ecc.HIGH, 5, 5, 2, false);
for (int y = 0; y < qr1.size; y++) {
for (int x = 0; x < qr1.size; x++) {
(... paint qr1.getModule(x, y) ...)
}
}
```


License
-------

Copyright © 2022 Project Nayuki. (MIT License)
[https://www.nayuki.io/page/qr-code-generator-library](https://www.nayuki.io/page/qr-code-generator-library)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

* The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

* The Software is provided "as is", without warranty of any kind, express or
implied, including but not limited to the warranties of merchantability,
fitness for a particular purpose and noninfringement. In no event shall the
authors or copyright holders be liable for any claim, damages or other
liability, whether in an action of contract, tort or otherwise, arising from,
out of or in connection with the Software or the use or other dealings in the
Software.
21 changes: 21 additions & 0 deletions licenses/qrcodegencpp/qrcodegen-cmake/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021-2022 EasyCoding Team and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.