Continuing on my chaotic journey to build the next master piece 3D game everyone will want to play, I'm finally back our good old C++ 🤣 But this time I'm going to do this correctly! [Are you Manu ? Really ? 🙃] ⇒ I need a proper C++ development environment, not just Visual Studio Code without any kind of intellisense/linter/formatter etc. I need something to boost my productivity…
$ git clone ssh://git@gitlab.nervtech.org:22002/nerv/nervland.git NervLand
nvl_cli() { "`nvl_get_project_dir`/scripts/cli.sh" "$@" }
$ git config --global core.editor nano
@echo off SETLOCAL ENABLEDELAYEDEXPANSION @REM Retrieve the current folder: cd /D %~dp0.. FOR /F %%i IN (".") DO set NVL_ROOT_DIR=%%~fi set NVL_DIR=%NVL_ROOT_DIR% echo Using NervLand root folder: %NVL_DIR% @REM Extract the python env if needed: set TOOLS_DIR=%NVL_DIR%\tools\windows\ set UNZIP=%TOOLS_DIR%\7zip\7za.exe set PYTHON=%TOOLS_DIR%\python\python.exe @REM Check if python is extracted already: if not exist "%PYTHON%" ( echo Extracting python tool... %UNZIP% x -o"%TOOLS_DIR%" "%TOOLS_DIR%\python-win.7z" > nul @REM Upgrade pip: %PYTHON% -m pip install --upgrade pip )
#!/usr/bin/env bash # cf. https://stackoverflow.com/questions/59895/how-can-i-get-the-source-directory-of-a-bash-script-from-within-the-script-itsel SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) # On windows we should simply rely on the cli.bat script below: SCRIPT_DIR="`cygpath -w $SCRIPT_DIR`" cmd /C "$SCRIPT_DIR\\cli.bat" "$@"
{ "python.linting.pylintEnabled": true, "python.linting.enabled": true, "python.linting.pylintPath": "${workspaceFolder}\\tools\\windows\\python\\Scripts\\pylint.exe", "python.linting.pylintArgs": [ "--max-line-length=120", ], "python.defaultInterpreterPath": "${workspaceFolder}\\tools\\windows\\python\\python.exe", "python.formatting.autopep8Path": "${workspaceFolder}\\tools\\windows\\python\\Scripts\\autopep8.exe", "python.formatting.provider": "autopep8", "python.formatting.autopep8Args": [ "--max-line-length=120", "--experimental" ], "editor.formatOnSave": true, // "python.envFile": "${workspaceFolder}/.vs_env" }
nvl_cli --check-deps -v
git clone ssh://git@gitlab.nervtech.org:22002/nerv/nervland.git NervLand
#!/usr/bin/env bash # cf. https://stackoverflow.com/questions/59895/how-can-i-get-the-source-directory-of-a-bash-script-from-within-the-script-itsel SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) run_cli_windows() { # On windows we should simply rely on the cli.bat script below: SCRIPT_DIR="`cygpath -w $SCRIPT_DIR`" cmd /C "$SCRIPT_DIR\\cli.bat" "$@" } run_cli_linux() { # On linux we should call the python cli directly: # Get the project root folder: local root_dir=`readlink -f $SCRIPT_DIR/../` echo "NervLand root dir is: $root_dir" # Check if we already have python: local tools_dir=$root_dir/tools/linux local tmp_dir=$root_dir/temp if [[ ! -d $tmp_dir ]]; then echo "Creating temp folder..." mkdir $tmp_dir fi local unzip_dir=$tools_dir/7zip local unzip_path=$unzip_dir/7zzs if [[ ! -d $unzip_dir ]]; then echo "Extracting 7zip tool..." pushd $tools_dir > /dev/null tar xvJf 7zip.tar.xz popd > /dev/null fi local python_dir=$tools_dir/python local python_path=$python_dir/bin/python3 if [[ ! -d $python_dir ]]; then # Check if we already have the python.7z if [[ -e "${python_dir}.7z" ]]; then echo "Extracting $python_dir.7z..." $unzip_path x -o"$tools_dir" "${python_dir}.7z" > /dev/null else local pyversion="3.10.2" local pyfolder="Python-$pyversion" local tarfile="$pyfolder.tar.xz" local url="https://www.python.org/ftp/python/$pyversion/$tarfile" pushd $tmp_dir > /dev/null # Remove any previous build folder: if [[ -d $pyfolder ]]; then echo "Removing previous $pyfolder..." rm -Rf $pyfolder fi if [[ -e $tarfile ]]; then echo "Removing previous $tarfile..." rm -Rf $tarfile fi echo "Downloading python sources from $url" wget -O $tarfile $url tar xvJf $tarfile # Enter into the python source folder: pushd $pyfolder > /dev/null # should ensure that the dependency packages are installed (?) # sudo apt-get install libbz2-dev liblzma-dev echo "Configuring python..." ./configure --enable-optimizations --prefix=$python_dir.tmp CFLAGS=-fPIC CXXFLAGS=-fPIC # --enable-loadable-sqlite-extensions --with-system-expat --with-system-ffi CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib echo "Building python..." # Note: Building with optimizations is very slow: make echo "Installing python..." make install popd > /dev/null popd > /dev/null # Now we rename the destination folder: mv $python_dir.tmp $python_dir # And we create the 7z package: echo "Generating python tool package..." $unzip_path a -t7z $python_dir.7z $python_dir -m0=lzma2 -mx=9 -aoa -mfb=64 -md=32m -ms=on -r # removing python build folder: echo "Removing python build folder..." rm -Rf temp/$pyfolder* echo "Done generating python package." fi # Once we have deployed the base python tool package we start with upgrading pip: echo "Upgrading pip..." $python_path -m pip install --upgrade pip # Finally we install the python requirements: echo "Installing python requirements..." $python_path -m pip install -r $root_dir/tools/requirements.txt fi # Execute the command in python: $python_path $root_dir/scripts/cli.py "$@" } # Check if we are on a windows or a linux system: pname=`uname -s` case $pname in CYGWIN*) run_cli_windows "$@" ;; *) run_cli_linux "$@" ;; esac
def _build_boost_linux64(self, build_dir, prefix, desc): """Build method for boost with linux64 compiler.""" comp = self.get_compiler_config() # cf. https://gist.github.com/Shauren/5c28f646bf7a28b470a8 # Note: the bootstrap.sh script above is crap, so instead we build b2 manually ourself here: bs_cmd = ["./tools/build/src/engine/build.sh", "clang", f"--cxx={comp['path']}", f"--cxxflags={comp['cxxflags']}" ] logger.info("Building B2 command: %s", bs_cmd) self.execute(bs_cmd, cwd=build_dir) bjam_file=self.get_path(build_dir, "bjam") self.copy_file(self.get_path(build_dir, "tools/build/src/engine/b2"), bjam_file) self.add_execute_permission(bjam_file) with open(os.path.join(build_dir, "user-config.jam"), "w") as file: # Note: Should not add the -std=c++11 flag below as this will lead to an error with C files: file.write(f"using clang : : {comp['path']} : <compileflags>\"{comp['cxxflags']} -fPIC\" <linkflags>\"{comp['linkflags']}\" ;\n") # Note: below we need to run bjam with links to the clang libraries: build_env = os.environ.copy() build_env['LD_LIBRARY_PATH'] = comp['library_path'] bjam_cmd = ['./bjam', "--user-config=user-config.jam", "--buildid=clang", "-j", "8", "toolset=clang", "--prefix="+prefix, "--without-mpi", "-sNO_BZIP2=1", "architecture=x86", "variant=release", "link=static", "threading=multi", "target-os=linux", "address-model=64", "install"] logger.info("Executing bjam command: %s", bjam_cmd) self.execute(bjam_cmd, cwd=build_dir, env=build_env)
def _build_sdl2_linux64(self, build_dir, prefix, _desc): """Build method for sdl2 with linux64 compiler.""" build_env = self.setup_compiler_env() logger.info("Using CXXFLAGS: %s", build_env['CXXFLAGS']) cmd = [self.get_cmake_path(), "-DCMAKE_BUILD_TYPE=Release", "-DSDL_STATIC=ON", "-DSDL_STATIC_PIC=ON", f"-DCMAKE_INSTALL_PREFIX={prefix}", ".."] logger.info("Executing SDL2 build command: %s", cmd) self.execute(cmd, cwd=build_dir+"/src", env=build_env) # Build command: self.execute(["make"], cwd=build_dir+"/src", env=build_env) # Install command: self.execute(["make", "install"], cwd=build_dir+"/src", env=build_env)
def _build_luajit_linux64(self, build_dir, prefix, desc): """Build method for luajit with linux64 compiler.""" # End finally make install: build_env = self.setup_compiler_env() self.execute(["make", "install", f"PREFIX={prefix}", "HOST_CC=clang"], cwd=build_dir, env=build_env) # We should rename the include sub folder: "luajit-2.1" -> "luajit" dst_name=self.get_path(prefix, "include", "luajit") self.rename_folder(f"{dst_name}-{desc['version']}", dst_name)
$ nvl_cli --check-deps luajit --rebuild -v 2>&1 | tee build_luajit.log