Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Build Lite
提交
de554e92
B
Build Lite
项目概览
OpenHarmony
/
Build Lite
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
de554e92
编写于
7月 28, 2021
作者:
P
pilipala195
提交者:
yangming_ha
7月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
!8 build tool download logic optimized
Signed-off-by:
N
yangming_ha
<
yangming_ha@163.com
>
上级
a7e9ddeb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
66 deletion
+47
-66
hb/__init__.py
hb/__init__.py
+15
-15
hb/common/config.py
hb/common/config.py
+25
-47
hb/common/utils.py
hb/common/utils.py
+7
-4
未找到文件。
hb/__init__.py
浏览文件 @
de554e92
...
...
@@ -45,21 +45,21 @@ CONFIG_STRUCT = {
VERSION
=
'0.4.3'
BUILD_TOOLS_URL
=
{
"gn"
:
{
"linux-x86"
:
'https://repo.huaweicloud.com/harmonyos/compiler/gn/'
+
\
'1717/linux/gn-linux-x86-1717.tar.gz'
,
"windows-amd64"
:
'https://repo.huaweicloud.com/harmonyos/compiler/gn/'
+
\
'1744/windows/gn-windows-amd64.zip'
},
"ninja"
:
{
"linux-x86"
:
'https://repo.huaweicloud.com/harmonyos/compiler/ninja/'
+
\
'1.10.1/linux/ninja-linux-x86-1.10.1.tar.gz'
,
"windows"
:
'https://repo.huaweicloud.com/harmonyos/compiler/ninja/'
+
\
'1.9.0/windows/ninja-win.zip'
},
"clang"
:
{
"linux"
:
'https://repo.huaweicloud.com/harmonyos/compiler/clang/'
+
\
BUILD_TOOLS_CFG
=
{
"Linux"
:
{
"build_tools_path"
:
'prebuilts/build-tools/linux-x86/bin'
,
"gn"
:
'https://repo.huaweicloud.com/harmonyos/compiler/gn/'
+
\
'1717/linux/gn-linux-x86-1717.tar.gz'
,
"ninja"
:
'https://repo.huaweicloud.com/harmonyos/compiler/ninja/'
+
\
'1.10.1/linux/ninja-linux-x86-1.10.1.tar.gz'
,
"clang"
:
'https://repo.huaweicloud.com/harmonyos/compiler/clang/'
+
\
'10.0.1-62608/linux/llvm.tar.gz'
},
"Windows"
:
{
"build_tools_path"
:
'prebuilts
\\
build-tools
\\
win-x86
\\
bin'
,
"gn"
:
'https://repo.huaweicloud.com/harmonyos/compiler/gn/'
+
\
'1744/windows/gn-windows-amd64.zip'
,
"ninja"
:
'https://repo.huaweicloud.com/harmonyos/compiler/ninja/'
+
\
'1.9.0/windows/ninja-win.zip'
}
}
hb/common/config.py
浏览文件 @
de554e92
...
...
@@ -21,13 +21,13 @@ from distutils.spawn import find_executable
from
hb
import
CONFIG_JSON
from
hb
import
CONFIG_STRUCT
from
hb
import
BUILD_TOOLS_
URL
from
hb
import
BUILD_TOOLS_
CFG
from
hb.common.utils
import
read_json_file
from
hb.common.utils
import
dump_json_file
from
hb.common.utils
import
Singleton
from
hb.common.utils
import
OHOSException
from
hb.common.utils
import
download_tool
from
hb.common.utils
import
extract_tool
from
hb.common.utils
import
makedirs
class
Config
(
metaclass
=
Singleton
):
...
...
@@ -44,6 +44,7 @@ class Config(metaclass=Singleton):
self
.
_patch_cache
=
config_content
.
get
(
'patch_cache'
,
None
)
self
.
_out_path
=
None
self
.
fs_attr
=
set
()
self
.
platform
=
platform
.
system
()
@
property
def
root_path
(
self
):
...
...
@@ -160,21 +161,11 @@ class Config(metaclass=Singleton):
@
property
def
build_tools_path
(
self
):
platform_name
=
platform
.
system
()
if
platform_name
==
'Linux'
:
return
os
.
path
.
join
(
self
.
root_path
,
'prebuilts'
,
'build-tools'
,
'linux-x86'
,
'bin'
)
if
platform_name
==
'Windows'
:
return
os
.
path
.
join
(
self
.
root_path
,
'prebuilts'
,
'build-tools'
,
'win-x86'
,
'bin'
)
raise
OHOSException
(
f
'unidentified platform:
{
platform_name
}
'
)
try
:
tools_path
=
BUILD_TOOLS_CFG
[
self
.
platform
][
'build_tools_path'
]
return
os
.
path
.
join
(
self
.
root_path
,
tools_path
)
except
KeyError
:
raise
OHOSException
(
f
'unidentified platform:
{
self
.
platform
}
'
)
@
property
def
gn_path
(
self
):
...
...
@@ -184,17 +175,12 @@ class Config(metaclass=Singleton):
return
repo_gn_path
# gn not install, download and extract it.
if
not
os
.
path
.
exists
(
self
.
build_tools_path
):
os
.
makedirs
(
self
.
build_tools_path
)
host
=
platform
.
system
()
if
host
==
'Linux'
:
gn_url
=
BUILD_TOOLS_URL
[
"gn"
][
"linux-x86"
]
gn_dst
=
os
.
path
.
join
(
self
.
build_tools_path
,
'gn.tar.gz'
)
elif
host
==
'Windows'
:
gn_url
=
BUILD_TOOLS_URL
[
"gn"
][
"windows-amd64"
]
gn_dst
=
os
.
path
.
join
(
self
.
build_tools_path
,
'gn.zip'
)
download_tool
(
gn_url
,
gn_dst
)
extract_tool
(
gn_dst
,
self
.
build_tools_path
)
makedirs
(
self
.
build_tools_path
,
exist_ok
=
True
)
gn_url
=
BUILD_TOOLS_CFG
[
self
.
platform
].
get
(
'gn'
)
gn_dst
=
os
.
path
.
join
(
self
.
build_tools_path
,
'gn_pkg'
)
download_tool
(
gn_url
,
gn_dst
,
tgt_dir
=
self
.
build_tools_path
)
return
repo_gn_path
@
property
...
...
@@ -205,15 +191,10 @@ class Config(metaclass=Singleton):
return
repo_ninja_path
# ninja not install, download and extract.
host
=
platform
.
system
()
if
host
==
'Linux'
:
ninja_url
=
BUILD_TOOLS_URL
[
"ninja"
][
"linux-x86"
]
ninja_dst
=
os
.
path
.
join
(
self
.
build_tools_path
,
'ninja.tar.gz'
)
elif
host
==
'Windows'
:
ninja_url
=
BUILD_TOOLS_URL
[
"ninja"
][
"windows"
]
ninja_dst
=
os
.
path
.
join
(
self
.
build_tools_path
,
'ninja.zip'
)
download_tool
(
ninja_url
,
ninja_dst
)
extract_tool
(
ninja_dst
,
self
.
build_tools_path
)
ninja_url
=
BUILD_TOOLS_CFG
[
self
.
platform
].
get
(
'ninja'
)
ninja_dst
=
os
.
path
.
join
(
self
.
build_tools_path
,
'ninja_pkg'
)
download_tool
(
ninja_url
,
ninja_dst
,
tgt_dir
=
self
.
build_tools_path
)
return
repo_ninja_path
@
property
...
...
@@ -239,16 +220,13 @@ class Config(metaclass=Singleton):
return
env_clang_path
# need auto download and extract clang.
clang_path
=
os
.
path
.
join
(
'prebuilts'
,
'clang'
,
'ohos'
,
'linux-x86_64'
)
if
not
os
.
path
.
exists
(
clang_path
):
os
.
makedirs
(
clang_path
)
clang_url
=
BUILD_TOOLS_URL
[
"clang"
][
"linux"
]
clang_dst
=
os
.
path
.
join
(
clang_path
,
'llvm.tar.gz'
)
download_tool
(
clang_url
,
clang_dst
)
extract_tool
(
clang_dst
,
clang_path
)
clang_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
repo_clang_path
,
os
.
pardir
))
makedirs
(
clang_path
,
exist_ok
=
True
)
clang_url
=
BUILD_TOOLS_CFG
[
self
.
platform
].
get
(
'clang'
)
clang_dst
=
os
.
path
.
join
(
clang_path
,
'clang_pkg'
)
download_tool
(
clang_url
,
clang_dst
,
tgt_dir
=
clang_path
)
return
f
'//
{
repo_clang_path
}
'
@
property
...
...
hb/common/utils.py
浏览文件 @
de554e92
...
...
@@ -235,7 +235,7 @@ class OHOSException(Exception):
pass
def
download_tool
(
url
,
dst
):
def
download_tool
(
url
,
dst
,
tgt_dir
=
None
):
try
:
res
=
requests
.
get
(
url
,
stream
=
True
,
timeout
=
(
5
,
9
))
except
OSError
:
...
...
@@ -259,17 +259,20 @@ def download_tool(url, dst):
download_size
+=
len
(
chunk
)
download_percent
=
round
(
float
(
download_size
/
total_size
*
100
),
2
)
print
(
'Progress: %s%%
\r
'
%
download_percent
,
end
=
' '
)
hb_info
(
f
'Download complete!'
)
hb_info
(
'Download complete!'
)
except
OSError
:
raise
OHOSException
(
f
'
{
url
}
download failed, please install it manually!'
)
if
tgt_dir
is
not
None
:
extract_tool
(
dst
,
tgt_dir
)
def
extract_tool
(
src
,
tgt_dir
):
hb_info
(
f
'Extracting to
{
tgt_dir
}
, please wait...'
)
try
:
if
src
.
endswith
((
'.tar.gz'
,
'.gz'
,
'.tar'
)
):
if
tarfile
.
is_tarfile
(
src
):
ef
=
tarfile
.
open
(
src
)
elif
src
.
endswith
(
'.zip'
):
elif
zipfile
.
is_zipfile
(
src
):
ef
=
zipfile
.
ZipFile
(
src
)
else
:
raise
OHOSException
(
f
'Extract file type not support!'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录