diff options
author | Sam Clegg <sbc@chromium.org> | 2019-12-08 20:50:25 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-08 20:50:25 -0600 |
commit | 42b61e3c2e7851ed001bf26a7e1afab21d0cb38d (patch) | |
tree | b86a0a10ec9ea1d4351e4500ff84f987894aaf8e /scripts/embedwat.py | |
parent | b232033385b025ba276423613fb67f644c0596ce (diff) | |
download | binaryen-42b61e3c2e7851ed001bf26a7e1afab21d0cb38d.tar.gz binaryen-42b61e3c2e7851ed001bf26a7e1afab21d0cb38d.tar.bz2 binaryen-42b61e3c2e7851ed001bf26a7e1afab21d0cb38d.zip |
Use wat over wast for text format filenames (#2518)
Diffstat (limited to 'scripts/embedwat.py')
-rwxr-xr-x | scripts/embedwat.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/embedwat.py b/scripts/embedwat.py new file mode 100755 index 000000000..dfb12b772 --- /dev/null +++ b/scripts/embedwat.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# +# 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) |