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

[apps][minizip] add minizip app & 增加 minizip 应用 #31

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions repo/packages/m/minizip/scripts/deploy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- 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.
--
-- Copyright (C) 2023-2023 RT-Thread Development Team
--
-- @author wcx1024979076
-- @file deploy.lua
--
-- Change Logs:
-- Date Author Notes
-- ------------ ---------- -----------------------------------------------
-- 2023-07-26 wcx1024979076 initial version
--
import("rt.rt_utils")

function main(rootfs, installdir)
for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do
local filename = path.filename(filepath)
rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename))
end
end
42 changes: 42 additions & 0 deletions repo/packages/m/minizip/scripts/export.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- 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.
--
-- Copyright (C) 2023-2023 RT-Thread Development Team
--
-- @author wcx1024979076
-- @file export.lua
--
-- Change Logs:
-- Date Author Notes
-- ------------ ---------- -----------------------------------------------
-- 2023-07-26 wcx1024979076 initial version
--
import("rt.rt_utils")

function main(rootfs, installdir)
for _, filedir in ipairs(os.filedirs(path.join(installdir, "include", "minizip") .. "/*")) do
local inc = path.join(installdir, "include", "minizip")
local name = path.relative(filedir, inc)
rt_utils.cp_with_symlink(path.join(inc, name), path.join(rootfs, "include", "minizip", name),
{rootdir = inc, symlink = true})
end

for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.a")) do
local filename = path.filename(filepath)
rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename))
end

for _, filepath in ipairs(os.files(path.join(installdir, "lib") .. "/lib*.so*")) do
local filename = path.filename(filepath)
rt_utils.cp_with_symlink(filepath, path.join(rootfs, "lib", filename))
end
end
72 changes: 72 additions & 0 deletions repo/packages/m/minizip/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
-- 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.
--
-- Copyright (C) 2023-2023 RT-Thread Development Team
--
-- @author wcx1024979076
-- @file xmake.lua
--
-- Change Logs:
-- Date Author Notes
-- ------------ ---------- -----------------------------------------------
-- 2023-07-26 wcx1024979076 initial version
--

package("minizip")
set_homepage("https://www.zlib.net/")
set_description("Mini zip and unzip based on zlib")
set_license("zlib")

add_urls("https://github.com/madler/zlib/archive/$(version).tar.gz",
"https://github.com/madler/zlib.git")
add_versions("v1.2.10", "42cd7b2bdaf1c4570e0877e61f2fdc0bce8019492431d054d3d86925e5058dc5")
add_versions("v1.2.11", "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff")
add_versions("v1.2.12", "d8688496ea40fb61787500e863cc63c9afcbc524468cedeb478068924eb54932")
add_versions("v1.2.13", "1525952a0a567581792613a9723333d7f8cc20b87a81f920fb8bc7e3f2251428")

add_configs("shared", {
description = "Build shared library.",
default = os.getenv("RT_XMAKE_LINK_TYPE") ~= "static",
type = "boolean"
})

on_load(function(package)
package:add("deps", "zlib", {debug = package:config("debug"), configs = {shared = package:config("shared")}})
end)

on_install(function (package)
import("rt.private.build.rtflags")
local info = rtflags.get_package_info(package)
local host = info.host
local configs = {host = host}
local cc = info.cc
local ldflags = {}
os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH"))

table.insert(configs, "--enable-static=yes")
if package:config("shared") then
table.insert(configs, "--enable-shared=yes")
else
table.insert(configs, "--enable-shared=no")
end

os.cd(path.join("contrib", "minizip"))

local buildenvs = import("package.tools.autoconf").buildenvs(package,
{ldflags = ldflags, packagedeps = {"zlib"}})
import("package.tools.autoconf").configure(package, configs, {envs = buildenvs})
import("package.tools.make").install(package, {}, {envs = buildenvs})
end)

on_test(function (package)
assert(package:has_cfuncs("inflate", {includes = "minizip/zip.h"}))
end)