Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Build Lite
提交
320fffce
B
Build Lite
项目概览
OpenHarmony
/
Build Lite
9 个月 前同步成功
通知
22
Star
24
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
Build Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
320fffce
编写于
11月 23, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
!625 解决联合门禁编译失败的问题
Merge pull request !625 from aodongbiao/cherry-pick-1669089062
上级
277ec43d
93df6d1f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
256 deletion
+6
-256
hb_internal/build/build_process.py
hb_internal/build/build_process.py
+4
-14
hb_internal/build/fs_process.py
hb_internal/build/fs_process.py
+0
-241
hb_internal/common/config.py
hb_internal/common/config.py
+2
-1
未找到文件。
hb_internal/build/build_process.py
浏览文件 @
320fffce
...
...
@@ -33,7 +33,6 @@ from hb_internal.common.config import Config
from
hb_internal.cts.cts
import
CTS
from
hb_internal.common.device
import
Device
from
hb_internal.common.product
import
Product
from
hb_internal.build.fs_process
import
Packer
from
hb_internal.build.patch_process
import
Patch
from
hb_internal.preloader.preloader
import
Preloader
from
hb_internal.common.misc
import
PreBuild
...
...
@@ -208,12 +207,6 @@ class Build():
cmd_list
.
append
(
self
.
gn_build
)
cmd_list
.
append
(
self
.
ninja_build
)
if
self
.
config
.
os_level
!=
"standard"
:
if
self
.
config
.
fs_attr
is
not
None
:
packer
=
Packer
()
cmd_list
.
append
(
packer
.
fs_make
)
return
cmd_list
def
env
(
self
):
...
...
@@ -275,14 +268,11 @@ class Build():
my_ninja_args
.
append
(
'-k1000000'
)
# Keep targets to the last
if
ninja_args
.
get
(
'default_target'
)
is
not
None
:
if
self
.
config
.
os_level
==
"standard"
:
if
self
.
config
.
product
==
'ohos-sdk'
:
my_ninja_args
.
append
(
'build_ohos_sdk'
)
else
:
my_ninja_args
.
append
(
'images'
)
if
ninja_args
.
get
(
'default_target'
)
is
not
None
:
if
self
.
config
.
product
==
'ohos-sdk'
:
my_ninja_args
.
append
(
'build_ohos_sdk'
)
else
:
my_ninja_args
.
append
(
'
pack
ages'
)
my_ninja_args
.
append
(
'
im
ages'
)
if
ninja_args
.
get
(
'targets'
):
my_ninja_args
.
extend
(
ninja_args
.
get
(
'targets'
))
ninja_cmd
=
[
...
...
hb_internal/build/fs_process.py
已删除
100644 → 0
浏览文件 @
277ec43d
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020 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.
#
from
collections
import
namedtuple
import
os
import
shutil
from
hb_internal.common.utils
import
exec_command
from
hb_internal.common.utils
import
makedirs
from
hb_internal.common.utils
import
read_yaml_file
from
hb_internal.common.utils
import
hb_info
from
hb_internal.common.utils
import
hb_warning
from
hb_internal.common.config
import
Config
class
Packer
():
def
__init__
(
self
)
->
None
:
self
.
config
=
Config
()
self
.
replace_items
=
{
r
'${product_name}'
:
self
.
config
.
product
,
r
'${root_path}'
:
self
.
config
.
root_path
,
r
'${out_path}'
:
self
.
config
.
out_path
}
self
.
packing_process
=
[
self
.
mv_usr_libs
,
self
.
create_fs_dirs
,
self
.
fs_link
,
self
.
fs_filemode
,
self
.
fs_make_cmd
,
self
.
fs_tear_down
]
self
.
fs_cfg
=
None
self
.
chmod_dirs
=
[]
def
mv_usr_libs
(
self
):
src_path
=
self
.
config
.
out_path
libs
=
[
lib
for
lib
in
os
.
listdir
(
src_path
)
if
self
.
is_lib
(
lib
)]
target_path
=
os
.
path
.
join
(
src_path
,
'usr'
,
'lib'
)
makedirs
(
target_path
,
exist_ok
=
True
)
for
lib
in
libs
:
source_file
=
os
.
path
.
join
(
src_path
,
lib
)
target_file
=
os
.
path
.
join
(
target_path
,
lib
)
shutil
.
move
(
source_file
,
target_file
)
@
classmethod
def
is_lib
(
cls
,
lib
):
return
lib
.
startswith
(
'lib'
)
and
lib
.
endswith
(
'.so'
)
@
classmethod
def
is_incr
(
cls
,
fs_incr
):
exist_ok
=
False
if
fs_incr
is
None
else
True
with_rm
=
True
if
fs_incr
is
None
else
False
return
exist_ok
,
with_rm
def
create_fs_dirs
(
self
):
fs_path
=
os
.
path
.
join
(
self
.
config
.
out_path
,
self
.
fs_cfg
.
get
(
'fs_dir_name'
,
'rootfs'
))
exist_ok
,
with_rm
=
self
.
is_incr
(
self
.
fs_cfg
.
get
(
'fs_incr'
,
None
))
makedirs
(
fs_path
,
exist_ok
=
exist_ok
,
with_rm
=
with_rm
)
self
.
replace_items
[
r
'${fs_dir}'
]
=
fs_path
for
fs_dir
in
self
.
fs_cfg
.
get
(
'fs_dirs'
,
[]):
source_dir
=
fs_dir
.
get
(
'source_dir'
,
''
)
target_dir
=
fs_dir
.
get
(
'target_dir'
,
''
)
if
target_dir
==
''
:
continue
source_path
=
self
.
fs_dirs_replace
(
source_dir
,
self
.
config
.
out_path
)
target_path
=
self
.
fs_dirs_replace
(
target_dir
,
fs_path
)
if
source_dir
==
''
or
not
os
.
path
.
exists
(
source_path
):
makedirs
(
target_path
)
target_mode_tuple
=
(
target_path
,
fs_dir
.
get
(
'dir_mode'
,
755
))
self
.
chmod_dirs
.
append
(
target_mode_tuple
)
continue
self
.
copy_files
(
source_path
,
target_path
,
fs_dir
)
def
fs_dirs_replace
(
self
,
path
,
default_path
):
source_path
,
is_changed
=
self
.
replace
(
path
)
if
not
is_changed
:
source_path
=
os
.
path
.
join
(
default_path
,
path
)
return
source_path
def
copy_files
(
self
,
spath
,
tpath
,
fs_dir
):
ignore_files
=
fs_dir
.
get
(
'ignore_files'
,
[])
dir_mode
=
fs_dir
.
get
(
'dir_mode'
,
755
)
file_mode
=
fs_dir
.
get
(
'file_mode'
,
555
)
def
copy_file_process
(
source_path
,
target_path
):
if
not
os
.
path
.
isdir
(
target_path
):
makedirs
(
target_path
)
self
.
chmod_dirs
.
append
((
target_path
,
dir_mode
))
tfile
=
os
.
path
.
join
(
target_path
,
os
.
path
.
basename
(
source_path
))
try
:
shutil
.
copy
(
sfile
,
tfile
,
follow_symlinks
=
False
)
self
.
chmod_dirs
.
append
((
tfile
,
file_mode
))
except
FileExistsError
:
hb_warning
(
f
'Target file:
{
tfile
}
already exists!'
)
if
os
.
path
.
isfile
(
spath
):
sfile
=
spath
copy_file_process
(
spath
,
tpath
)
return
for
srelpath
,
sfile
in
self
.
list_all_files
(
spath
,
ignore_files
):
tdirname
=
srelpath
.
replace
(
spath
,
tpath
)
copy_file_process
(
sfile
,
tdirname
)
@
classmethod
def
chmod
(
cls
,
file
,
mode
):
mode
=
int
(
str
(
mode
),
base
=
8
)
if
os
.
path
.
exists
(
file
):
os
.
chmod
(
file
,
mode
)
@
classmethod
def
filter
(
cls
,
files
,
ignore_list
):
if
ignore_list
is
None
or
not
len
(
ignore_list
):
return
files
filter_files
=
[]
for
file
in
files
:
flag
=
True
for
ignore
in
ignore_list
:
if
file
.
startswith
(
ignore
)
or
file
.
endswith
(
ignore
):
flag
=
False
break
if
flag
:
filter_files
.
append
(
file
)
return
filter_files
def
list_all_files
(
self
,
path
,
ignore_list
=
None
):
for
relpath
,
_
,
files
in
os
.
walk
(
path
):
files
=
self
.
filter
(
files
,
ignore_list
)
for
file
in
files
:
full_path
=
os
.
path
.
join
(
path
,
relpath
,
file
)
if
os
.
path
.
isfile
(
full_path
):
yield
relpath
,
full_path
def
replace
(
self
,
raw_str
):
old_str
=
raw_str
for
old
,
new
in
self
.
replace_items
.
items
():
raw_str
=
raw_str
.
replace
(
old
,
new
)
return
raw_str
,
old_str
!=
raw_str
def
fs_link
(
self
):
fs_symlink
=
self
.
fs_cfg
.
get
(
'fs_symlink'
,
[])
for
symlink
in
fs_symlink
:
source
,
_
=
self
.
replace
(
symlink
.
get
(
'source'
,
''
))
link_name
,
_
=
self
.
replace
(
symlink
.
get
(
'link_name'
,
''
))
if
os
.
path
.
exists
(
link_name
):
os
.
remove
(
link_name
)
os
.
symlink
(
source
,
link_name
)
def
fs_filemode
(
self
):
fs_filemode
=
self
.
fs_cfg
.
get
(
'fs_filemode'
,
[])
for
filestat
in
fs_filemode
:
file_dir
=
os
.
path
.
join
(
self
.
replace_items
[
r
'${fs_dir}'
],
filestat
.
get
(
'file_dir'
,
''
))
file_mode
=
filestat
.
get
(
'file_mode'
,
0
)
if
os
.
path
.
exists
(
file_dir
)
and
file_mode
>
0
:
self
.
chmod_dirs
.
append
((
file_dir
,
file_mode
))
for
file_dir
,
file_mode
in
self
.
chmod_dirs
:
self
.
chmod
(
file_dir
,
file_mode
)
def
fs_make_cmd
(
self
):
fs_make_cmd
=
self
.
fs_cfg
.
get
(
'fs_make_cmd'
,
[])
log_path
=
self
.
config
.
log_path
for
cmd
in
fs_make_cmd
:
cmd
,
_
=
self
.
replace
(
cmd
)
cmd
=
cmd
.
split
(
' '
)
exec_command
(
cmd
,
log_path
=
log_path
)
def
fs_tear_down
(
self
):
while
len
(
self
.
chmod_dirs
):
tfile
=
self
.
chmod_dirs
.
pop
()[
0
]
if
os
.
path
.
isfile
(
tfile
):
self
.
chmod
(
tfile
,
555
)
elif
os
.
path
.
isdir
(
tfile
):
self
.
chmod
(
tfile
,
755
)
def
fs_attr_process
(
self
,
fs_cfg
):
fs_attr
=
fs_cfg
.
get
(
'fs_attr'
,
{})
for
attr_key
,
attr_value
in
fs_attr
.
items
():
if
attr_key
in
self
.
config
.
fs_attr
:
for
target_key
,
target_value
in
attr_value
.
items
():
if
target_key
in
fs_cfg
:
fs_cfg
[
target_key
]
+=
target_value
else
:
fs_cfg
[
target_key
]
=
target_value
return
fs_cfg
def
fs_make
(
self
,
cmd_args
):
fs_cfg_path
=
os
.
path
.
join
(
self
.
config
.
product_path
,
'fs.yml'
)
if
not
os
.
path
.
isfile
(
fs_cfg_path
):
hb_info
(
f
'
{
fs_cfg_path
}
not found, stop packing fs. '
'If the product does not need to be packaged, ignore it.'
)
return
if
self
.
config
.
fs_attr
is
None
:
hb_info
(
'component compiling, no need to pack fs'
)
return
fs_cfg_list
=
read_yaml_file
(
fs_cfg_path
)
for
fs_cfg
in
fs_cfg_list
:
self
.
fs_cfg
=
self
.
fs_attr_process
(
fs_cfg
)
if
self
.
fs_cfg
.
get
(
'fs_dir_name'
,
None
)
is
None
:
continue
for
fs_process_func
in
self
.
packing_process
:
fs_process_func
()
if
__name__
==
"__main__"
:
packer
=
Packer
()
ConfigTest
=
namedtuple
(
'config'
,
[
'product'
,
'root_path'
,
'out_path'
,
'log_path'
,
'product_path'
,
'fs_attr'
])
packer
.
config
=
ConfigTest
(
''
,
''
,
''
,
''
,
set
())
packer
.
config
.
fs_attr
.
add
(
'dmverity_enable'
)
packer
.
replace_items
=
{
r
'${product_name}'
:
packer
.
config
.
product
,
r
'${root_path}'
:
packer
.
config
.
root_path
,
r
'${out_path}'
:
packer
.
config
.
out_path
}
packer
.
fs_make
(
''
)
hb_internal/common/config.py
浏览文件 @
320fffce
...
...
@@ -16,9 +16,10 @@
# limitations under the License.
import
os
import
sys
import
platform
from
distutils.spawn
import
find_executable
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))))
from
hb_internal
import
CONFIG_JSON
from
hb_internal
import
CONFIG_STRUCT
from
hb_internal
import
BUILD_TOOLS_CFG
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录