1# Copyright (c) 2020 IBM
2# Use is subject to license terms.
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; version 2 of the License.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1335  USA
16
17
18# MRI scripts have a problem with +. It's a line contination character
19# unfortunately there is no escape character. We know we don't have
20# "+" in libraries or the MariaDB paths, but Ubuntu CI builds will have
21# in their CI path due to the package names that Ubuntu generates.
22# So here we replace the fully expanded paths in the TARGET_SCRIPT,
23# strip off the TOP_DIR to make it a relative path to the top level directory
24# and then execute AR on the top level directory.
25
26FILE(READ ${TARGET_SCRIPT} SCRIPT_CONTENTS)
27STRING(REPLACE "${TOP_DIR}/" "" SCRIPT_CONTENTS_TRIMMED "${SCRIPT_CONTENTS}")
28FILE(WRITE "${TARGET_SCRIPT}.mri" ${SCRIPT_CONTENTS_TRIMMED})
29
30EXECUTE_PROCESS(
31  WORKING_DIRECTORY ${TOP_DIR}
32  COMMAND ${CMAKE_AR} -M
33  INPUT_FILE ${TARGET_SCRIPT}.mri
34)
35