Enable the semantic version mechanism for WAMR (#1374)

Use the semantic versioning (https://semver.org) to replace the current date
versioning system, which is more general and is requested by some developers,
e.g. issue #1357.

There are three parts in the new version string:
- major. Any incompatible modification on ABIs and APIs will lead to an increment
  in the value of major, which mainly includes: AOT calling conventions, AOT file
  format, wasm_export.h, wasm_c_api.h, and so on.
- minor. It represents new features, including MVP/POST-MVP features, libraries,
  WAMR private ones, and so one.
- patch. It represents patches.

The new version will start from 1.0.0. Update the help info and version showing for
iwasm and wamrc.
This commit is contained in:
liang.he
2022-08-18 19:01:05 +08:00
committed by GitHub
parent 88bb4f3c81
commit 717e8a48e2
11 changed files with 144 additions and 0 deletions

View File

@ -232,6 +232,7 @@ print_help()
printf(" for example:\n");
printf(" --addr-pool=1.2.3.4/15,2.3.4.5/16\n");
printf(" --max-threads=n Set maximum thread number per cluster, default is 4\n");
printf(" --version Show version information\n");
return 1;
}
/* clang-format on */
@ -292,6 +293,7 @@ typedef enum EcallCmd {
CMD_DESTROY_RUNTIME, /* wasm_runtime_destroy() */
CMD_SET_WASI_ARGS, /* wasm_runtime_set_wasi_args() */
CMD_SET_LOG_LEVEL, /* bh_log_set_verbose_level() */
CMD_GET_VERSION, /* wasm_runtime_get_version() */
} EcallCmd;
static void
@ -580,6 +582,23 @@ set_wasi_args(void *wasm_module, const char **dir_list, uint32_t dir_list_size,
return (bool)ecall_args[0];
}
static void
get_version(uint64_t *major, uint64_t *minor, uint64_t *patch)
{
uint64_t ecall_args[3] = { 0 };
if (SGX_SUCCESS
!= ecall_handle_command(g_eid, CMD_GET_VERSION, (uint8_t *)ecall_args,
sizeof(ecall_args))) {
printf("Call ecall_handle_command() failed.\n");
return;
}
*major = ecall_args[0];
*minor = ecall_args[1];
*patch = ecall_args[2];
}
int
main(int argc, char *argv[])
{
@ -700,6 +719,12 @@ main(int argc, char *argv[])
return print_help();
max_thread_num = atoi(argv[0] + 14);
}
else if (!strncmp(argv[0], "--version", 9)) {
uint64_t major = 0, minor = 0, patch = 0;
get_version(&major, &minor, &patch);
printf("iwasm %lu.%lu.%lu\n", major, minor, patch);
return 0;
}
else
return print_help();
}

View File

@ -44,6 +44,7 @@ typedef enum EcallCmd {
CMD_DESTROY_RUNTIME, /* wasm_runtime_destroy() */
CMD_SET_WASI_ARGS, /* wasm_runtime_set_wasi_args() */
CMD_SET_LOG_LEVEL, /* bh_log_set_verbose_level() */
CMD_GET_VERSION, /* wasm_runtime_get_version() */
} EcallCmd;
typedef struct EnclaveModule {
@ -522,6 +523,18 @@ handle_cmd_set_wasi_args(uint64 *args, int32 argc)
}
#endif /* end of SGX_DISABLE_WASI */
static void
handle_cmd_get_version(uint64 *args, uint32 argc)
{
uint32 major, minor, patch;
bh_assert(argc == 3);
wasm_runtime_get_version(&major, &minor, &patch);
args[0] = major;
args[1] = minor;
args[2] = patch;
}
void
ecall_handle_command(unsigned cmd, unsigned char *cmd_buf,
unsigned cmd_buf_size)
@ -569,6 +582,9 @@ ecall_handle_command(unsigned cmd, unsigned char *cmd_buf,
case CMD_SET_LOG_LEVEL:
handle_cmd_set_log_level(args, argc);
break;
case CMD_GET_VERSION:
handle_cmd_get_version(args, argc);
break;
default:
LOG_ERROR("Unknown command %d\n", cmd);
break;

View File

@ -68,6 +68,7 @@ print_help()
printf(" -g=ip:port Set the debug sever address, default is debug disabled\n");
printf(" if port is 0, then a random port will be used\n");
#endif
printf(" --version Show version information\n");
return 1;
}
/* clang-format on */
@ -461,6 +462,12 @@ main(int argc, char *argv[])
ip_addr = argv[0] + 3;
}
#endif
else if (!strncmp(argv[0], "--version", 9)) {
uint32 major, minor, patch;
wasm_runtime_get_version(&major, &minor, &patch);
printf("iwasm %u.%u.%u\n", major, minor, patch);
return 0;
}
else
return print_help();
}

View File

@ -50,6 +50,7 @@ print_help()
printf(" -g=ip:port Set the debug sever address, default is debug disabled\n");
printf(" if port is 0, then a random port will be used\n");
#endif
printf(" --version Show version information\n");
return 1;
}
/* clang-format on */
@ -339,6 +340,12 @@ main(int argc, char *argv[])
ip_addr = argv[0] + 3;
}
#endif
else if (!strncmp(argv[0], "--version", 9)) {
uint32 major, minor, patch;
wasm_runtime_get_version(&major, &minor, &patch);
printf("iwasm %u.%u.%u\n", major, minor, patch);
return 0;
}
else
return print_help();
}