software/demo: Make hellocpp optional (only build with --with-cxx) to avoid adding g++ as a dependency for an optional feature.
This commit is contained in:
parent
31ac6659c9
commit
7e3912aaef
|
@ -3,7 +3,10 @@ BUILD_DIR?=../build/
|
||||||
include $(BUILD_DIR)/software/include/generated/variables.mak
|
include $(BUILD_DIR)/software/include/generated/variables.mak
|
||||||
include $(SOC_DIRECTORY)/software/common.mak
|
include $(SOC_DIRECTORY)/software/common.mak
|
||||||
|
|
||||||
OBJECTS=isr.o donut.o helloc.o hellocpp.o main.o
|
OBJECTS = isr.o donut.o helloc.o main.o
|
||||||
|
ifdef WITH_CXX
|
||||||
|
OBJECTS += hellocpp.o
|
||||||
|
endif
|
||||||
|
|
||||||
all: demo.bin
|
all: demo.bin
|
||||||
|
|
||||||
|
@ -33,6 +36,7 @@ donut.o: CFLAGS += -w
|
||||||
helloc.o: CFLAGS += -w
|
helloc.o: CFLAGS += -w
|
||||||
|
|
||||||
hellocpp.o: CXXFLAGS += -w
|
hellocpp.o: CXXFLAGS += -w
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(compilexx)
|
$(compilexx)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ from distutils.dir_util import copy_tree
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="LiteX Bare Metal Demo App.")
|
parser = argparse.ArgumentParser(description="LiteX Bare Metal Demo App.")
|
||||||
parser.add_argument("--build-path", help="Target's build path (ex build/board_name)", required=True)
|
parser.add_argument("--build-path", help="Target's build path (ex build/board_name).", required=True)
|
||||||
|
parser.add_argument("--with-cxx", action="store_true", help="Enable CXX support.")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Create demo directory
|
# Create demo directory
|
||||||
|
@ -24,7 +25,7 @@ def main():
|
||||||
|
|
||||||
# Compile demo
|
# Compile demo
|
||||||
build_path = args.build_path if os.path.isabs(args.build_path) else os.path.join("..", args.build_path)
|
build_path = args.build_path if os.path.isabs(args.build_path) else os.path.join("..", args.build_path)
|
||||||
os.system(f"export BUILD_DIR={build_path} && cd demo && make")
|
os.system(f"export BUILD_DIR={build_path} && {'export WITH_CXX=1 &&' if args.with_cxx else ''} cd demo && make")
|
||||||
|
|
||||||
# Copy demo.bin
|
# Copy demo.bin
|
||||||
os.system("cp demo/demo.bin ./")
|
os.system("cp demo/demo.bin ./")
|
||||||
|
|
|
@ -88,7 +88,9 @@ static void help(void)
|
||||||
#endif
|
#endif
|
||||||
puts("donut - Spinning Donut demo");
|
puts("donut - Spinning Donut demo");
|
||||||
puts("helloc - Hello C");
|
puts("helloc - Hello C");
|
||||||
|
#ifdef WITH_CXX
|
||||||
puts("hellocpp - Hello C++");
|
puts("hellocpp - Hello C++");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
@ -148,6 +150,7 @@ static void helloc_cmd(void)
|
||||||
helloc();
|
helloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WITH_CXX
|
||||||
extern void hellocpp(void);
|
extern void hellocpp(void);
|
||||||
|
|
||||||
static void hellocpp_cmd(void)
|
static void hellocpp_cmd(void)
|
||||||
|
@ -155,6 +158,8 @@ static void hellocpp_cmd(void)
|
||||||
printf("Hello C++ demo...\n");
|
printf("Hello C++ demo...\n");
|
||||||
hellocpp();
|
hellocpp();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
/* Console service / Main */
|
/* Console service / Main */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
@ -179,8 +184,10 @@ static void console_service(void)
|
||||||
donut_cmd();
|
donut_cmd();
|
||||||
else if(strcmp(token, "helloc") == 0)
|
else if(strcmp(token, "helloc") == 0)
|
||||||
helloc_cmd();
|
helloc_cmd();
|
||||||
|
#ifdef WITH_CXX
|
||||||
else if(strcmp(token, "hellocpp") == 0)
|
else if(strcmp(token, "hellocpp") == 0)
|
||||||
hellocpp_cmd();
|
hellocpp_cmd();
|
||||||
|
#endif
|
||||||
prompt();
|
prompt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue