From 80e5751e2f0c54fdea0e32ef0471d457075ef196 Mon Sep 17 00:00:00 2001 From: Sylvain Lefebvre Date: Sat, 20 Jan 2024 12:21:23 +0100 Subject: [PATCH] wip on compilation and install --- CMakeLists.txt | 41 +++++++++++++++--------- bin/silice-make.py | 31 ++++++++++++------ compile_silice_mingw64.sh | 1 - frameworks/boards/verilator/verilator.sh | 24 +++++++------- src/SiliceCompiler.cpp | 2 +- 5 files changed, 60 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d4c050a..ed1f7751 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,34 +126,45 @@ add_library(libsilice STATIC ${SILICE_CORE}) add_executable(silice src/silice.cpp) # set_target_properties(silice PROPERTIES OUTPUT_NAME "silice") target_link_libraries(silice libsilice antlr4_static lua luabind) + if(WIN32) -target_link_libraries(silice shlwapi) -endif(WIN32) + target_link_libraries(silice shlwapi) +endif() # install and paths -if (DEVBUILD) +if(WIN32) + IF(MINGW) + set(INSTALL_IN_REPO OFF CACHE BOOL "Install in repository") + else() + set(INSTALL_IN_REPO ON CACHE BOOL "Install in repository") + endif() +else() + set(INSTALL_IN_REPO OFF CACHE BOOL "Install in repository") +endif() + +if (INSTALL_IN_REPO) -install(TARGETS silice RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin) -install(TARGETS libsilice ARCHIVE DESTINATION ${CMAKE_SOURCE_DIR}/lib) + install(TARGETS silice RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/bin) + install(TARGETS libsilice ARCHIVE DESTINATION ${CMAKE_SOURCE_DIR}/lib) + add_definitions(-DFRAMEWORKS_DEFAULT_PATH=\"${CMAKE_SOURCE_DIR}/frameworks\") else() -install(TARGETS silice RUNTIME) -install(TARGETS libsilice ARCHIVE) -install(FILES bin/silice-make.py DESTINATION bin/) -install(FILES bin/report-cycles.py DESTINATION bin/) -install(DIRECTORY frameworks DESTINATION share/silice/frameworks) + install(TARGETS silice RUNTIME) + install(TARGETS libsilice ARCHIVE) + install(FILES bin/silice-make.py DESTINATION bin/) + install(FILES bin/report-cycles.py DESTINATION bin/) + install(DIRECTORY frameworks DESTINATION share/silice/) + install(DIRECTORY src/libs/LibSL-small DESTINATION share/silice/src/libs/) + add_definitions(-DFRAMEWORKS_DEFAULT_PATH=\"${CMAKE_INSTALL_PREFIX}/share/silice/frameworks\") endif() -add_definitions(-DFRAMEWORKS_DEFAULT_PATH=\"${CMAKE_INSTALL_PREFIX}/share/silice/frameworks\") - # compiler checks -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND - CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8) - message(FATAL_ERROR "Silice requires g++ 8 at least") +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8) + message(FATAL_ERROR "Silice requires g++ 8 at least") endif() if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") diff --git a/bin/silice-make.py b/bin/silice-make.py index cb09ab78..22d6832d 100755 --- a/bin/silice-make.py +++ b/bin/silice-make.py @@ -27,6 +27,7 @@ import argparse import platform import sysconfig +import subprocess # from termcolor import colored def colored(str,clr,attrs=0): @@ -43,8 +44,7 @@ def colored(str,clr,attrs=0): parser.add_argument('-r','--root', help="Root directory, use to override default frameworks.") parser.add_argument('-D','--defines', help="List of comma-separated defines to pass to Silice, e.g. -D A=0,B=1") parser.add_argument('--no_build', help="Only generate verilog output file.", action="store_true") -parser.add_argument('--no_program', help="Only generate verilog output file and build bitstream.", - action="store_true") +parser.add_argument('--no_program', help="Only generate verilog output file and build bitstream.", action="store_true") parser.add_argument('--reprogram', help="Only program device.", action="store_true") args = parser.parse_args() @@ -75,15 +75,28 @@ def colored(str,clr,attrs=0): os.environ["BUILD_DIR"] = out_dir # - frameworks directory -frameworks_dir = os.path.realpath(os.path.join(make_dir,"../frameworks/")) +frameworks_dirs=list() +frameworks_dirs.append(os.path.realpath(os.path.join(make_dir,"../frameworks/"))) +frameworks_dirs.append('/usr/local/share/silice/frameworks/') +if platform.system() == "Windows": + if sysconfig.get_platform().startswith("mingw"): + frameworks_dirs.append(subprocess.check_output('cygpath -m /usr/local/share/silice/frameworks/').decode('utf-8').strip()) if args.root: - frameworks_dir = os.path.realpath(os.path.abspath(args.root)) -print("* Silice frameworks directory: ",frameworks_dir,"\t\t\t",end='') -if (os.path.exists(frameworks_dir)): - print(colored("[ok]", 'green')) + frameworks_dirs.append(os.path.realpath(os.path.abspath(args.root))) +# search in expected paths +frameworks_dir = None +for fdir in frameworks_dirs: + if (os.path.exists(fdir)): + frameworks_dir = fdir + break +if frameworks_dir == None: + print("* Silice frameworks directory: \t\t\t",end='') + print(colored("[not found]", 'red')) + sys.exit(-1) else: - print(colored("[not found]", 'red')) - sys.exit(-1) + print("* Silice frameworks directory: ",frameworks_dir,"\t\t\t",end='') + print(colored("[ok]", 'green')) + frameworks_dir = fdir os.environ["FRAMEWORKS_DIR"] = frameworks_dir # enter build directory diff --git a/compile_silice_mingw64.sh b/compile_silice_mingw64.sh index 7d92ad9d..02a1dd8d 100755 --- a/compile_silice_mingw64.sh +++ b/compile_silice_mingw64.sh @@ -29,5 +29,4 @@ cd build-silice mingw32-make -j16 install cd .. - cd .. diff --git a/frameworks/boards/verilator/verilator.sh b/frameworks/boards/verilator/verilator.sh index 8428606d..53ad1b24 100755 --- a/frameworks/boards/verilator/verilator.sh +++ b/frameworks/boards/verilator/verilator.sh @@ -44,18 +44,14 @@ else export MAKE=mingw32-make fi -export PATH=$PATH:$SILICE_DIR/../tools/oss-cad-suite/:$SILICE_DIR +export PATH=$PATH:$SILICE_DIR + +if [[ -n "${YOSYSHQ_ROOT}" ]]; then + export VERILATOR_ROOT=${YOSYSHQ_ROOT}/share/verilator/ +fi if [[ -z "${VERILATOR_ROOT}" ]]; then -case "$(uname -s)" in -Linux) -unset VERILATOR_ROOT -;; -*) -export VERILATOR_ROOT=$SILICE_DIR/../tools/oss-cad-suite/share/verilator/ -;; -esac -echo "VERILATOR_ROOT is set to ${VERILATOR_ROOT}" +echo "[WARNING] **** VERILATOR_ROOT is NOT set ****" else echo "VERILATOR_ROOT already defined, using its value" fi @@ -83,15 +79,17 @@ if [[ ! -z "${NO_BUILD}" ]]; then exit fi -LIBSL_DIR=$SILICE_DIR/../src/libs/LibSL-small/src/LibSL/ -VERILATOR_LIB_DIR=$SILICE_DIR/../frameworks/verilator/ +LIBSL_DIR=$FRAMEWORKS_DIR../src/libs/LibSL-small/src/LibSL/ +VERILATOR_LIB_DIR=$FRAMEWORKS_DIR/verilator/ + +echo "LIBSL_DIR is set to ${LIBSL_DIR}" # NOTE: this below is necessary due to some wierd behaviour on some MinGW # installs where absolute paths generated by Verilator in its makefile # for include directories are incorrectly interepreted by g++. # Relative paths seem ok. cp $VERILATOR_LIB_DIR/verilator_callbacks.h . -cp -R $SILICE_DIR/../src/libs/LibSL-small/src/LibSL . +cp -R $LIBSL_DIR . VERILATOR_GFX_SRC=" $LIBSL_DIR/Image/ImageFormat_TGA.cpp $LIBSL_DIR/Image/Image.cpp $LIBSL_DIR/Image/tga.cpp $LIBSL_DIR/Math/Vertex.cpp $LIBSL_DIR/Math/Math.cpp $LIBSL_DIR/StlHelpers/StlHelpers.cpp $LIBSL_DIR/CppHelpers/CppHelpers.cpp $LIBSL_DIR/System/System.cpp" diff --git a/src/SiliceCompiler.cpp b/src/SiliceCompiler.cpp index 2921d629..03c5890f 100644 --- a/src/SiliceCompiler.cpp +++ b/src/SiliceCompiler.cpp @@ -339,7 +339,7 @@ void SiliceCompiler::beginParsing( } // determine frameworks dir if needed if (frameworks_dir.empty()) { - frameworks_dir = std::string(LibSL::System::Application::executablePath()) + "../frameworks/"; + frameworks_dir = std::string(FRAMEWORKS_DEFAULT_PATH); } // extract pre-processor header from framework std::string framework_lpp, framework_verilog;