-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
121 lines (100 loc) · 4.29 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#
# Copyright © 2022 Github Lzhiyong
#
# Licensed 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.
#
cmake_minimum_required(VERSION 3.14.2)
project(sdk-tools)
enable_language(ASM)
# platform tools version
# see the patches/misc/platform_tools_version.h
set(TOOLS_VERSION_MAJOR 34)
set(TOOLS_VERSION 34.0.4)
set(_TOOLS_DEF "-D_TOOL_VERSION_MAJOR='\"${TOOLS_VERSION_MAJOR}\"' -D_TOOLS_VERSION='\"${TOOLS_VERSION}\"'")
# For src/art/libartbase/base/mem_map.cc
set(LIBARTBASE_DEF "-DART_BASE_ADDRESS=0x70000000")
# For src/art/libartbase/arch/instruction_set.h
set(LIBARTBASE_DEF "${LIBARTBASE_DEF} -DART_STACK_OVERFLOW_GAP_arm=8192")
set(LIBARTBASE_DEF "${LIBARTBASE_DEF} -DART_STACK_OVERFLOW_GAP_arm64=16384")
set(LIBARTBASE_DEF "${LIBARTBASE_DEF} -DART_STACK_OVERFLOW_GAP_riscv64=16384")
set(LIBARTBASE_DEF "${LIBARTBASE_DEF} -DART_STACK_OVERFLOW_GAP_x86=16384")
set(LIBARTBASE_DEF "${LIBARTBASE_DEF} -DART_STACK_OVERFLOW_GAP_x86_64=20480")
# For src/art/libartbase/arch/instruction_set.h
# see aosp/art/build/art.go
# default frame size limit: 1736
# device limit: 7400
# host limit: 6400
set(LIBARTBASE_DEF "${LIBARTBASE_DEF} -DART_FRAME_SIZE_LIMIT=6400")
# set global cflags and cxxflags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics -fPIC -Wno-attributes -std=gnu11 ${_TOOLS_DEF}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics -fPIC -Wno-attributes -std=gnu++2a ${_TOOLS_DEF}")
# static link
# set(CMAKE_EXE_LINKER_FLAGS "-static")
set(SRC ${PROJECT_SOURCE_DIR}/src)
# 64-bit off_t for lseek.
add_definitions(-D_FILE_OFFSET_BITS=64)
set(PROTOC_COMPILER)
if(DEFINED PROTOC_PATH)
set(PROTOC_COMPILER ${PROTOC_PATH})
if(NOT EXISTS ${PROTOC_COMPILER})
unset(PROTOC_PATH CACHE)
message(FATAL_ERROR "Invalid protoc: ${PROTOC_COMPILER}, please check if the path is correct")
endif()
# check protoc version
execute_process(
COMMAND ${PROTOC_COMPILER} --version
OUTPUT_VARIABLE PTOTOBUF_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
if(NOT PTOTOBUF_VERSION MATCHES "^libprotoc*")
unset(PROTOC_PATH CACHE)
message(FATAL_ERROR "Invalid protoc: ${PROTOC_COMPILER}, this may not be an executable")
endif()
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" VERSIONS ${PTOTOBUF_VERSION})
# please note that if the protobuf version is too high, you may encounter the following error
# error: This file was generated by a newer version of protoc
if(VERSIONS VERSION_GREATER "3.9.1")
message(WARNING "${PTOTOBUF_VERSION}, the protobuf version is too high, may be incompatible!!")
endif()
endif()
# thrid-party libraries
add_subdirectory(src/boringssl/src EXCLUDE_FROM_ALL)
add_subdirectory(src/fmtlib EXCLUDE_FROM_ALL)
add_subdirectory(src/pcre EXCLUDE_FROM_ALL)
add_subdirectory(src/libpng EXCLUDE_FROM_ALL)
add_subdirectory(src/expat/expat EXCLUDE_FROM_ALL)
add_subdirectory(src/zopfli EXCLUDE_FROM_ALL)
add_subdirectory(src/jsoncpp EXCLUDE_FROM_ALL)
add_subdirectory(src/zstd/build/cmake EXCLUDE_FROM_ALL)
add_subdirectory(src/lz4/build/cmake EXCLUDE_FROM_ALL)
add_subdirectory(src/brotli EXCLUDE_FROM_ALL)
add_subdirectory(src/abseil-cpp EXCLUDE_FROM_ALL)
add_subdirectory(src/protobuf/cmake EXCLUDE_FROM_ALL)
# building sdk-tools
add_subdirectory(lib)
add_subdirectory(build-tools)
add_subdirectory(platform-tools)
# creating source tarballs
set(CPACK_PACKAGE_DIRECTORY ${PROJECT_SOURCE_DIR}/pack)
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_SOURCE_GENERATOR "TXZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${TOOLS_VERSION}")
set(CPACK_SOURCE_IGNORE_FILES
${PROJECT_SOURCE_DIR}/.git
${PROJECT_SOURCE_DIR}/.gitignore
${PROJECT_SOURCE_DIR}/get_source.py
${PROJECT_SOURCE_DIR}/build
${PROJECT_SOURCE_DIR}/patches
${PROJECT_SOURCE_DIR}/pack
)
include(CPack)