Skip to content

Commit

Permalink
wip on compilation and install
Browse files Browse the repository at this point in the history
  • Loading branch information
sylefeb committed Jan 20, 2024
1 parent 4e87f25 commit 80e5751
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 39 deletions.
41 changes: 26 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
31 changes: 22 additions & 9 deletions bin/silice-make.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import argparse
import platform
import sysconfig
import subprocess
# from termcolor import colored

def colored(str,clr,attrs=0):
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion compile_silice_mingw64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ cd build-silice
mingw32-make -j16 install

cd ..

cd ..
24 changes: 11 additions & 13 deletions frameworks/boards/verilator/verilator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/SiliceCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 80e5751

Please sign in to comment.