[llvm] a7ba84a - cmake: Inline the add_llvm_symbol_exports.py script
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 10 13:19:24 PST 2022
Author: Tom Stellard
Date: 2022-11-10T13:18:47-08:00
New Revision: a7ba84a39dbe6a39c28e92773c6bcdb78676cacb
URL: https://github.com/llvm/llvm-project/commit/a7ba84a39dbe6a39c28e92773c6bcdb78676cacb
DIFF: https://github.com/llvm/llvm-project/commit/a7ba84a39dbe6a39c28e92773c6bcdb78676cacb.diff
LOG: cmake: Inline the add_llvm_symbol_exports.py script
This fixes stand-alone builds.
Reviewed By: andrewng
Differential Revision: https://reviews.llvm.org/D137611
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
Removed:
llvm/utils/add_llvm_symbol_exports.py
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 428a22422e288..376478e98b975 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -103,7 +103,13 @@ function(add_llvm_symbol_exports target_name export_file)
# FIXME: Don't write the "local:" line on OpenBSD.
# in the export file, also add a linker script to version LLVM symbols (form: LLVM_N.M)
add_custom_command(OUTPUT ${native_export_file}
- COMMAND "${Python3_EXECUTABLE}" ${LLVM_MAIN_SRC_DIR}/utils/add_llvm_symbol_exports.py ${LLVM_VERSION_MAJOR} ${export_file} ${native_export_file}
+ COMMAND "${Python3_EXECUTABLE}" "-c"
+ "import sys; \
+ lines = [' ' + l.rstrip() for l in sys.stdin] + [' local: *;']; \
+ print('LLVM_${LLVM_VERSION_MAJOR} {'); \
+ print(' global:') if len(lines) > 1 else None; \
+ print(';\\n'.join(lines) + '\\n};')"
+ < ${export_file} > ${native_export_file}
DEPENDS ${export_file}
VERBATIM
COMMENT "Creating export file for ${target_name}")
diff --git a/llvm/utils/add_llvm_symbol_exports.py b/llvm/utils/add_llvm_symbol_exports.py
deleted file mode 100644
index ed444cc45848d..0000000000000
--- a/llvm/utils/add_llvm_symbol_exports.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python3
-#===----------------------------------------------------------------------===##
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#===----------------------------------------------------------------------===##
-
-import os
-import sys
-
-if (len(sys.argv) != 4):
- print('usage: ' + sys.argv[0] + ' <LLVM major version> <input> <output>')
- sys.exit(1)
-
-with open(sys.argv[3], 'w') as out_fd:
- out_fd.write('LLVM_' + sys.argv[1] + ' {\n')
- if os.stat(sys.argv[2]).st_size > 0:
- out_fd.write(' global:\n')
- with open(sys.argv[2], 'r') as in_fd:
- for e in in_fd.readlines():
- out_fd.write(' ' + e.rstrip() + ';\n')
- out_fd.write(' local: *;\n};\n')
-
-sys.exit(0)
More information about the llvm-commits
mailing list