You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2023/03/17 15:07:10 UTC

[nuttx-apps] 01/02: toywasm: add a script to regenerate config-dependent files

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit b962c02c053819a0901555d80aeabc5e996b0885
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Mar 9 02:56:43 2023 +0900

    toywasm: add a script to regenerate config-dependent files
    
    This is a manual step mainly because it involves extra
    tools including cmake.
---
 interpreters/toywasm/regen.sh           | 43 +++++++++++++++++++++++++++++++++
 interpreters/toywasm/tmpl/c-sections.in |  8 ++++++
 interpreters/toywasm/tmpl/license.in    | 20 +++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/interpreters/toywasm/regen.sh b/interpreters/toywasm/regen.sh
new file mode 100755
index 000000000..361a3bdcb
--- /dev/null
+++ b/interpreters/toywasm/regen.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+
+# A script to generate a few files for nuttx-apps build.
+
+REPO=https://github.com/yamt/toywasm
+REF=${REF:-master}
+
+TMP=$(mktemp -d)
+trap "rm -rf ${TMP}" 0
+DIR="${TMP}/src"
+BUILDDIR="${TMP}/build"
+
+mkdir -p ${DIR}
+git -C ${DIR} init
+git -C ${DIR} fetch --tags ${REPO} ${REF}
+git -C ${DIR} checkout FETCH_HEAD
+
+# Note: for this build, TOYWASM_USE_SHORT_ENUMS is only used for
+# the "toywasm --version" output.
+
+cmake -B ${BUILDDIR} \
+-DTOYWASM_USE_SHORT_ENUMS=OFF \
+-DTOYWASM_ENABLE_WASM_EXTENDED_CONST=ON \
+-DTOYWASM_ENABLE_WASM_MULTI_MEMORY=ON \
+-DTOYWASM_ENABLE_WASM_TAILCALL=ON \
+-DTOYWASM_ENABLE_WASM_THREADS=ON \
+-DTOYWASM_ENABLE_WASI_THREADS=ON \
+${DIR}
+
+for fn in \
+    include/toywasm_config.h \
+    include/toywasm_version.h \
+    src/toywasm_config.c; do
+
+    (m4 -DFILENAME=$fn tmpl/license.in
+    case ${fn} in
+    *.c)
+        cat tmpl/c-sections.in
+        ;;
+    esac
+    # remove comments to appease nxstyle
+    sed -e '/^\/\*/d' ${BUILDDIR}/$(basename $fn)) > ${fn}
+done
diff --git a/interpreters/toywasm/tmpl/c-sections.in b/interpreters/toywasm/tmpl/c-sections.in
new file mode 100644
index 000000000..46a331512
--- /dev/null
+++ b/interpreters/toywasm/tmpl/c-sections.in
@@ -0,0 +1,8 @@
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
diff --git a/interpreters/toywasm/tmpl/license.in b/interpreters/toywasm/tmpl/license.in
new file mode 100644
index 000000000..90da07e10
--- /dev/null
+++ b/interpreters/toywasm/tmpl/license.in
@@ -0,0 +1,20 @@
+/****************************************************************************
+ * apps/interpreters/toywasm/FILENAME
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you 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.
+ *
+ ****************************************************************************/
+