Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
Z
zstd
管理
动态
成员
标记
计划
议题
议题看板
里程碑
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
构建
流水线
作业
流水线计划
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
Xayah
zstd
提交
cdf73e91
提交
cdf73e91
编辑于
5 years ago
作者:
Carl Woffenden
浏览文件
操作
下载
补丁
差异文件
Rewrote the scripts to sh instead of bash
上级
e9c0fc12
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
contrib/declib/build.sh
+2
-1
2 个添加, 1 个删除
contrib/declib/build.sh
contrib/declib/combine.sh
+20
-18
20 个添加, 18 个删除
contrib/declib/combine.sh
有
22 个添加
和
19 个删除
contrib/declib/build.sh
+
2
−
1
浏览文件 @
cdf73e91
#!/bin/
ba
sh
#!/bin/sh
# Where to find the sources
ZSTD_SRC_ROOT
=
"../../lib"
...
...
@@ -10,6 +10,7 @@ OUT_FILE="tempbin"
OUT_WASM
=
"temp.wasm"
# Amalgamate the sources
echo
"Amalgamating files... this may take a few minutes"
./combine.sh
-r
"
$ZSTD_SRC_ROOT
"
-r
"
$ZSTD_SRC_ROOT
/common"
-r
"
$ZSTD_SRC_ROOT
/decompress"
-o
zstddeclib.c zstddeclib-in.c
# Did combining work?
if
[
$?
-ne
0
]
;
then
...
...
此差异已折叠。
点击以展开。
contrib/declib/combine.sh
+
20
−
18
浏览文件 @
cdf73e91
#!/bin/
ba
sh
#!/bin/sh
-e
# Tool to bundle multiple C/C++ source files, inlining any includes.
#
# Note: this POSIX-compliant script is many times slower than the original bash
# implementation (due to the grep calls) but it runs and works everywhere.
#
# TODO: ROOTS and FOUND as arrays (since they fail on paths with spaces)
# Common file roots
...
...
@@ -14,7 +17,7 @@ FOUND=""
DESTN
=
""
# Prints the script usage then exits
function
usage
{
usage
()
{
echo
"Usage:
$0
[-r <path>] [-o <outfile>] infile"
echo
" -r file root search paths"
echo
" -o output file (otherwise stdout)"
...
...
@@ -22,27 +25,26 @@ function usage {
exit
1
}
# Tests if list $1 has item $2
function
list_has_item
{
local
list
=
"
$1
"
local
item
=
"
$2
"
if
[[
$list
=
~
(
^|[[:space:]]
*
)
"
$item
"
(
$|
[[
:space:]]
*
)
]]
;
then
# Tests if list $1 has item $2 (returning zero on a match)
list_has_item
()
{
if
echo
"
$1
"
|
grep
-Eq
"(^|
\s
*)
$2
(
\$
|
\s
*)"
;
then
return
0
else
return
1
fi
return
1
}
# Adds a new line with the supplied arguments to $DESTN (or stdout)
function
write_line
{
write_line
()
{
if
[
-n
"
$DESTN
"
]
;
then
printf
"
%s
\n
"
"
$@
"
>>
"
$DESTN
"
printf
'
%s\n
'
"
$@
"
>>
"
$DESTN
"
else
printf
"
%s
\n
"
"
$@
"
printf
'
%s\n
'
"
$@
"
fi
}
# Adds the contents of $1 with any of its includes inlined
function
add_file
{
add_file
()
{
# Match the path
local
file
=
if
[
-f
"
$1
"
]
;
then
...
...
@@ -56,12 +58,12 @@ function add_file {
fi
if
[
-n
"
$file
"
]
;
then
# Read the file
local
line
local
line
=
while
IFS
=
read
-r
line
;
do
if
[[
$line
=
~ ^[[:space:]]
*
\#
[[
:space:]]
*
include[[:space:]]
*
\"
(
.
*
)
\"
.
*
]]
;
then
# We have an include directive
local
inc
=
$
{
BASH_REMATCH
[1]
}
if
!
`
list_has_item
"
$FOUND
"
"
$inc
"
`
;
then
if
echo
"
$line
"
|
grep
-Eq
'^\s*#\s*include\s*".+"'
;
then
# We have an include directive
so strip the (first) file
local
inc
=
$
(
echo
"
$line
"
|
grep
-Eo
'".*"'
|
grep
-Eo
'\w*(\.?\w+)+'
|
head
-1
)
if
!
list_has_item
"
$FOUND
"
"
$inc
"
;
then
# And we've not previously encountered it
FOUND
=
"
$FOUND
$inc
"
write_line
"/**** start inlining
$inc
****/"
...
...
@@ -102,7 +104,7 @@ if [ -n "$1" ]; then
fi
add_file
$1
else
echo
"Input file not found:
'
$1
'
"
echo
"Input file not found:
\"
$1
\"
"
exit
1
fi
else
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录