morningman commented on a change in pull request #3760:
URL: https://github.com/apache/incubator-doris/pull/3760#discussion_r434952908



##########
File path: custom_udf/CMakeLists.txt
##########
@@ -0,0 +1,58 @@
+cmake_minimum_required(VERSION 2.8.10)
+ 
+# set CMAKE_C_COMPILER, this must set before project command
+if (DEFINED ENV{DORIS_GCC_HOME})
+    set(CMAKE_C_COMPILER "$ENV{DORIS_GCC_HOME}/bin/gcc")
+    set(CMAKE_CXX_COMPILER "$ENV{DORIS_GCC_HOME}/bin/g++")
+    set(GCC_HOME $ENV{DORIS_GCC_HOME})
+else()
+    message(FATAL_ERROR "DORIS_GCC_HOME environment variable is not set")
+endif()
+
+project(doris)
+
+# set CMAKE_BUILD_TYPE
+if (NOT CMAKE_BUILD_TYPE)
+    set(CMAKE_BUILD_TYPE RELEASE)
+endif()
+
+string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
+message(STATUS "Build type is ${CMAKE_BUILD_TYPE}")
+
+set(BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(ENV{DORIS_HOME} "${BASE_DIR}/../")
+set(THIRDPARTY_DIR "$ENV{DORIS_THIRDPARTY}/installed/")
+set(BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+set(SRC_DIR "${BASE_DIR}/src/")
+set(OUTPUT_DIR "${BASE_DIR}/output")
+
+# Check gcc
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.2")

Review comment:
       chang it to 7.3.0

##########
File path: custom_udf/CMakeLists.txt
##########
@@ -0,0 +1,58 @@
+cmake_minimum_required(VERSION 2.8.10)
+ 
+# set CMAKE_C_COMPILER, this must set before project command
+if (DEFINED ENV{DORIS_GCC_HOME})
+    set(CMAKE_C_COMPILER "$ENV{DORIS_GCC_HOME}/bin/gcc")
+    set(CMAKE_CXX_COMPILER "$ENV{DORIS_GCC_HOME}/bin/g++")
+    set(GCC_HOME $ENV{DORIS_GCC_HOME})
+else()
+    message(FATAL_ERROR "DORIS_GCC_HOME environment variable is not set")
+endif()
+
+project(doris)
+
+# set CMAKE_BUILD_TYPE
+if (NOT CMAKE_BUILD_TYPE)
+    set(CMAKE_BUILD_TYPE RELEASE)
+endif()
+
+string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
+message(STATUS "Build type is ${CMAKE_BUILD_TYPE}")
+
+set(BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(ENV{DORIS_HOME} "${BASE_DIR}/../")
+set(THIRDPARTY_DIR "$ENV{DORIS_THIRDPARTY}/installed/")
+set(BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+set(SRC_DIR "${BASE_DIR}/src/")
+set(OUTPUT_DIR "${BASE_DIR}/output")
+
+# Check gcc
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.2")
+        message(FATAL_ERROR "Need GCC version at least 4.8.2")
+    endif()
+
+    if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.3.0")
+        message(STATUS "GCC version is greater than 7.3.0, disable -Werror. Be 
careful with compile warnings.")
+    else()
+        #   -Werror: compile warnings should be errors when using the 
toolchain compiler.
+        set(CXX_GCC_FLAGS "${CXX_GCC_FLAGS} -Werror")
+    endif()
+elseif (NOT APPLE)
+    message(FATAL_ERROR "Compiler should be GNU")
+endif()
+
+# Just for clang-tidy:  -Wno-expansion-to-defined -Wno-deprecated-declaration
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -g -ggdb -std=c++11 -Wall 
-Werror -Wno-unused-variable -Wno-expansion-to-defined 
-Wno-deprecated-declarations -O3")
+message(STATUS "Compiler Flags: ${CMAKE_CXX_FLAGS}")
+
+# Include udf
+include_directories($ENV{DORIS_HOME}/output/udf/include)
+
+# Set all libraries
+add_library(udf STATIC IMPORTED)
+set_target_properties(udf PROPERTIES IMPORTED_LOCATION 
$ENV{DORIS_HOME}/output/udf/lib/libDorisUdf.a)
+

Review comment:
       Add comment to let user know that they can add their subdirectory here

##########
File path: docs/zh-CN/extending-doris/contribute_udf.md
##########
@@ -0,0 +1,117 @@
+---
+{
+    "title": "Contribute UDF",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Contribute UDF

Review comment:
       这里用中文

##########
File path: docs/zh-CN/extending-doris/contribute_udf.md
##########
@@ -0,0 +1,117 @@
+---
+{
+    "title": "Contribute UDF",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Contribute UDF
+
+该手册主要讲述了外部用户如何将自己编写的 UDF 函数贡献给 Doris 社区。
+
+# 前提条件
+
+1. UDF 函数具有通用性
+
+    这里的通用性主要指的是:UDF 函数在某些业务场景下,被广泛使用。也就是说 UDF 函数具有复用价值,可被社区内其他用户直接使用。
+
+    如果你不确定自己写的 UDF 函数是否具有通用性,可以发邮件到 `[email protected]` 或直接创建 ISSUE 发起讨论。
+
+2. UDF 已经完成测试,并正常运行在用户的生产环境中
+
+# 准备工作
+
+1. UDF 的 source code
+2. UDF 的使用手册
+
+## 源代码
+    
+    待贡献的源代码应该包含: `.h` , `.cpp`, `CMakeFile.txt`。存放路径应该在 
`custom_udf/src/my_udf` 下。这里以 udf_samples 为例,首先在 `custom_udf/src/` 
路径下创建一个新的文件夹,并存放源码。
+
+```
+    ├── custom_udf
+    │   ├── CMakeLists.txt
+    │   └── src
+    │       └── udf_samples
+    │           ├── CMakeLists.txt
+    │           ├── uda_sample.cpp
+    │           ├── uda_sample.h
+    │           ├── udf_sample.cpp
+    │           └── udf_sample.h
+
+```
+
+## 使用手册
+
+    使用手册需要包含:UDF 函数含义说明,适用的场景,函数的语法,如何编译 UDF ,如何在 Doris 集群中使用 UDF, 以及使用示例。
+
+1. 使用手册需包含中英文两个版本,并分别存放在 `docs/zh-CN/extending-doris/third-party-udf/` 和 
`docs/en/extending-doris/third-party-udf` 下。
+
+    ```
+    ├── docs
+    │   └── zh-CN
+    │       └──extending-doris
+    │          └──third-party-udf
+    │             ├── udf simple 使用手册
+ 
+    ``` 
+
+    ```
+    ├── docs
+    │   └── en
+    │       └──extending-doris
+    │          └──third-party-udf
+    │             ├── udf simple manual
+    ```
+
+2. 将两个使用手册的文件,加入中文和英文的 sidebar 中。
+
+    ```
+    vi docs/.vuepress/sidebar/zh-CN.js
+    {
+        title: "第三方 UDF",
+        directoryPath: "third-party-udf/",
+        children:
+        [
+            "udf simple 使用手册",

Review comment:
       这里应该是文档文件名,比如 udf-sample,而不是标题

##########
File path: custom_udf/build_custom_udf.sh
##########
@@ -0,0 +1,156 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+##############################################################
+# This script is used to compile Apache Doris(incubating)
+# Usage:
+#    sh build.sh        build both Backend and Frontend.
+#    sh build.sh -clean clean previous output and build.
+#
+# You need to make sure all thirdparty libraries have been
+# compiled and installed correctly.
+##############################################################
+
+set -eo pipefail
+
+ROOT=`dirname "$0"`
+ROOT=`cd "$ROOT"; pwd`
+
+export DORIS_HOME=$(dirname "$PWD")
+echo ${DORIS_HOME}
+export CUSTOM_UDF_HOME=${ROOT}
+
+. ${DORIS_HOME}/env.sh
+
+# build thirdparty libraries if necessary
+if [[ ! -f ${DORIS_THIRDPARTY}/installed/lib/libs2.a ]]; then
+    echo "Thirdparty libraries need to be build ..."
+    ${DORIS_THIRDPARTY}/build-thirdparty.sh
+fi
+
+PARALLEL=$[$(nproc)/4+1]
+
+# Check args
+usage() {
+  echo "
+Usage: $0 <options>
+  Optional options:
+     --udf              build custom UDF
+     --clean            clean and build target
+
+  Eg.
+    $0                                       build UDF without clean
+    $0 --udf                                 build UDF without clean
+    $0 --udf --clean                         clean and build UDF
+  "
+  exit 1
+}
+
+OPTS=$(getopt \
+  -n $0 \
+  -o '' \
+  -o 'h' \
+  -l 'udf' \

Review comment:
       parameter `udf` is meaningless




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to