summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaine Bublitz <blaine.bublitz@gmail.com>2022-01-04 09:51:41 -0700
committerGitHub <noreply@github.com>2022-01-04 08:51:41 -0800
commit1980e5570bce241945360abe8105101019f64bc6 (patch)
tree806f6d9e0efae183cad36c353fc899c673a96128
parent6137b338c7fb37ba98b63c31225ec9cfda8cfa59 (diff)
downloadbinaryen-1980e5570bce241945360abe8105101019f64bc6.tar.gz
binaryen-1980e5570bce241945360abe8105101019f64bc6.tar.bz2
binaryen-1980e5570bce241945360abe8105101019f64bc6.zip
Remove python from CMake build (#4324)
Use CMake's configure_file() instead.
-rw-r--r--.github/workflows/create_release.yml3
-rwxr-xr-xscripts/embedwat.py45
-rw-r--r--src/passes/CMakeLists.txt17
-rw-r--r--src/passes/WasmIntrinsics.cpp.in9
4 files changed, 20 insertions, 54 deletions
diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml
index a13ec6561..17259bbcd 100644
--- a/.github/workflows/create_release.yml
+++ b/.github/workflows/create_release.yml
@@ -21,9 +21,6 @@ jobs:
run:
shell: bash
steps:
- - uses: actions/setup-python@v1
- with:
- python-version: '3.x'
- uses: actions/checkout@v1
with:
submodules: true
diff --git a/scripts/embedwat.py b/scripts/embedwat.py
deleted file mode 100755
index 5b0809b26..000000000
--- a/scripts/embedwat.py
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright 2018 WebAssembly Community Group participants
-#
-# 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.
-
-import sys
-
-input_file = sys.argv[1]
-output_file = sys.argv[2]
-
-with open(input_file) as f:
- wat = f.read()
-
-output = """\
-// Automatically generated by embedwat.py
-
-#include "passes/intrinsics-module.h"
-
-static const char theModule[%d] = {
-""" % (len(wat) + 1)
-
-for c in wat:
- output += str(ord(c)) + ', '
-
-output += '''0
-};
-
-namespace wasm {
-const char* IntrinsicsModuleWast = theModule;
-}
-'''
-
-with open(output_file, 'w') as f:
- f.write(output)
diff --git a/src/passes/CMakeLists.txt b/src/passes/CMakeLists.txt
index bc09736a4..e24072424 100644
--- a/src/passes/CMakeLists.txt
+++ b/src/passes/CMakeLists.txt
@@ -1,10 +1,15 @@
-# Python 3.5 is the version shipped in Ubuntu Xenial
-find_package(PythonInterp 3.5 REQUIRED)
+file(READ wasm-intrinsics.wat WASM_INTRINSICS_WAT HEX)
-add_custom_command(
- OUTPUT WasmIntrinsics.cpp
- COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/embedwat.py ${PROJECT_SOURCE_DIR}/src/passes/wasm-intrinsics.wat ${CMAKE_CURRENT_BINARY_DIR}/WasmIntrinsics.cpp
- DEPENDS ${PROJECT_SOURCE_DIR}/scripts/embedwat.py wasm-intrinsics.wat)
+string(REGEX MATCHALL "([A-Fa-f0-9][A-Fa-f0-9])" SEPARATED_HEX ${WASM_INTRINSICS_WAT})
+
+set(WASM_INTRINSICS_SIZE 1)
+foreach (hex IN LISTS SEPARATED_HEX)
+ string(APPEND WASM_INTRINSICS_EMBED "0x${hex},")
+ math(EXPR WASM_INTRINSICS_SIZE "${WASM_INTRINSICS_SIZE}+1")
+endforeach ()
+string(APPEND WASM_INTRINSICS_EMBED "0x00")
+
+configure_file(WasmIntrinsics.cpp.in WasmIntrinsics.cpp @ONLY)
FILE(GLOB passes_HEADERS *.h)
set(passes_SOURCES
diff --git a/src/passes/WasmIntrinsics.cpp.in b/src/passes/WasmIntrinsics.cpp.in
new file mode 100644
index 000000000..46216842d
--- /dev/null
+++ b/src/passes/WasmIntrinsics.cpp.in
@@ -0,0 +1,9 @@
+#include "passes/intrinsics-module.h"
+
+static const char theModule[@WASM_INTRINSICS_SIZE@] = {
+@WASM_INTRINSICS_EMBED@
+};
+
+namespace wasm {
+const char* IntrinsicsModuleWast = theModule;
+}