From: yu.dongliang <18588496441@163.com> Date: Wed, 19 Apr 2023 02:44:47 +0000 (+0800) Subject: add usage info X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=6cf2704d13cd586f2a6fa35a55a945c92dc5d464;p=scf.git add usage info --- diff --git a/parse/main.c b/parse/main.c index 2ee3400..93e2c1a 100644 --- a/parse/main.c +++ b/parse/main.c @@ -31,11 +31,18 @@ void usage(char* path) { fprintf(stderr, "Usage: %s [-c] [-a arch] [-o out] src0 [src1]\n\n", path); fprintf(stderr, "-c: only compile, not link\n"); - fprintf(stderr, "-a: select cpu arch (x64 or arm64), default is x64\n"); + fprintf(stderr, "-a: select cpu arch (x64 or arm64 or naja), default is x64\n\n"); + fprintf(stderr, "naja is a bytecode designed by me, so that a script language can be developed based on scf framework.\n"); + fprintf(stderr, "naja is compiled & linked to ELF, and run by nvm in 'scf/vm' dir.\n"); } int main(int argc, char* argv[]) { + if (argc < 2) { + usage(argv[0]); + return -EINVAL; + } + scf_vector_t* afiles = scf_vector_alloc(); scf_vector_t* sofiles = scf_vector_alloc(); scf_vector_t* srcs = scf_vector_alloc(); diff --git a/vm/scf_vm_test.c b/vm/scf_vm_test.c index 54eea6f..2136fa4 100644 --- a/vm/scf_vm_test.c +++ b/vm/scf_vm_test.c @@ -1,7 +1,13 @@ #include"scf_vm.h" -int main() +int main(int argc, char* argv[]) { + if (argc < 2) { + printf("usage: ./nvm file\n\n"); + printf("file: an ELF file with naja bytecode\n"); + return -1; + } + scf_vm_t* vm = NULL; int ret = scf_vm_open(&vm, "naja"); @@ -10,7 +16,7 @@ int main() return -1; } - ret = scf_vm_run(vm, "../parse/1.out", "x64"); + ret = scf_vm_run(vm, argv[1], "x64"); if (ret < 0) { scf_loge("\n"); return -1;