Skip to content

Commit

Permalink
Merge branch 'v2.x' of https://github.com/syberos-team/syberh into v2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jun_xue committed Oct 23, 2020
2 parents 0fc7a49 + 342d86c commit 52f49d7
Show file tree
Hide file tree
Showing 32 changed files with 491 additions and 162 deletions.
14 changes: 7 additions & 7 deletions packages/cli/bin/syberh-build
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ const projectConfPath = path.join(appPath, PROJECT_CONFIG)

program
.option('--type [typeName]', '运行编译类型,device:真机 simulator:模拟器')
.option('--debug', 'debug模式运行,支持热更新')
.option('--release', '构建release版本')
.option('--target [targetName]', '重置target,device:真机 simulator:模拟器')
.option('--env [env]', 'Env type')
.option('--onlybuild', '构建完成后不安装sop')
.option('--nodoctor', '构建时不执行环境检查')
.option('--s1', '构建S1手机可用的应用')
.parse(process.argv)

const { type, debug, nodoctor, onlybuild, s1 } = program
const { type, release, nodoctor, onlybuild, s1 } = program
let { env } = program
log.verbose('debug:', debug)
log.verbose('release:', release)
log.verbose('env:', env)
log.verbose('type:', type)

Expand All @@ -45,18 +45,18 @@ targetReset(appPath, program).then(() => {
if (env) {
process.env.NODE_ENV = env
} else {
if (debug) {
process.env.NODE_ENV = 'development'
} else {
if (release) {
process.env.NODE_ENV = 'production'
} else {
process.env.NODE_ENV = 'development'
}
}

process.env.SYBEROS_ENV = type

build(appPath, {
type,
debug,
release,
nodoctor,
onlyBuild,
s1
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/scripts/cdb-install-sop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ spawn $cdbPath -s $cdbDevice shell
expect {
"developer@" {
send "exit\r"
spawn $cdbPath -s $cdbDevice shell "/usr/bin/ins-tool -siu /tmp/$sopFilename && rm -f /tmp/$sopFilename"
spawn $cdbPath -s $cdbDevice shell "/usr/bin/ins-tool -iu /tmp/$sopFilename && rm -f /tmp/$sopFilename"
}
"root@" {
send "su install\r"
expect "install@" {
send "/usr/bin/ins-tool -siu /tmp/$sopFilename && exit\r"
send "/usr/bin/ins-tool -iu /tmp/$sopFilename && exit\r"
expect "root@" {send "rm -f /tmp/$sopFilename && exit\r"}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/scripts/ssh-install-sop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set sopid [lindex $argv 2]
set sopFilename [lindex $argv 3]

set timeout 1000
spawn ssh -p $port developer@$ip "/usr/bin/ins-tool -siu /tmp/$sopFilename && rm -f /tmp/$sopFilename"
spawn ssh -p $port developer@$ip "/usr/bin/ins-tool -iu /tmp/$sopFilename && rm -f /tmp/$sopFilename"
expect {
"(yes/no)?" {send "yes\r"; exp_continue}
"assword:" {send "system\r"}
Expand Down
53 changes: 29 additions & 24 deletions packages/cli/src/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ export class Build {
this.mkdirBuild()
// 2、拷贝www路径到模板下
await this.copywww()
// 3、生成证书
// 3、在platforms/syberos目录下生成project.config.json
this.generateProjectConfig();
// 4、生成证书
this.generateCert();
// 4、执行构建命令
// 5、执行构建命令
const sopPath = this.compile()
// 5、构建完成后执行回调
// 6、构建完成后执行回调
if (typeof buildSuccessCallback === 'function') {
// 构建完成后,回退到项目根目录
shelljs.cd('..')
Expand All @@ -133,9 +135,9 @@ export class Build {
// 定义编译目录
if (this.buildConfig.onlyBuild === true) {
// 如果是只打SOP包, 目录名的设备名为 device
this.buildDir = `${this.appPath}/.build-${DEVICES_TYPES.DEVICE}-${this.projectConfig.target}${this.buildConfig.debug ? '-Debug' : ''}`
this.buildDir = `${this.appPath}/.build-${DEVICES_TYPES.DEVICE}-${this.projectConfig.target}${this.buildConfig.release ? '' : '-Debug'}`
} else {
this.buildDir = `${this.appPath}/.build-${this.buildConfig.type}-${this.projectConfig.target}${this.buildConfig.debug ? '-Debug' : ''}`
this.buildDir = `${this.appPath}/.build-${this.buildConfig.type}-${this.projectConfig.target}${this.buildConfig.release ? '' : '-Debug'}`
}

if (!fs.pathExistsSync(this.buildDir)) {
Expand Down Expand Up @@ -170,6 +172,21 @@ export class Build {
log.info('已拷贝www目录,From:', wwwPath, ' To:', syberosPath)
}

/**
* 在platforms/syberos目录下生成project.config.json
*/
private generateProjectConfig(){
const projectConfObj : ExConfig = {
debug: !this.buildConfig.release,
logLevel: this.devLog,
...this.projectConfig
}
const projectConfigPath = path.join(this.appPath, 'platforms/syberos/project.config.json');

fs.writeJSONSync(projectConfigPath, projectConfObj);
log.info('生成配置:', projectConfigPath)
}

/**
* 生成证书
*/
Expand Down Expand Up @@ -237,12 +254,6 @@ export class Build {
private async compileApp(buildPkg: boolean): Promise<string | null> {
log.verbose('Build compileApp(%s)', buildPkg)

const exConfigObj : ExConfig = {
debug: this.buildConfig.debug,
logLevel: this.devLog,
...this.projectConfig
}

const compiler = new compile.Compiler()
const compileResult = await compiler.buildApp({
// 编译项目的pro文件位置
Expand All @@ -256,9 +267,9 @@ export class Build {
// 额外的qmake编译参数
qmakeArgs: [],
// 是否使用debug编译
debug: !!exConfigObj.debug,
// 扩展参数
exConfig: exConfigObj
debug: !this.buildConfig.release
// 预留扩展参数
// exConfig: exConfigObj
}, buildPkg);
return compileResult.sopPath;
}
Expand Down Expand Up @@ -287,20 +298,14 @@ export class Build {
qmakeArgs.push('DEFINES+=S1');
}

const exConfigObj : ExConfig = {
debug: this.buildConfig.debug,
logLevel: this.devLog,
...this.projectConfig
}

const compiler = new compile.Compiler()
compiler.buildPlugins({
// 指向应用中platform/syberos位置
platformSyberosPath: path.join(this.appPath, 'platforms/syberos'),
// 编译插件的名称
plugins: plugins,
// 应用的sopid
sopid: exConfigObj.sopid,
sopid: this.projectConfig.sopid,
// 编译输出目录
buildPath: this.buildDir,
// pdk命令所在位置
Expand All @@ -310,9 +315,9 @@ export class Build {
// 额外的qmake编译参数
qmakeArgs: qmakeArgs,
// 是否使用debug编译
debug: !!exConfigObj.debug,
// 扩展参数
exConfig: exConfigObj
debug: !this.buildConfig.release
// 预留扩展参数
// exConfig: exConfigObj
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/build/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface CompileGeneralConfig {
processNum?: number
// 是否使用debug编译
debug?: boolean
// 扩展参数
// 预留扩展参数
exConfig?: object
}

Expand Down
13 changes: 10 additions & 3 deletions packages/cli/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { IProjectConfig } from '../util/types'
import CONFIG from '../config'



/**
* build命令入口
* @param appPath 应用路径
* @param buildConfig build命令参数
*/
export default async function build(appPath: string, buildConfig: BuildConfig) {
if(buildConfig.type !== DEVICES_TYPES.DEVICE && buildConfig.type !== DEVICES_TYPES.SIMULATOR){
console.log(
Expand Down Expand Up @@ -50,6 +54,9 @@ async function executeBuild(appPath: string, config: BuildConfig) {
if(!projectConf.devServerPort){
projectConf.devServerPort = CONFIG.DEV_SERVER_PORT
}
if(!projectConf.debuggingPort){
projectConf.debuggingPort = CONFIG.DEBUGGING_PORT
}

console.log(chalk.green(`开始编译项目 ${chalk.bold(projectConf.projectName)}`))

Expand All @@ -58,8 +65,8 @@ async function executeBuild(appPath: string, config: BuildConfig) {
await build.start(null)
} else {
await build.start(() => {
// 启动devServer热更新服务
if (buildConfig.debug) {
// 非release构建时,启动devServer热更新服务
if (!buildConfig.release) {
// TODO 5.0暂时关闭热更新服务
if(isTargetOS_5(projectConf.target)){
log.verbose('os5.0暂时关闭热更新服务')
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/build/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { IProjectConfig } from '../util/types'

// build命令参数
export interface BuildConfig {
/**
* 适配器
*/
// 真机或模拟器
type: DEVICES_TYPES
nodoctor?: boolean,
// 是否检查项目
nodoctor?: boolean
// 只打SOP包,不运行
onlyBuild?: boolean
// 支持s1手机
s1?: boolean
debug: boolean
release: boolean
}

// 编译扩展参数
export interface ExConfig extends IProjectConfig {
logLevel: string
debug: boolean
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export default {
DEPLOY_IP: '192.168.100.100',
DEPLOY_PORT: '22',
DEV_SERVER_IP: '192.168.100.101',
DEV_SERVER_PORT: '4399'
DEV_SERVER_PORT: '4399',
DEBUGGING_PORT: '9867'
}
3 changes: 2 additions & 1 deletion packages/cli/src/create/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export default class Project extends Creator {
deployIP: CONFIG.DEPLOY_IP,
deployPort: CONFIG.DEPLOY_PORT,
devServerIP: CONFIG.DEV_SERVER_IP,
devServerPort: CONFIG.DEV_SERVER_PORT
devServerPort: CONFIG.DEV_SERVER_PORT,
debuggingPort: CONFIG.DEBUGGING_PORT
},
options
)
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,6 @@ export interface IProjectConfig {
devServerIP: string
// dev服务端口
devServerPort: string
// qtwebengine remote debugging 端口
debuggingPort: string
}
3 changes: 2 additions & 1 deletion packages/cli/templates/default/project
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"deployIP": "<%= deployIP %>",
"deployPort": "<%= deployPort %>",
"devServerIP": "<%= devServerIP %>",
"devServerPort": "<%= devServerPort %>"
"devServerPort": "<%= devServerPort %>",
"debuggingPort": "<%= debuggingPort %>"
}
5 changes: 4 additions & 1 deletion packages/syberos/app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ lib.path = $$INSTALL_DIR/
plugins.files = plugins
plugins.path = $$INSTALL_DIR/

INSTALLS += res meta syber lib plugins
projectconfig.files = project.config.json
projectconfig.path = $$INSTALL_DIR/

INSTALLS += res meta syber lib plugins projectconfig
5 changes: 2 additions & 3 deletions packages/syberos/app/qml/framework/SWebview59.qml
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,13 @@ CPage{
}

Keys.onReleased: {
LOG.logger.verbose('SWebview qml Keys.onReleased',Keys.onReleased)
LOG.logger.verbose('SWebview qml Keys.onReleased ', event.key, event.text)
keyEvent('onReleased', event)
//event.accepted = true
setDestroyStatus(true)
}

Keys.onPressed: {
LOG.logger.verbose('SWebview qml Keys.onPressed',Keys.onPressed)
LOG.logger.verbose('SWebview qml Keys.onPressed', event.key, event.text)
keyEvent('onPressed', event)
setDestroyStatus(true)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/syberos/app/qml/framework/js/webview/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ function WebView (options) {
that.trigger('keyEvent', object, eventType, event);
});

NativeSdkManager.request('DevTools*', 12378, '', '');
NativeSdkManager.request('Packages*', 151010, '', '');
NativeSdkManager.request('DevTools*', 12378, '', {});
NativeSdkManager.request('Packages*', 151010, '', {});
});

// 页面被打开
Expand Down
12 changes: 5 additions & 7 deletions packages/syberos/app/src/App_Workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@

#include "../../nativesdk/src/helper.h"
#include "../../nativesdk/src/framework/nativesdkmanager.h"
#include "../../nativesdk/src/framework/common/extendedconfig.h"
#include "../../nativesdk/src/framework/common/projectconfig.h"
#include "../../nativesdk/src/util/log.h"
// #include "../../vendor/syberh-framework/src/package.h"
#include "../../nativesdk/src/util/fileutil.h"
#include "../../nativesdk/src/framework/common/errorinfo.h"

Expand All @@ -26,10 +25,10 @@ using namespace NativeSdk;
App_Workspace::App_Workspace()
: CWorkspace()
{

ProjectConfig *projectConfig = ProjectConfig::instance();
// 设置日志级别,若开启了debug将日志级别强制设为verbose
QString logLevel = ExtendedConfig::instance()->getLogLevel();
bool debug = ExtendedConfig::instance()->isDebug();
QString logLevel = projectConfig->getLogLevel();
bool debug = projectConfig->isDebug();
if(debug){
logLevel = LOG_VERBOSE;
}
Expand All @@ -48,7 +47,7 @@ App_Workspace::App_Workspace()

// 开启 chromium devtools
if(debug){
QString devToolServer = ExtendedConfig::instance()->getDeployIP().append(":9867");
QString devToolServer = QString("%1:%2").arg(projectConfig->getDeployIP()).arg(projectConfig->getDebuggingPort());
qputenv("QTWEBENGINE_REMOTE_DEBUGGING", devToolServer.toLatin1());
qDebug() << "QTWEBENGINE_REMOTE_DEBUGGING:" << devToolServer;
}
Expand All @@ -64,7 +63,6 @@ App_Workspace::App_Workspace()
Helper *helper = Helper::instance();
m_view->rootContext()->setContextProperty("helper", helper);


NativeSdkManager * nativeSdkManager = NativeSdkManager::getInstance();
m_view->rootContext()->setContextProperty("NativeSdkManager",nativeSdkManager);

Expand Down
2 changes: 2 additions & 0 deletions packages/syberos/nativesdk/nativesdk.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ HEADERS += \
$$PWD/src/framework/common/networkstatus.h \
$$PWD/src/framework/common/errorinfo.h \
$$PWD/src/framework/common/extendedconfig.h \
$$PWD/src/framework/common/projectconfig.h \
$$PWD/src/framework/devtools/devtools.h \
$$PWD/src/framework/devtools/socketclient.h \
$$PWD/src/framework/devtools/devdownload.h \
Expand All @@ -46,6 +47,7 @@ SOURCES += \
$$PWD/src/framework/common/networkstatus.cpp \
$$PWD/src/framework/common/errorinfo.cpp \
$$PWD/src/framework/common/extendedconfig.cpp \
$$PWD/src/framework/common/projectconfig.cpp \
$$PWD/src/framework/devtools/socketclient.cpp \
$$PWD/src/framework/devtools/devdownload.cpp \
$$PWD/src/util/fileutil.cpp \
Expand Down
Loading

0 comments on commit 52f49d7

Please sign in to comment.