dawn_node: Begin working on the CMake rules
This is enough to compile the interop code. This doesn't do anything as we need to emit the NodeJS module entry point, and actually hook up the interop to the Dawn bindings.
This comes next.
Bug: dawn:1123
Change-Id: I754b4bcb0532c8446031622d8e8e64e2faaff585
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64903
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn_node/CMakeLists.txt b/src/dawn_node/CMakeLists.txt
new file mode 100644
index 0000000..639f033
--- /dev/null
+++ b/src/dawn_node/CMakeLists.txt
@@ -0,0 +1,58 @@
+# Copyright 2021 The Dawn Authors
+#
+# 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.
+
+set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen")
+set(IDLGEN_TOOL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmd/idlgen")
+
+# idlgen() is a function that uses the tools/cmd/idlgen/main.go tool to generate
+# code from an IDL file and template.
+# idlgen() accepts the following named arguments:
+# TEMPLATE <path> - (required) the path to the root .tmpl file. If the
+# template imports other templates, then these should be
+# added to the DEPENDS argument list.
+# OUTPUT <path> - (required) the output file path.
+# IDLS <paths> - (at least one required) the list of input WebIDL files.
+# DEPENDS <paths> - an optional list of additional file dependencies used.
+function(idlgen)
+ cmake_parse_arguments(IDLGEN
+ "" # options
+ "TEMPLATE;OUTPUT" # one_value_keywords
+ "IDLS;DEPENDS" # multi_value_keywords
+ ${ARGN})
+
+ if(NOT IDLGEN_TEMPLATE)
+ message(FATAL_ERROR "idlgen() missing TEMPLATE argument")
+ endif()
+ if(NOT IDLGEN_OUTPUT)
+ message(FATAL_ERROR "idlgen() missing OUTPUT argument")
+ endif()
+ if(NOT IDLGEN_IDLS)
+ message(FATAL_ERROR "idlgen() missing IDLS argument(s)")
+ endif()
+ add_custom_command(
+ COMMAND "go" "run" "main.go"
+ "--template" "${IDLGEN_TEMPLATE}"
+ "--output" "${IDLGEN_OUTPUT}"
+ ${IDLGEN_IDLS}
+ DEPENDS "${IDLGEN_TOOL_DIR}/main.go"
+ ${IDLGEN_TEMPLATE}
+ ${IDLGEN_DEPENDS}
+ ${IDLGEN_IDLS}
+ OUTPUT ${IDLGEN_OUTPUT}
+ WORKING_DIRECTORY ${IDLGEN_TOOL_DIR}
+ COMMENT "Generating ${IDLGEN_OUTPUT}"
+ )
+endfunction()
+
+add_subdirectory(interop)