Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【don't merge】Openharmony adapted to the new Deveco(3.1 beta2) version #14804

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions scripts/native-pack-tool/source/platforms/openharmony.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { cchelper, Paths } from "../utils";
import { randomBytes } from "crypto";
import { outputJSONSync } from 'fs-extra';
import * as JSON5 from "json5"
import { writeFileSync } from "fs";

export interface IOrientation {
landscapeLeft: boolean;
Expand Down Expand Up @@ -96,13 +97,10 @@ export class OpenHarmonyPackTool extends NativePackTool {
stringJSON.string.find((item: any) => item.name === 'MainAbility_label').value = this.params.projectName;
outputJSONSync(stringJSONPath, stringJSON, { spaces: 2 });

const packageJsonPath = ps.join(ohosProjDir, 'package.json');
const packageJson = fs.readJSONSync(packageJsonPath);
const packageJsonPath = ps.join(ohosProjDir, 'oh-package.json5');
const packageJson = this.readJSON5Sync(packageJsonPath);
packageJson.name = this.params.projectName;
fs.writeJSONSync(packageJsonPath, packageJson, {
spaces: 4,
});

writeFileSync(packageJsonPath, JSON5.stringify(packageJson, null, 4));
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion templates/openharmony/entry/build-profile.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"cppFlags": "",
},
"compileMode": "esmodule",
"compileMode": "jsbundle",
},
"targets": [
{
Expand Down
9 changes: 9 additions & 0 deletions templates/openharmony/entry/oh-package.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"license": "ISC",
"devDependencies": {},
"name": "entry",
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {}
}
5 changes: 0 additions & 5 deletions templates/openharmony/entry/package-lock.json

This file was deleted.

14 changes: 0 additions & 14 deletions templates/openharmony/entry/package.json

This file was deleted.

48 changes: 48 additions & 0 deletions templates/openharmony/hvigorw
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# ----------------------------------------------------------------------------
# Hvigor startup script, version 1.0.0
#
# Required ENV vars:
# ------------------
# NODE_HOME - location of a Node home dir
# or
# Add /usr/local/nodejs/bin to the PATH environment variable
# ----------------------------------------------------------------------------

HVIGOR_APP_HOME=$(dirname $(readlink -f $0))
HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
warn() {
echo ""
echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}

error() {
echo ""
echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
}

fail() {
error "$@"
exit 1
}

# Determine node to start hvigor wrapper script
if [ -n "${NODE_HOME}" ];then
EXECUTABLE_NODE="${NODE_HOME}/bin/node"
if [ ! -x "$EXECUTABLE_NODE" ];then
fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
fi
else
EXECUTABLE_NODE="node"
which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path"
fi

# Check hvigor wrapper script
if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then
fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
fi

# start hvigor-wrapper script
exec "${EXECUTABLE_NODE}" \
"${HVIGOR_WRAPPER_SCRIPT}" "$@"
57 changes: 57 additions & 0 deletions templates/openharmony/hvigorw.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Hvigor startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
set NODE_EXE=node.exe

goto start

:start
@rem Find node.exe
if defined NODE_HOME goto findNodeFromNodeHome

%NODE_EXE% --version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.

goto fail

:findNodeFromNodeHome
set NODE_HOME=%NODE_HOME:"=%
set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%

if exist "%NODE_EXE_PATH%" goto execute
echo.
echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
echo.
echo Please set the NODE_HOME variable in your environment to match the
echo location of your NodeJs installation.

goto fail

:execute
@rem Execute hvigor
"%NODE_EXE%" %WRAPPER_MODULE_PATH% %*

:fail
exit /b 1
14 changes: 14 additions & 0 deletions templates/openharmony/oh-package-lock.json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions templates/openharmony/oh-package.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"license": "ISC",
"devDependencies": {
"@ohos/hypium": "1.0.6"
},
"name": "test-cases",
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {}
}
Loading