From e02b03ac4c2cd466eeb5cf0e26dabd22d6044912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=88=98?= <40414978+PatriceJiang@users.noreply.github.com> Date: Fri, 1 Apr 2022 18:53:52 +0800 Subject: [PATCH] 3.6 add linux ci (#10636) * 3.6 add linux ci --- .github/workflows/native-compile-linux.yml | 48 +++++++++++++++++++ native/cocos/core/geometry/Capsule.cpp | 4 +- native/cocos/core/geometry/Obb.cpp | 20 ++++---- native/cocos/math/Utils.h | 4 +- native/cocos/math/Vec3.cpp | 2 +- .../cocos/platform/linux/modules/Screen.cpp | 7 ++- .../renderer/gfx-gles3/GLES3GPUObjects.h | 7 +-- .../utils/generate_compile_commands_linux.sh | 22 +++++++++ 8 files changed, 94 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/native-compile-linux.yml create mode 100644 native/utils/generate_compile_commands_linux.sh diff --git a/.github/workflows/native-compile-linux.yml b/.github/workflows/native-compile-linux.yml new file mode 100644 index 0000000000..4d0dbffd35 --- /dev/null +++ b/.github/workflows/native-compile-linux.yml @@ -0,0 +1,48 @@ +name: Linux + +on: [pull_request] + +jobs: + compile_linux: + name: "Linux-Ubuntu" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Download external libraries + shell: bash + run: | + EXT_VERSION=`grep version native/external-config.json |awk -F'"' '{print $4}'` + git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos-creator/engine-native-external native/external + - name: Generate bindings + run: | + python3 -m pip install PyYAML==5.4.1 Cheetah3 + python3 ./native/tools/tojs/genbindings.py + rm ./native/tools/tojs/userconf.ini + - name: Install dependencies + run: | + sudo apt install libx11-dev -y + sudo apt install libsndio-dev -y + sudo apt install ninja-build -y + - name: Compile + env: + COCOS_ENGINE_DEV: 1 + run: | + COCOS2DX_ROOT=$GITHUB_WORKSPACE/native + echo "Compiling Linux ... " + cd $COCOS2DX_ROOT/templates/linux + mkdir -p build-linux/proj + touch build-linux/proj/cfg.cmake + echo "set(CC_USE_VULKAN OFF)" >> build-linux/proj/cfg.cmake + echo "set(CC_USE_GLES2 OFF)" >> build-linux/proj/cfg.cmake + echo "set(CC_USE_GLES3 ON)" >> build-linux/proj/cfg.cmake + echo "set(CC_USE_METAL OFF)" >> build-linux/proj/cfg.cmake + echo "set(USE_WEBSOCKET_SERVER OFF)" >> build-linux/proj/cfg.cmake + echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-linux/proj/cfg.cmake + echo "set(USE_PHYSICS_PHYSX OFF)" >> build-linux/proj/cfg.cmake + mkdir build-linux/assets + + RES_DIR=$COCOS2DX_ROOT/templates/linux/build-linux + cd build-linux + cmake ../ -GNinja -DRES_DIR=$RES_DIR -DCOCOS_X_PATH=$COCOS2DX_ROOT + set +e + cmake --build . \ No newline at end of file diff --git a/native/cocos/core/geometry/Capsule.cpp b/native/cocos/core/geometry/Capsule.cpp index de447b2266..78100ea9ea 100644 --- a/native/cocos/core/geometry/Capsule.cpp +++ b/native/cocos/core/geometry/Capsule.cpp @@ -5,7 +5,7 @@ namespace geometry { void Capsule::transform(const Mat4 &m, const Vec3 & /*pos*/, const Quaternion &rot, const Vec3 &scale, Capsule *out) const { const auto maxComponent = mathutils::absMaxComponent(scale); - out->radius = this->radius * abs(maxComponent); + out->radius = this->radius * std::abs(maxComponent); const auto halfTotalWorldHeight = (this->halfHeight + this->radius) * std::abs(scale.y); auto halfWorldHeight = halfTotalWorldHeight - out->radius; @@ -44,4 +44,4 @@ void Capsule::updateLocalCenter() { } } } // namespace geometry -} // namespace cc \ No newline at end of file +} // namespace cc diff --git a/native/cocos/core/geometry/Obb.cpp b/native/cocos/core/geometry/Obb.cpp index ca5c275287..84ba332b2a 100644 --- a/native/cocos/core/geometry/Obb.cpp +++ b/native/cocos/core/geometry/Obb.cpp @@ -3,15 +3,15 @@ namespace { void transformExtentM3(cc::Vec3 *out, const cc::Vec3 &extent, const cc::Mat3 &m3) { cc::Mat3 m3Tmp; - m3Tmp.m[0] = abs(m3.m[0]); - m3Tmp.m[1] = abs(m3.m[1]); - m3Tmp.m[2] = abs(m3.m[2]); - m3Tmp.m[3] = abs(m3.m[3]); - m3Tmp.m[4] = abs(m3.m[4]); - m3Tmp.m[5] = abs(m3.m[5]); - m3Tmp.m[6] = abs(m3.m[6]); - m3Tmp.m[7] = abs(m3.m[7]); - m3Tmp.m[8] = abs(m3.m[8]); + m3Tmp.m[0] = std::abs(m3.m[0]); + m3Tmp.m[1] = std::abs(m3.m[1]); + m3Tmp.m[2] = std::abs(m3.m[2]); + m3Tmp.m[3] = std::abs(m3.m[3]); + m3Tmp.m[4] = std::abs(m3.m[4]); + m3Tmp.m[5] = std::abs(m3.m[5]); + m3Tmp.m[6] = std::abs(m3.m[6]); + m3Tmp.m[7] = std::abs(m3.m[7]); + m3Tmp.m[8] = std::abs(m3.m[8]); out->transformMat3(extent, m3Tmp); }; } // namespace @@ -101,4 +101,4 @@ void OBB::setScale(const Vec3 &scale, OBB *out) const { } } // namespace geometry -} // namespace cc \ No newline at end of file +} // namespace cc diff --git a/native/cocos/math/Utils.h b/native/cocos/math/Utils.h index 08dc6296bb..f0095b174d 100644 --- a/native/cocos/math/Utils.h +++ b/native/cocos/math/Utils.h @@ -218,7 +218,7 @@ auto repeat(T t, T length) { template auto pingPong(T t, T length) { t = repeat(t, length * 2); - t = length - abs(t - length); + t = length - std::abs(t - length); return t; } @@ -252,7 +252,7 @@ Vec3ElementType maxComponent(const Vec3 &v); */ template auto absMax(F a, F b) { - return abs(a) > abs(b) ? a : b; + return std::abs(a) > std::abs(b) ? a : b; } } // namespace mathutils diff --git a/native/cocos/math/Vec3.cpp b/native/cocos/math/Vec3.cpp index ab01364488..71dc7349c8 100644 --- a/native/cocos/math/Vec3.cpp +++ b/native/cocos/math/Vec3.cpp @@ -210,7 +210,7 @@ void Vec3::transformMat4Normal(const Vec3 &v, const Mat4 &m, Vec3 *dst) { float y = v.y; float z = v.z; float rhw = m.m[3] * x + m.m[7] * y + m.m[11] * z; - rhw = rhw != 0.0F ? abs(1.0F / rhw) : 1.0F; + rhw = rhw != 0.0F ? std::abs(1.0F / rhw) : 1.0F; dst->x = (m.m[0] * x + m.m[4] * y + m.m[8] * z) * rhw; dst->y = (m.m[1] * x + m.m[5] * y + m.m[9] * z) * rhw; dst->z = (m.m[2] * x + m.m[6] * y + m.m[10] * z) * rhw; diff --git a/native/cocos/platform/linux/modules/Screen.cpp b/native/cocos/platform/linux/modules/Screen.cpp index 258b0db58c..cafc6a32e9 100644 --- a/native/cocos/platform/linux/modules/Screen.cpp +++ b/native/cocos/platform/linux/modules/Screen.cpp @@ -24,9 +24,12 @@ ****************************************************************************/ #include "platform/linux/modules/Screen.h" -#include #include "base/Macros.h" #include "cocos/bindings/jswrapper/SeApi.h" +// clang-format off +// Some macros in xlib.h conflict with v8 headers. +#include +// clang-format on namespace cc { @@ -84,4 +87,4 @@ void Screen::setDisplayStats(bool isShow) { se::ScriptEngine::getInstance()->evalString(commandBuf); } -} // namespace cc \ No newline at end of file +} // namespace cc diff --git a/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h b/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h index 8cd8a5f615..9bebbfba91 100644 --- a/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h +++ b/native/cocos/renderer/gfx-gles3/GLES3GPUObjects.h @@ -21,6 +21,8 @@ #pragma once +#include + #include "base/Macros.h" #include "base/std/container/unordered_map.h" #include "gfx-base/GFXDef-common.h" @@ -29,7 +31,6 @@ #include "GLES3Std.h" #include "GLES3Wrangler.h" - namespace cc { namespace gfx { @@ -157,7 +158,7 @@ using GLES3GPUTextureViewList = ccstd::vector; struct GLES3GPUSwapchain { #if CC_SWAPPY_ENABLED - bool swappyEnabled{false}; + bool swappyEnabled{false}; #endif EGLSurface eglSurface{EGL_NO_SURFACE}; EGLint eglSwapInterval{0}; @@ -670,4 +671,4 @@ private: }; } // namespace gfx -} // namespace cc \ No newline at end of file +} // namespace cc diff --git a/native/utils/generate_compile_commands_linux.sh b/native/utils/generate_compile_commands_linux.sh new file mode 100644 index 0000000000..dfcb8575f7 --- /dev/null +++ b/native/utils/generate_compile_commands_linux.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +GENERATER="Ninja" +if [ -x "$(command -v ninja)" ]; then + MAKE_BIN=-DCMAKE_MAKE_PROGRAM="$(command -v ninja)" +else + echo "Ninja is not find, use 'make' instead." + GENERATER="Unix Makefiles" + MAKE_BIN="" +fi + +mkdir -p build +cp ./utils/CMakeLists.header.txt build/CMakeLists.txt +set -x +cmake -Sbuild -Bbuild -DCC_USE_GLES2=ON -DCC_USE_VULKAN=ON -DCC_USE_GLES3=ON \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -G "$GENERATER" $MAKE_BIN + +cp build/compile_commands.json .