Skip to content

Commit

Permalink
Merge branch 'v3.8.2' into v3.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hana-alice committed Sep 8, 2023
2 parents 0561206 + 2ed62f7 commit 571c354
Show file tree
Hide file tree
Showing 47 changed files with 10,819 additions and 607 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/generate-oh-sdk-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: <Native> Generate OH SDK Cache

on:
workflow_dispatch:
inputs:
oh_sdk_version:
description: 'Openharmony SDK version'
type: string
default: '9'
required: true

jobs:
generate_oh_sdk_cache:
name: "Generate OH SDK cache"
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v3
id: setup-jdk
with:
distribution: 'zulu'
java-version: '17'

- name: Get oh sdk cache directory path
id: oh-sdk-cache-dir-path
run: |
echo "cache dir: "
echo "dir=$HOME/openharmony" >> $GITHUB_OUTPUT
- name: Output cache dir
run: |
echo "Output cache dir: ${{ steps.oh-sdk-cache-dir-path.outputs.dir }}"
- name: Cache OH SDK
id: cache-oh-sdk
uses: actions/cache@v3
env:
cache-name: cache-oh-sdk-${{ github.event.inputs.oh_sdk_version }}
with:
path: ${{ steps.oh-sdk-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}

- name: Add package.json
run: |
echo "{}" > package.json
echo "{\"name\": \"tests\",\"lockfileVersion\": 3,\"requires\": true,\"packages\": {}}" > package-lock.json
- uses: actions/setup-node@v3
with:
node-version: 14
cache: 'npm'

- if: ${{ steps.cache-oh-sdk.outputs.cache-hit != 'true' }}
name: No Cache found, install oh sdk
continue-on-error: false
run: |
if [ ! -d "$HOME/openharmony" ]; then
mkdir -p $HOME/openharmony
echo "Download commandline-tools-linux.zip ..."
curl -o commandline-tools-linux.zip "https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_package_901_9/b1/v3/E6zhv5UFQ2-inIwNJhTN6Q/commandline-tools-linux-2.0.0.2.zip?HW-CC-KV=V1&HW-CC-Date=20230621T074401Z&HW-CC-Expire=315360000&HW-CC-Sign=621224257B02079B1E76C0A56FDF21483400B1E3556213F88DC79BC9BE7D595D"
echo "Unzip commandline-tools-linux.zip ..."
unzip commandline-tools-linux.zip -d $HOME/openharmony > /dev/null
cd $HOME/openharmony
ls -l
cd command-line-tools
echo "=============== PATCHING sdkmanager/bin/sdkmgr file ==============="
sed -i "s@-Dfile.encoding=UTF-8@-Dfile.encoding=UTF-8 -Duser.country=CN@g" ./sdkmanager/bin/sdkmgr
cd bin
./sdkmgr list
echo "=============== INSTALL HOS toolchains:${{ github.event.inputs.oh_sdk_version }} ==============="
./sdkmgr install toolchains:${{ github.event.inputs.oh_sdk_version }} --accept-license > /dev/null
echo "=============== INSTALL OH SDK ets:${{ github.event.inputs.oh_sdk_version }} ==============="
./sdkmgr install OpenHarmony/ets:${{ github.event.inputs.oh_sdk_version }} --accept-license > /dev/null
echo "=============== INSTALL OH SDK js:${{ github.event.inputs.oh_sdk_version }} ==============="
./sdkmgr install OpenHarmony/js:${{ github.event.inputs.oh_sdk_version }} --accept-license > /dev/null
echo "=============== INSTALL OH SDK native:${{ github.event.inputs.oh_sdk_version }} ==============="
./sdkmgr install OpenHarmony/native:${{ github.event.inputs.oh_sdk_version }} --accept-license > /dev/null
echo "=============== INSTALL OH SDK toolchains:${{ github.event.inputs.oh_sdk_version }} ==============="
./sdkmgr install OpenHarmony/toolchains:${{ github.event.inputs.oh_sdk_version }} --accept-license > /dev/null
echo "=============== INSTALL OH SDK DONE ==============="
./sdkmgr list
fi
22 changes: 22 additions & 0 deletions .github/workflows/generate-vulkan-sdk-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: <Native> Generate Vulkan SDK Cache

on:
workflow_dispatch:
inputs:
vulkan_sdk_version:
description: 'Vulkan SDK version'
type: string
default: '1.2.189.0'
required: true

jobs:
generate_vulkan_sdk_cache:
name: "Generate Vulkan SDK cache"
runs-on: windows-2019
steps:
- name: Setup Vulkan SDK
uses: humbletim/setup-vulkan-sdk@v1.2.0
with:
vulkan-query-version: ${{ github.event.inputs.vulkan_sdk_version }}
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true
151 changes: 151 additions & 0 deletions .github/workflows/native-compile-platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,157 @@ jobs:
df -h
echo "Compile Android Debug Done!"
compile_openharmony:
name: "Openharmony"
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download external libraries
shell: bash
run: |
EXT_VERSION=`node ./.github/workflows/get-native-external-version.js`
git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external native/external
- uses: actions/setup-java@v3
id: setup-jdk
with:
distribution: 'zulu'
java-version: '17'
- name: Get oh sdk cache directory path
id: oh-sdk-cache-dir-path
run: |
echo "cache dir: "
echo "dir=$HOME/openharmony" >> $GITHUB_OUTPUT
- name: Output cache dir
run: |
echo "Output cache dir: ${{ steps.oh-sdk-cache-dir-path.outputs.dir }}"
- name: Cache OH SDK
id: cache-oh-sdk
uses: actions/cache@v3
env:
cache-name: cache-oh-sdk-9
with:
path: ${{ steps.oh-sdk-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}

- name: Add package.json
run: |
echo "{}" > package.json
echo "{\"name\": \"tests\",\"lockfileVersion\": 3,\"requires\": true,\"packages\": {}}" > package-lock.json
- uses: actions/setup-node@v3
with:
node-version: 14
cache: 'npm'

- if: ${{ steps.cache-oh-sdk.outputs.cache-hit != 'true' }}
name: No Cache found, install oh sdk
continue-on-error: false
run: |
if [ ! -d "$HOME/openharmony" ]; then
mkdir -p $HOME/openharmony
echo "Download commandline-tools-linux.zip ..."
curl -o commandline-tools-linux.zip "https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_package_901_9/b1/v3/E6zhv5UFQ2-inIwNJhTN6Q/commandline-tools-linux-2.0.0.2.zip?HW-CC-KV=V1&HW-CC-Date=20230621T074401Z&HW-CC-Expire=315360000&HW-CC-Sign=621224257B02079B1E76C0A56FDF21483400B1E3556213F88DC79BC9BE7D595D"
echo "Unzip commandline-tools-linux.zip ..."
unzip commandline-tools-linux.zip -d $HOME/openharmony > /dev/null
cd $HOME/openharmony
ls -l
cd command-line-tools
echo "=============== PATCHING sdkmanager/bin/sdkmgr file ==============="
sed -i "s@-Dfile.encoding=UTF-8@-Dfile.encoding=UTF-8 -Duser.country=CN@g" ./sdkmanager/bin/sdkmgr
cd bin
./sdkmgr list
echo "=============== INSTALL HOS toolchains:9 ==============="
./sdkmgr install toolchains:9 --accept-license > /dev/null
echo "=============== INSTALL OH SDK ets:9 ==============="
./sdkmgr install OpenHarmony/ets:9 --accept-license > /dev/null
echo "=============== INSTALL OH SDK js:9 ==============="
./sdkmgr install OpenHarmony/js:9 --accept-license > /dev/null
echo "=============== INSTALL OH SDK native:9 ==============="
./sdkmgr install OpenHarmony/native:9 --accept-license > /dev/null
echo "=============== INSTALL OH SDK toolchains:9 ==============="
./sdkmgr install OpenHarmony/toolchains:9 --accept-license > /dev/null
echo "=============== INSTALL OH SDK DONE ==============="
./sdkmgr list
fi
- name: Compile for Openharmony
run: |
which node
which npm
which java
node -v
npm -v
java --version
echo "=============== list files in oh sdk ($HOME/openharmony) ==============="
pushd $HOME/openharmony
ls -l
popd
NATIVE_ROOT=$GITHUB_WORKSPACE/native
echo "Compiling Openharmony ... "
cd $GITHUB_WORKSPACE/templates/openharmony
echo "message(STATUS \"hook before \${CC_TARGET_NAME}\")" >> Pre-Sample.cmake
echo "message(STATUS \"hook after \${CC_TARGET_NAME}\")" >> Post-Sample.cmake
mkdir -p build-oh/proj
touch build-oh/proj/cfg.cmake
echo "set(CC_USE_GLES3 ON)" >> build-oh/proj/cfg.cmake
echo "set(CC_USE_VULKAN OFF)" >> build-oh/proj/cfg.cmake
echo "set(CC_USE_GLES2 ON)" >> build-oh/proj/cfg.cmake
echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-oh/proj/cfg.cmake
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-oh/proj/cfg.cmake
echo "set(COCOS_X_PATH $NATIVE_ROOT)" >> build-oh/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-oh/proj/cfg.cmake
echo "set(USE_SE_V8 OFF)" >> build-oh/proj/cfg.cmake
echo "set(USE_SE_NAPI ON)" >> build-oh/proj/cfg.cmake
echo "=============== cat build-oh/proj/cfg.cmake ==============="
cat build-oh/proj/cfg.cmake
mkdir -p build-oh/assets
ASSET_DIR=$GITHUB_WORKSPACE/templates/openharmony/build-oh
echo "=============== HACK ./entry/build-profile.json5 ==============="
sed -i "s@[^-]DRES_DIR[^=]@$ASSET_DIR@g" ./entry/build-profile.json5
sed -i "s@[^-]DCOMMON_DIR[^=]@$GITHUB_WORKSPACE/templates/common@g" ./entry/build-profile.json5
# To speedup CI, compile arm64-v8a only
sed -i "s@\"armeabi-v7a\",@@g" ./entry/build-profile.json5
echo "entry/build-profile.json5: "
cat ./entry/build-profile.json5
echo "=============== HACK ./hvigor/hvigor-wrapper.js ==============="
sed -i "s@HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,\[\"install\"\]@HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,\[\"install\", \"--lockfile=false\"\]@g" ./hvigor/hvigor-wrapper.js
echo "=============== SET NPM OH REGISTRY ==============="
echo "@ohos:registry=https://repo.harmonyos.com/npm/" >> ~/.npmrc
npm config get @ohos:registry
npm config get registry
echo "=============== UPDATE local.properties ==============="
echo "nodejs.dir=/usr/bin" >> local.properties
echo "hwsdk.dir=$HOME/openharmony/hwsdk" >> local.properties
echo "=============== UPDATE ./hvigor/hvigor-config.json5 ==============="
echo "{\"hvigorVersion\":\"3.0.2\",\"dependencies\":{\"@ohos/hvigor-ohos-plugin\":\"3.0.2\"}}" > ./hvigor/hvigor-config.json5
echo "=============== Do not import game.ts for cocos_worker.ts ==============="
sed -i '/<% if(!useV8) { %>/,/<% } %>/d' ./entry/src/main/ets/workers/cocos_worker.ts
echo "=============== EXECUTE hvigorw ==============="
./hvigorw clean -i
./hvigorw --stop-daemon -i
./hvigorw assembleHap -p debuggable=true --no-daemon -d
#./hvigorw default@ProcessLibs -p debuggable=true --no-daemon -d
echo "=============== EXECUTE hvigorw DONE ==============="
compile_mac_x86_64:
name: "MacOS x86_64"
if:
Expand Down
15 changes: 7 additions & 8 deletions cocos/core/geometry/geometry-native-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { Sphere } from './sphere';
import { AABB } from './aabb';
import { Capsule } from './capsule';
import { Frustum } from './frustum';
import { assert } from '../platform/debug';

/**
* cache jsb attributes in js, reduce cross language invokations.
Expand Down Expand Up @@ -87,10 +88,9 @@ const defineAttrFloat = (kls: Constructor, attr: string): void => {
// __nativeFields__ is defined in jsb_geometry_manual.cpp
const desc: FieldDesc = (kls as any).__nativeFields__[attr];
const cacheKey = `_$_${attr}`;
if (!window.oh) {
// openharmony does not support the console.assert interface at this time.
console.assert(desc.fieldSize === 4, `field ${attr} size ${desc.fieldSize}`);
}

assert(desc.fieldSize === 4, `field ${attr} size ${desc.fieldSize}`);

Object.defineProperty(kls.prototype, desc.fieldName, {
configurable: true,
enumerable: true,
Expand Down Expand Up @@ -120,10 +120,9 @@ const defineAttrInt = (kls: Constructor, attr: string): void => {
console.error(`attr ${attr} not defined in class ${kls.toString()}`);

Check failure on line 120 in cocos/core/geometry/geometry-native-ext.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected console statement
}
const cacheKey = `_$_${attr}`;
if (!window.oh) {
// openharmony does not support the console.assert interface at this time.
console.assert(desc.fieldSize === 4, `field ${attr} size ${desc.fieldSize}`);
}

assert(desc.fieldSize === 4, `field ${attr} size ${desc.fieldSize}`);

Object.defineProperty(kls.prototype, desc.fieldName, {
configurable: true,
enumerable: true,
Expand Down
13 changes: 10 additions & 3 deletions cocos/core/math/vec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,11 +779,18 @@ export class Vec2 extends ValueType {
* @zh 获取当前向量和指定向量之间的有符号弧度。<br/>
* 有符号弧度的取值范围为 (-PI, PI],当前向量可以通过逆时针旋转有符号角度与指定向量同向。<br/>
* @param other specified vector
* @return The signed angle between the current vector and the specified vector (in radians); if there is a zero vector in the current vector and the specified vector, 0 is returned.
* @return The signed angle between the current vector and the specified vector (in radians);
* if there is a zero vector in the current vector and the specified vector, 0 is returned.
*/
public signAngle (other: Vec2): number {
const angle = this.angle(other);
return this.cross(other) < 0 ? -angle : angle;
// θ = atan(tan(θ))
// = atan(sin(θ) / cos(θ))
// = atan2(sin(θ), cos(θ))
// = atan2(|a|·|b|·sin(θ), |a|·|b|·cos(θ))
// = atan2(cross(a, b), dot(a, b))
const cross = this.cross(other);
const dot = this.dot(other);
return Math.atan2(cross, dot);
}

/**
Expand Down
24 changes: 13 additions & 11 deletions cocos/core/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { HTML5, TAOBAO, TAOBAO_MINIGAME } from 'internal:constants';
import { HTML5, NATIVE, TAOBAO, TAOBAO_MINIGAME } from 'internal:constants';
import { legacyCC } from './global-exports';

declare const fsUtils: any;
Expand Down Expand Up @@ -76,16 +76,18 @@ export class Settings {
}
if (!path) return Promise.resolve();

if (window.oh) {
return new Promise((resolve, reject): void => {
// TODO: to support a virtual module of settings.
// For now, we use a system module context to dynamically import the relative path of module.
const settingsModule = '../settings.js';
import(settingsModule).then((res): void => {
this._settings = res.default;
resolve();
}).catch((e): void => reject(e));
});
if (NATIVE) {
if (window.oh && window.scriptEngineType === 'napi') {
return new Promise((resolve, reject): void => {
// TODO: to support a virtual module of settings.
// For now, we use a system module context to dynamically import the relative path of module.
const settingsModule = '../settings.js';
import(settingsModule).then((res): void => {
this._settings = res.default;
resolve();
}).catch((e): void => reject(e));
});
}
}
return new Promise((resolve, reject): void => {
if (!HTML5 && !path.startsWith('http')) {
Expand Down
10 changes: 10 additions & 0 deletions cocos/gfx/base/framebuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,19 @@ export abstract class Framebuffer extends GFXObject {
return this._depthStencilTexture;
}

public get width (): number {
return this._width;
}

public get height (): number {
return this._height;
}

protected _renderPass: RenderPass | null = null;
protected _colorTextures: (Texture | null)[] = [];
protected _depthStencilTexture: Texture | null = null;
protected _width: number = 0;
protected _height: number = 0;

constructor () {
super(ObjectType.FRAMEBUFFER);
Expand Down
2 changes: 2 additions & 0 deletions cocos/gfx/webgl/webgl-framebuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export class WebGLFramebuffer extends Framebuffer {
};

WebGLCmdFuncCreateFramebuffer(WebGLDeviceManager.instance, this._gpuFramebuffer);
this._width = this._gpuFramebuffer.width;
this._height = this._gpuFramebuffer.height;
}

public destroy (): void {
Expand Down
2 changes: 2 additions & 0 deletions cocos/gfx/webgl2/webgl2-framebuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export class WebGL2Framebuffer extends Framebuffer {
};

WebGL2CmdFuncCreateFramebuffer(WebGL2DeviceManager.instance, this._gpuFramebuffer);
this._width = this._gpuFramebuffer.width;
this._height = this._gpuFramebuffer.height;
}

public destroy (): void {
Expand Down
Loading

0 comments on commit 571c354

Please sign in to comment.