移植适配sane-airscan; Signed-off-by:liuhaosu@huawei.com

Signed-off-by: 刘昊苏 <liuhaosu@huawei.com>
This commit is contained in:
刘昊苏
2025-08-05 10:54:44 +08:00
parent 07ebd85003
commit b35d275eb1
6 changed files with 1367 additions and 0 deletions
+113
View File
@@ -0,0 +1,113 @@
#Copyright (c) 2025 Huawei Device Co., Ltd.
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
import("//build/ohos.gni")
source_dir = "//third_party/sane-airscan"
target_dir = "${target_gen_dir}/patches"
action("airscan_action") {
script = "//third_party/sane-airscan/patch_install.py"
inputs = [ "${source_dir}/patches/oh-transplant.patch" ]
outputs = [
"${target_dir}/patches/airscan-conf.c",
"${target_dir}/patches/airscan-devops.c",
"${target_dir}/patches/airscan-eloop.c",
"${target_dir}/patches/airscan-http.c",
"${target_dir}/patches/airscan-init.c",
"${target_dir}/patches/airscan-log.c",
"${target_dir}/patches/airscan-mdns.c",
"${target_dir}/patches/airscan-netif.c",
"${target_dir}/patches/airscan-pollable.c",
"${target_dir}/patches/airscan-tiff.c",
"${target_dir}/patches/airscan-wsd.c",
"${target_dir}/patches/airscan-zeroconf.c",
"${target_dir}/patches/airscan.c",
"${target_dir}/patches/airscan.h",
]
airscan_source_dir = rebase_path("${source_dir}", root_build_dir)
args = [
"--source-dir",
"$airscan_source_dir",
]
}
config("airscan_config") {
cflags = [
"-fno-exceptions",
"-fdata-sections",
"-ffunction-sections",
"-fno-asynchronous-unwind-tables",
"-fno-unwind-tables",
"-flto",
"-Os",
"-DOH_AIRSCAN",
]
}
ohos_shared_library("sane-airscan") {
include_dirs = [ "./airscan.h" ]
sources = [
"airscan-array.c",
"airscan-bmp.c",
"airscan-conf.c",
"airscan-devcaps.c",
"airscan-device.c",
"airscan-devid.c",
"airscan-devops.c",
"airscan-eloop.c",
"airscan-escl.c",
"airscan-filter.c",
"airscan-http.c",
"airscan-id.c",
"airscan-image.c",
"airscan-init.c",
"airscan-ip.c",
"airscan-jpeg.c",
"airscan-log.c",
"airscan-math.c",
"airscan-memstr.c",
"airscan-netif.c",
"airscan-os.c",
"airscan-png.c",
"airscan-pollable.c",
"airscan-rand.c",
"airscan-trace.c",
"airscan-xml.c",
"airscan-zeroconf.c",
"airscan.c",
"http_parser.c",
"sane_strstatus.c",
]
configs = [ ":airscan_config" ]
deps = [ ":airscan_action" ]
external_deps = [
"backends:sane",
"hilog:libhilog",
"libjpeg-turbo:turbojpeg",
"libpng:libpng",
"libuv:uv",
"libxml2:libxml2",
]
ldflags = [ "-ldl" ]
subsystem_name = "thirdparty"
part_name = "sane-airscan"
}
#the target group
group("third_airscan") {
deps = [ ":sane-airscan" ]
}
+11
View File
@@ -0,0 +1,11 @@
[
{
"Name" : "sane-airscan",
"License" : "GPL v2",
"License File" : "LICENSE",
"Version Number" : "0.99.35",
"Owner" : "guoshengbang@huawei.com",
"Upstream URL" : "https://github.com/alexpevzner/sane-airscan/releases/tag/0.99.35",
"Description" : "sane-airscan is an implementation of the AirScan/eSCL protocol in the SANE (Scanner Access Now Easy) framework. It allows access to scanner devices that support Apple AirScan or eSCL protocols through IP networks."
}
]
+49
View File
@@ -0,0 +1,49 @@
# sane-airscan
仓库包含第三方开源软件sane-airscan[sane-airscan](https://github.com/alexpevzner/sane-airscan)是SANEScanner Access Now Easy)框架的AirScan/eSCL协议实现。它允许通过IP网络访问支持Apple AirScan或eSCL协议的扫描仪设备。在OpenHarmony系统中,引入sane-airscan作为SANE的eSCL协议驱动后端。
## 引入背景简述
在OpenHarmony系统中,扫描仪的适配都是通过厂商安装私有协议驱动到SANE的后端,各厂家的驱动不通用;为了适配更多的扫描厂商和机型,需要引入sane-airscan来支持免驱扫描。
## 目录结构
```
patch/ # 补丁目录
patch_install.py # 补丁安装脚本
BUILD.gn # GN构建脚本
bundle.json # 部件描述文件
README.OpenSource # 开源声明文件
```
## OpenHarmony如何使用sane-airscan
sane-airscan无法单独使用,编译出来的驱动文件需要作为[SANE](https://gitee.com/openharmony/third_party_backends)的后端一起使用。详细使用方式参考[SANE公开文档](http://sane-project.org/docs.html)
## 移植说明
OpenHarmony版本通过以下补丁进行了移植适配:
- oh-transplant.patch:修改了多个源文件以适配OpenHarmony环境
- 主要修改涉及:
- 日志系统适配(hilog)
- 网络接口适配(avahi替换为libuv)
## 相关仓库
[backends](https://gitee.com/openharmony/third_party_backends)
[print_fwk](https://gitee.com/openharmony/print_print_fwk)
## License
sane-airscan使用GPLv2协议。
## 风险提示
**sane-airscan是GPLV2协议类型的三方开源软件,使用时需履行相应的开源义务。**
## 参与贡献
[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/参与贡献.md)
[Commit message规范](https://gitee.com/openharmony/device_qemu/wikis/Commit%20message%E8%A7%84%E8%8C%83)
+40
View File
@@ -0,0 +1,40 @@
{
"name": "@ohos/sane-airscan",
"description": "sane-airscan is an implementation of the AirScan/eSCL protocol in the SANE (Scanner Access Now Easy) framework. It allows access to scanner devices that support Apple AirScan or eSCL protocols through IP networks.",
"version": "0.99.35",
"license": "GPL v2",
"publishAs":"code-segment",
"segment":{
"destPath":"third_party/sane-airscan"
},
"dirs":{},
"scripts":{},
"licensePath": "COPYING",
"component": {
"name": "sane-airscan",
"subsystem": "thirdparty",
"syscap": [],
"features": [],
"adapted_system_type": [
"standard"
],
"rom": "10KB",
"ram": "10KB",
"deps": {
"components": [
"hilog",
"libxml2",
"libpng",
"libjpeg-turbo",
"backends",
"libuv"
]
},
"build": {
"sub_component": [
"//third_party/sane-airscan:third_airscan"
],
"test": []
}
}
}
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import tarfile
import argparse
import os
import subprocess
import sys
import shutil
def apply_patch(source_dir):
patch_list = [
'oh-transplant.patch',
]
for patch in patch_list:
patch_dir = os.path.join(source_dir, 'patches', patch)
patch_dir = os.path.abspath(patch_dir)
source_dir = os.path.abspath(source_dir)
patch_cmd = ['patch', '-p1', "--fuzz=0", "--no-backup-if-mismatch", '-i', patch_dir, '-d', source_dir]
try:
result = subprocess.run(patch_cmd, check=True, text=True, capture_output=True)
if result.returncode != 0:
raise subprocess.CalledProcessError(result.returncode, result.args)
except subprocess.CalledProcessError:
print("sane-backends: {} apply error!".format(patch))
def main():
backends_path = argparse.ArgumentParser()
backends_path.add_argument('--source-dir', help='generate path of log', required=True)
args = backends_path.parse_args()
source_dir = args.source_dir
apply_patch(source_dir)
return 0
if __name__ == '__main__':
sys.exit(main())
File diff suppressed because it is too large Load Diff