Aufgabe 1 Beendet
This commit is contained in:
parent
d5f1f95be3
commit
a64471ed41
8
.idea/ninja.iml
generated
8
.idea/ninja.iml
generated
@ -1,8 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="CPP_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
||||
@ -1,7 +1,12 @@
|
||||
# cmake_minimum_required(VERSION <specify CMake version here>)
|
||||
project(ninja C)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(ninja LANGUAGES C)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(PROJECT_VERSION 0)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/config.h.in
|
||||
${CMAKE_BINARY_DIR}/config.h
|
||||
)
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
add_executable(ninja
|
||||
njvm.c)
|
||||
njvm.c config.h.in)
|
||||
|
||||
1
config.h.in
Normal file
1
config.h.in
Normal file
@ -0,0 +1 @@
|
||||
#define PROJECT_VERSION @PROJECT_VERSION@
|
||||
42
njvm.c
42
njvm.c
@ -1 +1,43 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
|
||||
void version() {
|
||||
printf("Ninja Virtual Machine version %i (compiled %s, %s)\n", PROJECT_VERSION, __DATE__, __TIME__);
|
||||
}
|
||||
|
||||
void help() {
|
||||
printf("usage: ./njvm [option] [option] ...\n\t--version\tshow version and exit\n\t--help\t\tshow this help and exit");
|
||||
}
|
||||
void printArgs(int argc, char *argv[]){
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
printf("%s\n", argv[i]);
|
||||
}
|
||||
}
|
||||
void useption(int argc, char *argv[]){
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "--version") == 0) {
|
||||
version();
|
||||
} else if (strcmp(argv[1], "--help") == 0) {
|
||||
help();
|
||||
} else if (argc != 0) {
|
||||
printf("unknown command line argument '%s', try './njvm --help'", argv[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
printArgs(argc,argv);
|
||||
if (argc > 1) useption(argc,argv);
|
||||
else {
|
||||
|
||||
// Started
|
||||
printf("Ninja Virtual Machine started\n");
|
||||
|
||||
|
||||
|
||||
// Stopped
|
||||
printf("Ninja Virtual Machine stopped\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user