-
Notifications
You must be signed in to change notification settings - Fork 786
Autogenerate boilerplate code for expressions from a single tool #3264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d389a79
14fb194
cce4360
fb0f2c4
61f616a
c918c5b
1763960
e8a2977
3d38c15
0e32bba
1401e6a
9664d82
292da6f
8d8ad96
3bc9756
367bb3a
834ccd5
ef59766
4bc793d
aefd373
058958c
2b3768b
c33f8b7
b0c30cc
b46965f
7ee2561
3e2535b
fd4ebb5
1a40bbe
652b184
e0b63af
b784418
0438666
a7a20f7
b23dde7
f824c4b
79ee0e1
fd2b93c
fd83d58
352ea44
cf98f2d
ae3d510
f7342fb
d766753
2c72f72
03fede8
fe1249b
3578e2b
d3b9d3f
c96d692
8c98c56
505fe7a
d92bf85
d7ad65d
bd0e527
75c8046
526e555
41592f4
24e9dde
d5ada9c
117a3a8
ba43591
f70c22a
1f6ed71
be2c2de
f533ac2
3cacc36
5e99b49
eb92572
362cab0
fe099f4
73bc61d
1272905
12e70a5
431de9d
cc83ed7
e9ee12b
8de6c45
4ac589d
4cb47e4
99360d5
8601f35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,6 +291,13 @@ IF(BUILD_LLVM_DWARF) | |
SET(binaryen_objs ${binaryen_objs} $<TARGET_OBJECTS:llvm_dwarf>) | ||
ENDIF() | ||
|
||
# Code generation. | ||
|
||
add_custom_target(gen_exprs ALL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems like you should just be able to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried that path earlier, but failed. The problem I ran into is that this tool emits I'm not an expert on how CMake works, but I spent a bunch of time on this and did quite a bit of searching for an example of how to do it (there are plenty of examples for generating a source file, but not a header), but came up empty.. 😞 |
||
COMMAND ${PROJECT_SOURCE_DIR}/scripts/gen-exprs | ||
BYPRODUCTS src/wasm-expressions.generated.h src/ir/compare-expressions.generated.h | ||
) | ||
|
||
# Sources. | ||
|
||
file(GLOB binaryen_HEADERS src/*.h) | ||
|
@@ -310,6 +317,7 @@ install(TARGETS binaryen | |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
add_dependencies(binaryen gen_exprs) | ||
|
||
install(FILES src/binaryen-c.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
|
@@ -321,6 +329,7 @@ function(binaryen_add_executable name sources) | |
set_property(TARGET ${name} PROPERTY CXX_STANDARD_REQUIRED ON) | ||
binaryen_setup_rpath(${name}) | ||
install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
add_dependencies(${name} gen_exprs) | ||
endfunction() | ||
|
||
binaryen_add_executable(wasm-opt src/tools/wasm-opt.cpp) | ||
|
@@ -363,6 +372,7 @@ if(EMSCRIPTEN) | |
set_property(TARGET binaryen_wasm PROPERTY CXX_STANDARD ${CXX_STANDARD}) | ||
set_property(TARGET binaryen_wasm PROPERTY CXX_STANDARD_REQUIRED ON) | ||
install(TARGETS binaryen_wasm DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
add_dependencies(binaryen_wasm gen_exprs) | ||
|
||
# binaryen.js JavaScript variant | ||
add_executable(binaryen_js | ||
|
@@ -388,4 +398,5 @@ if(EMSCRIPTEN) | |
set_property(TARGET binaryen_js PROPERTY CXX_STANDARD ${CXX_STANDARD}) | ||
set_property(TARGET binaryen_js PROPERTY CXX_STANDARD_REQUIRED ON) | ||
install(TARGETS binaryen_js DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
add_dependencies(binaryen_js gen_exprs) | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2020 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. | ||
# | ||
# Entry point for running gen-exprs.py, which requires python 3. | ||
# | ||
|
||
if [ -z "$PYTHON" ]; then | ||
PYTHON=$(which python3 2> /dev/null) | ||
fi | ||
|
||
if [ -z "$PYTHON" ]; then | ||
PYTHON=$(which python 2> /dev/null) | ||
fi | ||
|
||
if [ -z "$PYTHON" ]; then | ||
echo 'unable to find python in $PATH' | ||
exit 1 | ||
fi | ||
|
||
DIR=`dirname "$0"` | ||
|
||
exec "$PYTHON" "$DIR/gen-exprs.py" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@echo off | ||
:: Entry point for running gen-exprs.py on windows systems. | ||
|
||
if "%PYTHON%"=="" ( | ||
set PYTHON=python | ||
) | ||
|
||
"%PYTHON%" "%~dp0\%~n0.py" %* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If our CMake code is correct, it shouldn't be necessary to run these steps before CMake time, should it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I guess running the script is redundant here, I didn't realize that.
But thinking on it, I do still want to run it, just to avoid the risk of a future change in the other tests from affecting this. By running the script explicitly, we get a full self-contained test on one line here.