-
-
Notifications
You must be signed in to change notification settings - Fork 80
InstallGuide
You can redistribute NPLRuntime side-by-side with your scripts and resource files on windows/linux/iOS, etc. However, this section is only about installing NPL runtime to your development computer and setting up a recommended coding environment for NPL.
It is very easy to install on windows. The win32 executable of NPL runtime is currently released in two forms, choose one that is most suitable to you:
- Download windows 32bits/64bits installer exe, which contains the current master branch version. Click to download. It will add
npl
to your path. - Download ParacraftSDK which is recommended for paracraft mod dev. See below.
Paracraft is an IDE written completely in NPL. Follow the steps:
- Download ParacraftSDK
- or you can clone it with following commands (you need git installed):
# clone repository & sub modules
git clone https://github.com/LiXizhi/ParaCraftSDK.git
cd ParaCraftSDK
git submodule init
git submodule update
# Go into the repository
cd ParaCraftSDK
# install paracraft
redist\paracraft.exe
# install NPLRuntime
NPLRuntime\install.bat
-
redist\paracraft.exe
will install the most recent version ofParacraft
to./redist
folder- if you failed to install, please manually download from Paracraft and copy all files to
redist
folder.
- if you failed to install, please manually download from Paracraft and copy all files to
- Inside
./NPLRuntime/install.bat
- The NPL Runtime will be copied from
./redist
folder to./NPLRuntime/win/bin
- The above path will be added to your
%path%
variable, so that you can run npl script from any folder.
- The NPL Runtime will be copied from
- If you use NPLRuntime installer, simply download and reinstall it here
- If you use paracraftSDK, we regularly update
paracraft
(weekly) on windows platform, you can update to latest version of NPL Runtime following following steps.- run
redist\paracraft.exe
to update paracraft's NPL runtime inredist
folder - run
NPLRuntime\install.bat
to copy NPL runtime executable fromredist
toNPLRuntime/win/bin
folder
- run
- Compiling from source code is always the latest version (recommended for serious developers), see next section.
To build 64bits version of NPLRuntime, you need to build from source code (see next section), or download prebuild version from http://www.paracraft.cn.
Our current build target for public users is still 32bits on windows platform.
Please note that all compiled and non-compiled NPL/lua code can be loaded by both 32bits/64bits version of NPL runtime across all supported platforms (windows/linux/mac/android/ios) etc. However, if you use any C++ plugins (such as mysql, mono, etc), they must be built for each platform and CPU architecture.
git clone https://github.com/LiXizhi/NPLRuntime.git
cd NPLRuntime && git submodule update --init --recursive
build_win32.bat
see build_win32.bat and appveyor.yml or our build output for details
- You can download and build boost from source code. Version
1.55.0
,1.60.0
,1.64.0
are tested, but the latest version should be fine. Suppose you have unzipped the boost toD:\boost
, you can build with following command.
b2 runtime-link=static --with-thread --with-date_time --with-filesystem --with-system --with-chrono --with-serialization --with-iostreams --with-regex stage
or just
b2 runtime-link=static
and then add a system environment variable called BOOST_ROOT
, with value D:\boost
(or where your boost is located), so that our build-tool will find boost for you.
- Download NPLRuntime source code, or clone it by running:
git clone https://github.com/LiXizhi/NPLRuntime.git
- Download cmake, and build either
server
orclient
version. They share the same code base but with differentcmakelist.txt
;client
version has everythingserver
has plus graphics API.-
Server
version: runNPLRuntime/NPLRuntime/CMakeList.txt
inNPLRuntime/bin/win32
folder (any folder is fine, but do not use thecmakelist.txt
source folder) -
Client
version: runNPLRuntime/Client/CMakeList.txt
inNPLRuntime/bin/Client
folder (any folder is fine, but do not use thecmakelist.txt
source folder), please refer to build_win32.bat for details- REQUIRED: Install latest DirectX9 SDK in default location here.
- There is also a cmake option called
ParaEngineClient_DLL
which will build NPLRuntime as shared library, instead of executable.
-
- If successful, you will have visual studio solution files generated. Open it with visual studio and build.
- The final executable is in
./ParaWorld/bin/
directory.
You need to install and update Paracraft to the latest version. After you have successfully build NPLRuntime. Open the project property page of ParaEngineClient in visual studio, and set the debugging's working directory to the paracraft redist folder. You can also specify some custom command line parameters there.
Windows XP is no longer supported officially. But you are still able to build. First one needs to install windows XP support in visual studio installer (2017 tested), then we need to turn NPLRUNTIME_WINXP on in cmake. After visual studio solution files are generated, we need to manually select all projects and change platform toolset to WindowsXP (v141_xp). Then we are able to generate an executables for windows XP. Known issues are that caudioengine.dll needs to be removed and libcurl does not support https website under windows XP. Please note, we need to install C++ WindowsXP platform toolset from visual studio 2017 installer, then we can build with vs 2017 or above.
When you build NPLRuntime from source code, all binary file(dlls) are automatically copied to ./ParaWorld/bin/
directory. All debug version files have _d
appended to the end of the dll or exe files, such as sqlite_d.dll
, etc.
To debug your application, you need to start your application using the executable in ./ParaWorld/bin/
, such as paraengineclient_d.exe
. You also need to specify a working directory where your application resides, such as ./redist
folder in ParacraftSDK
. Alternatively, one can also copy all dependent *_d.dll
files from ./ParaWorld/bin/
to your application's working directory.
Applications written in NPL are usually in pure NPL scripts. So you can download and install any NPL powered application (such as this one ), and set your executable's working directory to it before debugging from source code. ParacraftSDK
also contains a good collection of example NPL programs. Please see the video at TutorialWebSite for install guide.
Click here to download precompiled NPL Runtime linux 64bits release.
Under linux, it is highly recommended to build NPL from source code with latest packages and build tools on your dev/deployment machine.
- Download NPLRuntime source code, or clone it by running:
git clone https://github.com/LiXizhi/NPLRuntime.git
cd NPLRuntime && git submodule init && git submodule update
- Install third-party packages and latest build tools.
- see .travis.yml or our build output for reference (on debian/ubuntu). In most cases, you need
gcc 4.9 or above, cmake, bzip2, boost, libcurl
. Optionally, you can installmysql, mono, postgresql
if want to build NPL plugins for them.
- see .travis.yml or our build output for reference (on debian/ubuntu). In most cases, you need
- Run ./build_linux.sh from the root directory. Be patient to wait for build to complete.
./build_linux.sh
or to enable parallel build of 6 concurrent make jobs, do following
./build_linux.sh 6
Please note, you need to have at least 2GB memory to build with gcc, or you need to step up swap memory
- The final executable is in
./ParaWorld/bin64/
directory. A symbolic link to the executable is created in/usr/local/bin/npl
, so that you can run NPL script from anywhere.
Make sure you have prepared linux packages in the previous step. One needs to install SDL2 and then run cmake like above. Currently, this is tested on ubuntu20@WSL2 on windows 11.
# 编译安装SDL
source build_sdl2.sh
# 编译安装Boost
./npl_boost_install.sh
# 配置NPLRuntime
cmake -S NPLRuntime -B out -DLINUX=TRUE -DSDL_ROOT=${SDL_ROOT}
# 编译NPLRuntime 会在./paraworld/bin64目录下生成可执行文件ParaCraftSDL2
cmake --build out
# 到Paracraft正式环境拷贝相关的配置文件到./paraworld/bin64即可执行ParaCraftSDL2. 相关配置(config/, database/, *.txt, *.pkg, *.ini, *.json)
First you need a linux environment such as WSL ubuntu, and then download emscripten and build boost, such as version 1.81.
./emsdk install latest
./emsdk activate latest && source ./emsdk_env.sh
1. 编译boost 下载boost.1.81.0源码, 解压并进入源码目录, 执行如下指令编译
.\bootstrap.bat
\b2 toolset=emscripten runtime-link=static --with-thread --with-date_time --with-filesystem --with-system --with-chrono --with-serialization --locale
进入生成的 stage/lib 目录, 对每个xxx.bc文件执行命令 emar -q xxx.a xxx.bc 将.bc转成.a文件
2. 进入NPLRuntime根目录: (git clone git@github.com:LiXizhi/NPLRuntime.git; cd NPLRuntime; git checkout emscripten)
emcmake cmake -S NPLRuntime -B build\emscripten -DEMSCRIPTEN=ON -DCMAKE_BUILD_TYPE=RELEASE -DBOOST_ROOT="boost_directory" -DAPP_ROOT="app_diectory"
cd build\emscripten
emmake make
- boost_directory 为boost根目录
- app_diectory 为应用程序根目录, 此目录需放置ParaCraft所需相关文件
- boost 报[-Wc++11-narrowing]错误 为类型转换精度缩小不支持, 编辑相关报错文件, 进行强制类型转换修复
- 编译成功后在build\emscripten\bin\ParaCraft.html, js, wasm, worker.js等网页静态文件
- 配置Nignx配置文件, 新建站点 emscripten.keepwork.com 非localhost站点使用https协议
- 指定站点根目录, 如: root /root;
- 将根目录配置成静态文件访问目录, 并添加特定响应头, 示例代码如下:
location / {
# 下两行所有环境均需要
add_header 'Cross-Origin-Embedder-Policy' 'require-corp';
add_header 'Cross-Origin-Opener-Policy' 'same-origin';
# 下面三行部署测试需要, 避免浏览器缓存文件
add_header 'Cache-Control' 'no-cache';
add_header 'Pragma' 'no-cache';
add_header 'Expires' '0';
# 通过url访问静态文件配置
try_files $uri $uri/ =404;
}
- script 脚本更新 main150727.pkg => ${APP_ROOT}/main150727.pkg
- buildinmod 内嵌模块更新 paracraftbuildinomod.zip => ${APP_ROOT}/npl_packages/ParacraftBuildiMod.zip 注意文件路径大小
- NPLRuntime emscripten 分支更新 上述代码发生跟改自动触发编译部署(开发环境) 资源更新可能也需要触发
We can build either the server or client version on OSX.
For server version:
./npl_boost_install.sh
./build_mac_server.sh 6
For client version:
./build_mac_client.sh
It will generate an XCode project from cmakefiles under ./build/mac
folder.
Please put all your asset files under NPLRuntime/Platform/OSX/assets
folder.
Then one can build it from XCode.
In order to submit to App Store, one must enable app sandbox. To do so, one must manually set application settings in Capabilities
tab and enable App Sandbox:
- Network: incoming and outgoing connections both client and server
- Bluetooth
- User selected file: readonly.
App sandbox API will not take effect if app is not code-signed, so one must also enable automatic code signing in the settings page. However, one must also add --deep
flag to Other Code Signing Flags
in build settings to enable signing all libraries as well.
Docker is the world’s leading software container platform. We can use Docker to run and manage apps side-by-side in isolated containers to get better compute density. This is an example in ubuntu 16.04.
- Install docker
#sudo apt-get update
#sudo apt-get install docker.io
- Search NPLRuntime images and pull it to localhost from docker hub
#docker search npl-runtime
#docker pull xuntian/ubuntu-npl-runtime
- Run NPLRuntime images
#docker run -dti xuntian/ubuntu-npl-runtime bash
Switch to
cp_old
branch to build for android.
We will build android apk with visual studio and Nvidia Nsight for visual studio. Nsight allows one to easily debug real device in visual studio. CMake natively supports generating target for visual studio + Nsight. But before that, we need to cross-compile some libraries like boost. We recommend you using boost 1.69 or above and cmake 3.11 or above.
First one needs to build boost for android.
NPLRuntime\externals\boost\build_android.bat
Second, run CMake and select Android and clang++ for the toolchain. see following for details:
build_android_tegra.bat
Open visual studio, and build and run.
For Nsight, you need to configure NDK, android SDK, ant, JDK in visual studio.
E:\Tools\android-ndk-r9d
C:\Program Files (x86)\Android\android-sdk
E:\Tools\apache-ant-1.9.4
C:\ProgramData\Chocolatey\lib\gradle\tools\gradle-4.6
D:\Program Files (x86)\Java\jdk1.8.0_11
d:\Program Files (x86)\Xoreax\IncrediBuild
Put all your android asset files to NPLRuntime/Platform/Android/assets
folder.
For an example of how an asset folder looks like, please see paracraft build file here, please switch to Android, iOS, win32 branch as needed.
Next run CMake and specify Android
as cross-platform toolchain name. This will generate a visual studio solution. And you are ready to build either the release or debug version.
Note: Nsight 3.5 + visual studio 2017
We can build for a simulator or device. A device build is recommended. First you need to build boost for all iOS architectures by running ./NPLRuntime/externals/boost/build_ios_and_osx.sh
The shell script will automatically download boost and compile it to ./NPLRuntime/externals/boost/prebuild
folder
Then we need to run ./build_ios_os.sh
to generate xcode project file from cmake files. The generated XCode project file is located in ./build/ios/ios_os
Like Android, one needs to put all your asset files to NPLRuntime/Platform/iOS/assets
folder. Please note, do not use symbolic links in the assets folder. Then build and run your app, it may take a while to build.
For an example of how an asset folder looks like, please see paracraft build file here, please switch to android, iOS, win32 branch as needed.
You can use your preferred editors that support lua syntax highlighting. NPL Runtime has a built-in web server called NPL Code Wiki, it allows you to edit and debug via HTTP from any web browser on any platform.
- NPL Code Wiki: build-in debugger and editor.
We have developed npl-debugger-plugins for following editors:
- Visual Studio Code: a very good free/cross-platform editor
-
Visual Studio Community Edition: the free version of
visual studio
(windows only) This is the one I used most.
We have developed several useful open-source NPL language plugins for visual studio products:
In visual studio, select menu::Tools::Extensions
, and search online for npl
to install following plugins:
- NPL Language service for vs code
-
NPL/Lua language service for visual studio: used by thousands of developers worldwide.
- Download Source code
-
NPL Debugger for visual studio: set break points and attach to running NPL process.
- Download Source code
- NPL/ParaEngine Tools for visual studio: misc tools
ParacraftSDK contains many example projects written in NPL.
- See ParacraftSDK wiki site for more details.
- You may now get your hand dirty by this tutorial or continue reading here.
Download Paracraft | ParacraftSDK | copyright by tatfook 2016 | upload image