mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-06-10 07:09:20 +00:00
add a sample to use cmake package (#4291)
- add a sample to use cmake package
This commit is contained in:
parent
b7474b354f
commit
6659a312cf
.github/workflows
samples/printversion
|
@ -437,6 +437,11 @@ jobs:
|
||||||
ctest --test-dir build --output-on-failure
|
ctest --test-dir build --output-on-failure
|
||||||
working-directory: samples/wasm-c-api
|
working-directory: samples/wasm-c-api
|
||||||
|
|
||||||
|
- name: Build Sample [printversion]
|
||||||
|
run: |
|
||||||
|
./test.sh
|
||||||
|
working-directory: samples/printversion
|
||||||
|
|
||||||
build_samples_others:
|
build_samples_others:
|
||||||
needs:
|
needs:
|
||||||
[
|
[
|
||||||
|
|
5
.github/workflows/compilation_on_macos.yml
vendored
5
.github/workflows/compilation_on_macos.yml
vendored
|
@ -282,6 +282,11 @@ jobs:
|
||||||
ctest --test-dir build --output-on-failure
|
ctest --test-dir build --output-on-failure
|
||||||
working-directory: samples/wasm-c-api
|
working-directory: samples/wasm-c-api
|
||||||
|
|
||||||
|
- name: Build Sample [printversion]
|
||||||
|
run: |
|
||||||
|
./test.sh
|
||||||
|
working-directory: samples/printversion
|
||||||
|
|
||||||
build_samples_others:
|
build_samples_others:
|
||||||
needs: [build_iwasm, build_wamrc, build_llvm_libraries_on_intel_macos, build_llvm_libraries_on_arm_macos]
|
needs: [build_iwasm, build_wamrc, build_llvm_libraries_on_intel_macos, build_llvm_libraries_on_arm_macos]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
10
samples/printversion/CMakeLists.txt
Normal file
10
samples/printversion/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Copyright (C) 2025 Midokura Japan KK. All rights reserved.
|
||||||
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
project(printversion LANGUAGES C)
|
||||||
|
|
||||||
|
add_executable(printversion printversion.c)
|
||||||
|
find_package(iwasm REQUIRED)
|
||||||
|
target_link_libraries(printversion iwasm::vmlib)
|
21
samples/printversion/printversion.c
Normal file
21
samples/printversion/printversion.c
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Midokura Japan KK. All rights reserved.
|
||||||
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <wasm_export.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
uint32_t major;
|
||||||
|
uint32_t minor;
|
||||||
|
uint32_t patch;
|
||||||
|
wasm_runtime_get_version(&major, &minor, &patch);
|
||||||
|
printf("wasm-micro-runtime %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", major,
|
||||||
|
minor, patch);
|
||||||
|
}
|
24
samples/printversion/test.sh
Executable file
24
samples/printversion/test.sh
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
# Copyright (C) 2025 Midokura Japan KK. All rights reserved.
|
||||||
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIST=$(mktemp -d)
|
||||||
|
|
||||||
|
# WAMR_BUILD_SIMD=0 to avoid fetching simde, which is
|
||||||
|
# not relevant to this particular test.
|
||||||
|
cmake -B build-wamr \
|
||||||
|
-D CMAKE_INSTALL_PREFIX=${DIST} \
|
||||||
|
-D WAMR_BUILD_SIMD=0 \
|
||||||
|
../..
|
||||||
|
cmake --build build-wamr -t install
|
||||||
|
|
||||||
|
cmake -B build-app \
|
||||||
|
-D CMAKE_PREFIX_PATH=${DIST} \
|
||||||
|
-D CMAKE_INSTALL_PREFIX=${DIST} \
|
||||||
|
.
|
||||||
|
cmake --build build-app
|
||||||
|
|
||||||
|
./build-app/printversion
|
Loading…
Reference in New Issue
Block a user