forked from audacity/audacity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_build.cmake
177 lines (139 loc) · 5.42 KB
/
ci_build.cmake
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
message(STATUS "CI build")
# Options
set(BUILD_TYPE "debug" CACHE STRING "Build type")
# Possible values:
# - debug - debug build
set(BUILD_MODE "dev" CACHE STRING "Build mode")
# Possible values:
# - dev - dev build
set(BUILD_CONFIGURATION "app" CACHE STRING "Build configuration")
# Possible values:
# - app - app
set(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE STRING "Source dir")
set(INSTALL_DIR "../build.install" CACHE STRING "Build install dir")
set(INSTALL_SUFFIX "" CACHE STRING "Install suffix")
set(BUILD_NUMBER "12345678" CACHE STRING "Build number")
set(BUILD_REVISION "" CACHE STRING "Build revision")
option(SKIP_RPATH "Skip rpath" OFF)
# CPUS
cmake_host_system_information(RESULT CPUS QUERY NUMBER_OF_LOGICAL_CORES)
if(NOT "${CPUS}" GREATER "0")
include(ProcessorCount)
ProcessorCount(CPUS)
endif()
# AU4_RUN_LRELEASE=${AU4_RUN_LRELEASE:-"ON"}
# AU4_CRASHREPORT_URL=${AU4_CRASHREPORT_URL:-""}
# AU4_BUILD_CRASHPAD_CLIENT=${AU4_BUILD_CRASHPAD_CLIENT:-"ON"}
# AU4_DEBUGLEVEL_ENABLED="OFF"
# AU4_VST3_SDK_PATH=${AU4_VST3_SDK_PATH:-""}
# AU4_BUILD_UNIT_TESTS=${AU4_BUILD_UNIT_TESTS:-"OFF"}
# AU4_NO_RPATH=${AU4_NO_RPATH:-"OFF"}
# AU4_MODULE_UPDATE=${AU4_MODULE_UPDATEE:-"ON"}
# AU4_BUILD_VST_MODULE=${AU4_BUILD_VST_MODULE:-"OFF"}
string(TOUPPER ${BUILD_TYPE} BUILD_TYPE)
message(STATUS "CPUS=${CPUS}")
message(STATUS "BUILD_TYPE=${BUILD_TYPE}")
message(STATUS "BUILD_MODE=${BUILD_MODE}")
message(STATUS "BUILD_CONFIGURATION=${BUILD_CONFIGURATION}")
message(STATUS "INSTALL_DIR=${INSTALL_DIR}")
message(STATUS "INSTALL_SUFFIX=${INSTALL_SUFFIX}")
message(STATUS "BUILD_NUMBER=${BUILD_NUMBER}")
message(STATUS "BUILD_REVISION=${BUILD_REVISION}")
macro(do_build build_type build_dir)
set(CONFIGURE_ARGS -GNinja
-DAU4_BUILD_MODE=${BUILD_MODE}
-DAU4_BUILD_CONFIGURATION=${BUILD_CONFIGURATION}
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
-DMUSE_APP_INSTALL_SUFFIX=${INSTALL_SUFFIX}
-DCMAKE_BUILD_NUMBER=${BUILD_NUMBER}
-DAU4_REVISION=${BUILD_REVISION}
-DCMAKE_SKIP_RPATH=${SKIP_RPATH}
)
message(STATUS "========= Begin configure =========")
file(MAKE_DIRECTORY ${build_dir})
execute_process(
COMMAND cmake ${SOURCE_DIR} ${CONFIGURE_ARGS} -DCMAKE_BUILD_TYPE=${build_type}
WORKING_DIRECTORY ${build_dir}
RESULT_VARIABLE CMAKE_RESULT
)
if (CMAKE_RESULT GREATER 0)
message(FATAL_ERROR "========= Failed configure =========")
else()
message(STATUS "========= Success configure =========")
endif()
message(STATUS "========= Begin build =========")
execute_process(
COMMAND ninja -j ${CPUS}
WORKING_DIRECTORY ${build_dir}
RESULT_VARIABLE NINJA_RESULT
)
if (NINJA_RESULT GREATER 0)
message(FATAL_ERROR "========= Failed build =========")
else()
message(STATUS "========= Success build =========")
endif()
# cmake .. -GNinja \
# -DCMAKE_BUILD_TYPE="${build_type}" \
# -DMUE_RUN_LRELEASE="${AU4_RUN_LRELEASE}" \
# -DMUE_BUILD_VIDEOEXPORT_MODULE="${AU4_BUILD_VIDEOEXPORT_MODULE}" \
# -DMUSE_MODULE_UPDATE="${AU4_MODULE_UPDATE}" \
# -DMUSE_ENABLE_UNIT_TESTS="${AU4_BUILD_UNIT_TESTS}" \
# -DMUSE_MODULE_DIAGNOSTICS_CRASHPAD_CLIENT="${AU4_BUILD_CRASHPAD_CLIENT}" \
# -DMUSE_MODULE_DIAGNOSTICS_CRASHREPORT_URL="${AU4_CRASHREPORT_URL}" \
# -DMUSE_MODULE_GLOBAL_LOGGER_DEBUGLEVEL="${AU4_DEBUGLEVEL_ENABLED}" \
# -DMUSE_MODULE_VST="${AU4_BUILD_VST_MODULE}" \
# -DMUSE_MODULE_VST_VST3_SDK_PATH="${AU4_VST3_SDK_PATH}" \
# -DCMAKE_SKIP_RPATH="${AU4_NO_RPATH}" \
# ninja -j $JOBS
endmacro()
macro(do_install build_dir)
message(STATUS "========= Begin install =========")
execute_process(
COMMAND cmake --install ${build_dir}
RESULT_VARIABLE INSTALL_RESULT
)
if (INSTALL_RESULT GREATER 0)
message(FATAL_ERROR "========= Failed install =========")
else()
message(STATUS "========= Success install =========")
endif()
endmacro()
# Configure and build
if(BUILD_TYPE STREQUAL "DEBUG")
do_build(Debug build.debug)
elseif(BUILD_TYPE STREQUAL "RELEASE_INSTALL")
set(BUILD_DIR build.release)
do_build(RelWithDebInfo ${BUILD_DIR})
do_install(${BUILD_DIR})
elseif(BUILD_TYPE STREQUAL "APPIMAGE")
set(INSTALL_SUFFIX "4portable${INSTALL_SUFFIX}") # e.g. "4portable" or "4portablenightly"
set(SKIP_RPATH ON)
set(BUILD_DIR build.release)
do_build(Release ${BUILD_DIR})
do_install(${BUILD_DIR})
file (STRINGS "${BUILD_DIR}/PREFIX.txt" INSTALL_DIR)
execute_process (
COMMAND ln -sf . usr
WORKING_DIRECTORY ${INSTALL_DIR}
)
file(COPY
${BUILD_DIR}/install_manifest.txt
DESTINATION ${INSTALL_DIR}
)
file(COPY
${BUILD_DIR}/org.musescore.MuseScore${INSTALL_SUFFIX}.desktop
DESTINATION ${INSTALL_DIR}
)
file(COPY
${CMAKE_CURRENT_LIST_DIR}/buildscripts/packaging/Linux+BSD/audacity.svg
DESTINATION ${INSTALL_DIR}
)
# mscore="mscore${MUSE_APP_INSTALL_SUFFIX}"
# desktop="org.musescore.MuseScore${MUSE_APP_INSTALL_SUFFIX}.desktop"
# icon="${mscore}.png"
# mani="install_manifest.txt"
# cp "share/applications/${desktop}" "${desktop}"
# cp "share/icons/hicolor/128x128/apps/${icon}" "${icon}"
# <"$build_dir/${mani}" >"${mani}" sed -rn 's/.*(share\/)(applications|icons|man|metainfo|mime)(.*)/\1\2\3/p'
# ;;
endif()