Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
64b21cc0
energy
项目概览
energye
/
energy
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
energy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
64b21cc0
编写于
9月 09, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
energy command-line tools: 优化 install
上级
215fe347
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
120 addition
and
40 deletion
+120
-40
cmd/energy/build.bat
cmd/energy/build.bat
+0
-4
cmd/internal/command/command.go
cmd/internal/command/command.go
+34
-4
cmd/internal/consts/consts.go
cmd/internal/consts/consts.go
+3
-0
cmd/internal/install.go
cmd/internal/install.go
+4
-2
cmd/internal/install/install.go
cmd/internal/install/install.go
+15
-2
cmd/internal/install/install_cef_framework.go
cmd/internal/install/install_cef_framework.go
+64
-28
未找到文件。
cmd/energy/build.bat
浏览文件 @
64b21cc0
...
...
@@ -8,10 +8,6 @@ set GOARCH=amd64
set
GOOS
=
windows
go
build
-ldflags
"-s -w"
-o
energy
-windows
-
64
.exe
energy
.go
set
GOARCH
=
arm64
set
GOOS
=
windows
go
build
-ldflags
"-s -w"
-o
energy
-windowsarm
-
64
.exe
energy
.go
set
GOARCH
=
amd64
set
GOOS
=
darwin
go
build
-ldflags
"-s -w"
-o
energy
-darwin
-
64
energy
.go
...
...
cmd/internal/command/command.go
浏览文件 @
64b21cc0
...
...
@@ -10,6 +10,9 @@
package
command
type
OS
string
type
Arch
string
type
Config
struct
{
Index
int
Wd
string
...
...
@@ -33,11 +36,14 @@ type Install struct {
Name
string
`short:"n" long:"name" description:"Name of the framework directory after installation" default:"EnergyFramework"`
Download
string
`short:"d" long:"download" description:"Download Source, 0:gitee or 1:github, Default empty" default:""`
All
bool
`short:"a" long:"all" description:"Install all, skip installation prompts (Y/n)"`
OS
OS
`long:"os" description:"Specify install OS: [windows, linux, darwin], default current system: os"`
Arch
Arch
`long:"arch" description:"Specify install ARCH: [386, amd64, arm64], Default current system: architecture"`
CEF
string
`short:"c" long:"cef" description:"Install system supports CEF version, provide 4 options, default empty. default, windows7, gtk2, flash" default:""`
IGolang
bool
ICEF
bool
INSIS
bool
IUPX
bool
IGolang
bool
// 是否已安装Golang
ICEF
bool
// 是否已安装CEF
INSIS
bool
// 是否已安装nsis
IUPX
bool
// 是否已安装upx
IsSame
bool
// 安装的OS和Arch是否为当前系统架构, 默认当前系统架构
}
type
Package
struct
{
...
...
@@ -70,3 +76,27 @@ type Build struct {
Upx
bool
`short:"u" long:"upx" description:"Set this parameter and install upx. Use upx to compress the execution file. windows"`
UpxFlag
string
`long:"upxFlag" description:"Upx command line parameters" default:""`
}
func
(
m
OS
)
IsWindows
()
bool
{
return
m
==
"windows"
}
func
(
m
OS
)
IsLinux
()
bool
{
return
m
==
"linux"
}
func
(
m
OS
)
IsDarwin
()
bool
{
return
m
==
"darwin"
}
func
(
m
Arch
)
Is386
()
bool
{
return
m
==
"386"
||
m
==
"32"
// windows32
}
func
(
m
Arch
)
IsAMD64
()
bool
{
return
m
==
"amd64"
}
func
(
m
Arch
)
IsARM64
()
bool
{
return
m
==
"arm64"
}
cmd/internal/consts/consts.go
浏览文件 @
64b21cc0
...
...
@@ -62,6 +62,9 @@ const (
IsWindows
=
runtime
.
GOOS
==
"windows"
//support
IsLinux
=
runtime
.
GOOS
==
"linux"
//support
IsDarwin
=
runtime
.
GOOS
==
"darwin"
//support
IsAMD64
=
runtime
.
GOARCH
==
"amd64"
IsARM64
=
runtime
.
GOARCH
==
"arm64"
Is386
=
runtime
.
GOARCH
==
"386"
)
const
(
...
...
cmd/internal/install.go
浏览文件 @
64b21cc0
...
...
@@ -16,14 +16,16 @@ import (
)
var
CmdInstall
=
&
command
.
Command
{
UsageLine
:
"install -p [path] -v [version] -n [name] -d [download] -a [all] -c [cef]"
,
UsageLine
:
"install -p [path] -v [version] -n [name] -d [download] -a [all] -c [cef]
-os -arch
"
,
Short
:
"Automatic installation and configuration of the energy framework complete development environment"
,
Long
:
`
-p Installation directory Default current directory
-v Specifying a version number,Default latest.\
-n Name of the framework directory after installation, Default EnergyFramework.\
-d Download Source, 0:gitee or 1:github, Default empty
-a Install all, skip installation prompts (Y/n), default empty:n
-a Install all, skip installation prompts (Y/n), default empty:false
-os Specify install OS: [windows, linux, darwin], default current os
-arch Specify install ARCH: [amd64, arm64, 386], default current arch
-c Install system supports CEF version, provide 4 options, default empty
default : Automatically select support for the latest version based on the current system.
109 : CEF 109.1.18 is the last one to support Windows 7.
...
...
cmd/internal/install/install.go
浏览文件 @
64b21cc0
...
...
@@ -86,7 +86,7 @@ func Install(c *command.Config) {
// 安装CEF二进制框架
cefFrameworkRoot
,
cefFrameworkSuccessCallback
=
installCEFFramework
(
c
)
// 设置 energy cef 环境变量
if
cefFrameworkRoot
!=
""
{
if
cefFrameworkRoot
!=
""
&&
c
.
Install
.
IsSame
{
env
.
SetEnergyHomeEnv
(
cefFrameworkRoot
)
}
// success 输出
...
...
@@ -121,7 +121,11 @@ func Install(c *command.Config) {
}
func
cefInstallPathName
(
c
*
command
.
Config
)
string
{
return
filepath
.
Join
(
c
.
Install
.
Path
,
consts
.
ENERGY
,
c
.
Install
.
Name
)
if
c
.
Install
.
IsSame
{
return
filepath
.
Join
(
c
.
Install
.
Path
,
consts
.
ENERGY
,
c
.
Install
.
Name
)
}
else
{
return
filepath
.
Join
(
c
.
Install
.
Path
,
consts
.
ENERGY
,
fmt
.
Sprintf
(
"%s_%s%s"
,
c
.
Install
.
Name
,
c
.
Install
.
OS
,
c
.
Install
.
Arch
))
}
}
func
goInstallPathName
(
c
*
command
.
Config
)
string
{
...
...
@@ -217,6 +221,15 @@ func initInstall(c *command.Config) {
// latest
c
.
Install
.
Version
=
"latest"
}
if
c
.
Install
.
OS
==
""
{
c
.
Install
.
OS
=
command
.
OS
(
runtime
.
GOOS
)
}
if
c
.
Install
.
Arch
==
""
{
c
.
Install
.
Arch
=
command
.
Arch
(
runtime
.
GOARCH
)
}
if
string
(
c
.
Install
.
OS
)
==
runtime
.
GOOS
&&
string
(
c
.
Install
.
Arch
)
==
runtime
.
GOARCH
{
c
.
Install
.
IsSame
=
true
}
// 创建安装目录
os
.
MkdirAll
(
c
.
Install
.
Path
,
fs
.
ModePerm
)
os
.
MkdirAll
(
cefInstallPathName
(
c
),
fs
.
ModePerm
)
...
...
cmd/internal/install/install_cef_framework.go
浏览文件 @
64b21cc0
...
...
@@ -20,7 +20,6 @@ import (
"github.com/energye/energy/v2/cmd/internal/tools"
"net/url"
"path/filepath"
"runtime"
"strconv"
"strings"
)
...
...
@@ -41,7 +40,7 @@ func installCEFFramework(c *command.Config) (string, func()) {
fmt
.
Println
(
"Error:"
,
err
.
Error
())
return
""
,
nil
}
extractOSConfig
:=
extractConfig
[
runtime
.
GOOS
]
.
(
map
[
string
]
any
)
extractOSConfig
:=
extractConfig
[
string
(
c
.
Install
.
OS
)
]
.
(
map
[
string
]
any
)
// 获取安装版本配置
downloadJSON
,
err
:=
tools
.
HttpRequestGET
(
consts
.
DownloadVersionURL
)
...
...
@@ -164,7 +163,7 @@ func installCEFFramework(c *command.Config) (string, func()) {
// 根据模块名拿到版本号
cefVersion
:=
tools
.
ToRNilString
(
installVersion
[
cefModuleName
],
""
)
// 当前模块版本支持系统,如果支持返回下载地址
libCEFOS
,
isSupport
:=
cefOS
(
cefModule
)
libCEFOS
,
isSupport
:=
cefOS
(
c
,
c
efModule
)
downloadCefURL
:=
tools
.
ToString
(
cefModule
[
"downloadUrl"
])
downloadCefURL
=
replaceSource
(
downloadCefURL
,
tools
.
ToString
(
cefModule
[
"downloadSource"
]),
tools
.
ToInt
(
cefModule
[
"downloadSourceSelect"
]),
"cef"
)
downloadCefURL
=
strings
.
ReplaceAll
(
downloadCefURL
,
"{version}"
,
cefVersion
)
...
...
@@ -176,7 +175,7 @@ func installCEFFramework(c *command.Config) (string, func()) {
// 最后根据模块名称来确定使用哪个liblcl
liblclVersion
:=
tools
.
ToRNilString
(
installVersion
[
liblclModuleName
],
""
)
if
liblclModule
!=
nil
{
libEnergyOS
,
isSupport
:=
liblclOS
(
cef
,
liblclVersion
,
tools
.
ToString
(
liblclModule
[
"buildSupportOSArch"
]))
libEnergyOS
,
isSupport
:=
liblclOS
(
c
,
c
ef
,
liblclVersion
,
tools
.
ToString
(
liblclModule
[
"buildSupportOSArch"
]))
downloadEnergyURL
:=
tools
.
ToString
(
liblclModule
[
"downloadUrl"
])
downloadEnergyURL
=
replaceSource
(
downloadEnergyURL
,
tools
.
ToString
(
liblclModule
[
"downloadSource"
]),
tools
.
ToInt
(
liblclModule
[
"downloadSourceSelect"
]),
"liblcl"
)
module
:=
tools
.
ToString
(
liblclModule
[
"module"
])
...
...
@@ -246,7 +245,7 @@ func installCEFFramework(c *command.Config) (string, func()) {
}
}
func
cefOS
(
module
map
[
string
]
any
)
(
string
,
bool
)
{
func
cefOS
(
c
*
command
.
Config
,
module
map
[
string
]
any
)
(
string
,
bool
)
{
buildSupportOSArch
:=
tools
.
ToString
(
module
[
"buildSupportOSArch"
])
mod
:=
tools
.
ToString
(
module
[
"module"
])
archs
:=
strings
.
Split
(
buildSupportOSArch
,
","
)
...
...
@@ -258,27 +257,58 @@ func cefOS(module map[string]any) (string, bool) {
}
return
false
}
if
consts
.
IsWindows
{
// windows arm for 64 bit, windows for 32/64 bit
if
runtime
.
GOARCH
==
"arm64"
{
//if consts.IsWindows { // windows arm for 64 bit, windows for 32/64 bit
// if consts.IsARM64 {
// return "windowsarm64", isSupport(consts.WindowsARM64)
// }
// if strconv.IntSize == 32 {
// return fmt.Sprintf("windows%d", strconv.IntSize), isSupport(consts.Windows32)
// }
// return fmt.Sprintf("windows%d", strconv.IntSize), isSupport(consts.Windows64)
//} else if consts.IsLinux { //linux for 64 bit
// if consts.IsARM64 {
// if mod == consts.Cef106 {
// return "linuxarm64", isSupport(consts.LinuxARM64GTK2)
// }
// return "linuxarm64", isSupport(consts.LinuxARM64) || isSupport(consts.LinuxARM64GTK3)
// } else if consts.IsAMD64 {
// if mod == consts.Cef106 {
// return "linux64", isSupport(consts.Linux64GTK2)
// }
// return "linux64", isSupport(consts.Linux64) || isSupport(consts.Linux64GTK3)
// }
//} else if consts.IsDarwin { // macosx for 64 bit
// //if runtime.GOARCH == "arm64" {
// // return "macosarm64", isSupport(MacOSARM64)
// //} else if runtime.GOARCH == "amd64" {
// // return "macosx64", isSupport(MacOSX64)
// //}
// // Mac amd64 m1 m2 架构目前使用amd64, m1,m2使用Rosetta2兼容
// return "macosx64", isSupport(consts.MacOSX64)
//}
if
c
.
Install
.
OS
.
IsWindows
()
{
// windows arm for 64 bit, windows for 32/64 bit
if
c
.
Install
.
Arch
.
IsARM64
()
{
return
"windowsarm64"
,
isSupport
(
consts
.
WindowsARM64
)
}
if
strconv
.
IntSize
==
32
{
return
fmt
.
Sprintf
(
"windows%d"
,
strconv
.
IntSize
)
,
isSupport
(
consts
.
Windows32
)
if
c
.
Install
.
Arch
.
Is386
()
{
return
"windows32"
,
isSupport
(
consts
.
Windows32
)
}
return
fmt
.
Sprintf
(
"windows%d"
,
strconv
.
IntSize
)
,
isSupport
(
consts
.
Windows64
)
}
else
if
c
onsts
.
IsLinux
{
//linux for 64 bit
if
runtime
.
GOARCH
==
"arm64"
{
return
"windows64"
,
isSupport
(
consts
.
Windows64
)
}
else
if
c
.
Install
.
OS
.
IsLinux
()
{
//linux for 64 bit
if
c
.
Install
.
Arch
.
IsARM64
()
{
if
mod
==
consts
.
Cef106
{
return
"linuxarm64"
,
isSupport
(
consts
.
LinuxARM64GTK2
)
}
return
"linuxarm64"
,
isSupport
(
consts
.
LinuxARM64
)
||
isSupport
(
consts
.
LinuxARM64GTK3
)
}
else
if
runtime
.
GOARCH
==
"amd64"
{
}
else
if
c
.
Install
.
Arch
.
IsAMD64
()
{
if
mod
==
consts
.
Cef106
{
return
"linux64"
,
isSupport
(
consts
.
Linux64GTK2
)
}
return
"linux64"
,
isSupport
(
consts
.
Linux64
)
||
isSupport
(
consts
.
Linux64GTK3
)
}
}
else
if
c
onsts
.
IsDarwin
{
// macosx for 64 bit
}
else
if
c
.
Install
.
OS
.
IsDarwin
()
{
// macosx for 64 bit
//if runtime.GOARCH == "arm64" {
// return "macosarm64", isSupport(MacOSARM64)
//} else if runtime.GOARCH == "amd64" {
...
...
@@ -288,7 +318,7 @@ func cefOS(module map[string]any) (string, bool) {
return
"macosx64"
,
isSupport
(
consts
.
MacOSX64
)
}
//not support
return
fmt
.
Sprintf
(
"%v %v"
,
runtime
.
GOOS
,
runtime
.
GOARCH
),
false
return
fmt
.
Sprintf
(
"%v %v"
,
c
.
Install
.
OS
,
c
.
Install
.
Arch
),
false
}
var
liblclFileNames
=
map
[
string
]
string
{
...
...
@@ -308,25 +338,31 @@ var liblclFileNames = map[string]string{
"darwin64_old"
:
"MacOSX x86 64 bits"
,
}
func
liblclName
(
version
,
cef
string
)
(
string
,
bool
)
{
func
liblclName
(
c
*
command
.
Config
,
version
,
cef
string
)
(
string
,
bool
)
{
var
key
string
var
isOld
bool
if
runtime
.
GOARCH
==
"arm64"
{
if
c
onsts
.
IsLinux
&&
cef
==
consts
.
Cef106
{
// 只linux区别liblcl gtk2
if
c
.
Install
.
Arch
.
IsARM64
()
{
if
c
.
Install
.
OS
.
IsLinux
()
&&
cef
==
consts
.
Cef106
{
// 只linux区别liblcl gtk2
key
=
"linuxarm64gtk2"
}
else
{
if
c
onsts
.
IsDarwin
{
if
c
.
Install
.
OS
.
IsDarwin
()
{
// Mac amd64 m1 m2 架构目前使用amd64, m1,m2使用Rosetta2兼容
key
=
fmt
.
Sprintf
(
"%samd64"
,
runtime
.
GO
OS
)
key
=
fmt
.
Sprintf
(
"%samd64"
,
c
.
Install
.
OS
)
}
else
{
key
=
fmt
.
Sprintf
(
"%sarm64"
,
runtime
.
GO
OS
)
key
=
fmt
.
Sprintf
(
"%sarm64"
,
c
.
Install
.
OS
)
}
}
}
else
{
if
c
onsts
.
IsLinux
&&
cef
==
consts
.
Cef106
{
// 只linux区别liblcl gtk2
if
c
.
Install
.
OS
.
IsLinux
()
&&
cef
==
consts
.
Cef106
{
// 只linux区别liblcl gtk2
key
=
"linux64gtk2"
}
else
{
key
=
fmt
.
Sprintf
(
"%s%d"
,
runtime
.
GOOS
,
strconv
.
IntSize
)
var
arch
command
.
Arch
if
c
.
Install
.
Arch
.
Is386
()
{
arch
=
"32"
// windows32
}
else
{
arch
=
c
.
Install
.
Arch
}
key
=
fmt
.
Sprintf
(
"%s%s"
,
c
.
Install
.
OS
,
arch
)
}
}
if
tools
.
Compare
(
"2.2.4"
,
version
)
{
...
...
@@ -344,15 +380,15 @@ func liblclName(version, cef string) (string, bool) {
// 命名规则 OS+[ARCH]+BIT+[GTK2]
// ARCH: 非必需, ARM 时填写, AMD为空
// GTK2: 非必需, GTK2(Linux CEF 106) 时填写, 非Linux或GTK3时为空
func
liblclOS
(
cef
,
version
,
buildSupportOSArch
string
)
(
string
,
bool
)
{
func
liblclOS
(
c
*
command
.
Config
,
c
ef
,
version
,
buildSupportOSArch
string
)
(
string
,
bool
)
{
archs
:=
strings
.
Split
(
buildSupportOSArch
,
","
)
var
goarch
string
if
c
onsts
.
IsWindows
&&
runtime
.
GOARCH
==
"386"
{
if
c
.
Install
.
OS
.
IsWindows
()
&&
c
.
Install
.
Arch
.
Is386
()
{
goarch
=
"32"
// windows32 = > windows386
}
else
{
goarch
=
runtime
.
GOARCH
goarch
=
string
(
c
.
Install
.
Arch
)
}
noSuport
:=
fmt
.
Sprintf
(
"%v %v"
,
runtime
.
GO
OS
,
goarch
)
noSuport
:=
fmt
.
Sprintf
(
"%v %v"
,
c
.
Install
.
OS
,
goarch
)
var
isSupport
=
func
(
goarch
string
)
bool
{
for
_
,
v
:=
range
archs
{
if
goarch
==
v
{
...
...
@@ -361,7 +397,7 @@ func liblclOS(cef, version, buildSupportOSArch string) (string, bool) {
}
return
false
}
if
name
,
isOld
:=
liblclName
(
version
,
cef
);
isOld
{
if
name
,
isOld
:=
liblclName
(
c
,
version
,
cef
);
isOld
{
if
name
==
""
{
return
noSuport
,
false
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录