From e938c04e3021d9cc756351e51c211ee6bd696317 Mon Sep 17 00:00:00 2001 From: uramer Date: Thu, 26 Jan 2023 23:31:27 +0100 Subject: [PATCH 01/12] Generate Teal declarations from luadoc --- docs/build_teal.sh | 36 ++++++++++++++++++++++++++++++++ docs/source/generate_luadoc.sh | 13 ++++++------ docs/source/luadoc_data_paths.sh | 9 ++++++++ docs/tlconfig.lua | 6 ++++++ 4 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 docs/build_teal.sh create mode 100644 docs/source/luadoc_data_paths.sh create mode 100644 docs/tlconfig.lua diff --git a/docs/build_teal.sh b/docs/build_teal.sh new file mode 100644 index 0000000000..dac453a4a4 --- /dev/null +++ b/docs/build_teal.sh @@ -0,0 +1,36 @@ +DOCS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +FILES_DIR=$(realpath $DOCS_DIR/../files) +OUTPUT_DIR=$(realpath $DOCS_DIR/$1) +DOCUMENTOR_PATH=~/.luarocks/bin/openmwluadocumentor +TEAL_PATH=~/.luarocks/bin/tl + +rm -rf $OUTPUT_DIR +mkdir $OUTPUT_DIR +cp "$DOCS_DIR/tlconfig.lua" "$OUTPUT_DIR/tlconfig.lua" + +build_path() { + for file in $1 + do + mkdir -p $OUTPUT_DIR/$(dirname $file) + $DOCUMENTOR_PATH -f teal -d "$OUTPUT_DIR" $file + done +} + +cd $FILES_DIR +build_path lua_api/openmw/*lua + +data_paths=$($DOCS_DIR/source/luadoc_data_paths.sh) +for path in $data_paths +do + build_path data/$path +done + +cd $OUTPUT_DIR + +mv lua_api/openmw ./ +rm -r lua_api + +mv data/* ./ +rm -r data + +"$TEAL_PATH" check **/*.d.tl diff --git a/docs/source/generate_luadoc.sh b/docs/source/generate_luadoc.sh index fc3d6dc999..7c8815e808 100755 --- a/docs/source/generate_luadoc.sh +++ b/docs/source/generate_luadoc.sh @@ -20,13 +20,12 @@ fi rm -f $OUTPUT_DIR/*.html +data_paths=$($DOCS_SOURCE_DIR/luadoc_data_paths.sh) + cd $FILES_DIR/lua_api $DOCUMENTOR_PATH -f doc -d $OUTPUT_DIR openmw/*lua - cd $FILES_DIR/data -$DOCUMENTOR_PATH -f doc -d $OUTPUT_DIR openmw_aux/*lua -$DOCUMENTOR_PATH -f doc -d $OUTPUT_DIR scripts/omw/ai.lua -$DOCUMENTOR_PATH -f doc -d $OUTPUT_DIR scripts/omw/playercontrols.lua -$DOCUMENTOR_PATH -f doc -d $OUTPUT_DIR scripts/omw/camera/camera.lua -$DOCUMENTOR_PATH -f doc -d $OUTPUT_DIR scripts/omw/mwui/init.lua -$DOCUMENTOR_PATH -f doc -d $OUTPUT_DIR scripts/omw/settings/player.lua +for path in $data_paths +do + $DOCUMENTOR_PATH -f doc -d $OUTPUT_DIR $path +done diff --git a/docs/source/luadoc_data_paths.sh b/docs/source/luadoc_data_paths.sh new file mode 100644 index 0000000000..792e957c11 --- /dev/null +++ b/docs/source/luadoc_data_paths.sh @@ -0,0 +1,9 @@ +paths=( + openmw_aux/*lua + scripts/omw/ai.lua + scripts/omw/playercontrols.lua + scripts/omw/camera/camera.lua + scripts/omw/mwui/init.lua + scripts/omw/settings/player.lua +) +printf '%s\n' "${paths[@]}" \ No newline at end of file diff --git a/docs/tlconfig.lua b/docs/tlconfig.lua new file mode 100644 index 0000000000..f3e3a0d3a6 --- /dev/null +++ b/docs/tlconfig.lua @@ -0,0 +1,6 @@ +-- used for checking generated declarations +return { + gen_target = '5.1', + gen_compat = 'off', + include_dir = { '.', }, +} From 75fcf53f7de73598a872dee6e0c7245a626bcf4e Mon Sep 17 00:00:00 2001 From: uramer Date: Fri, 27 Jan 2023 19:53:10 +0100 Subject: [PATCH 02/12] Teal CI --- .gitlab-ci.yml | 13 ++++++ CI/teal_ci.sh | 46 +++++++++++++++++++ docs/build_teal.sh | 13 ++++-- .../source/install_luadocumentor_in_docker.sh | 11 +++-- docs/source/luadoc_data_paths.sh | 0 5 files changed, 73 insertions(+), 10 deletions(-) create mode 100755 CI/teal_ci.sh mode change 100644 => 100755 docs/build_teal.sh mode change 100644 => 100755 docs/source/luadoc_data_paths.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2f16c93ac4..e6cb3196de 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -134,6 +134,19 @@ Clang_Format: script: - CI/check_clang_format.sh +Teal: + stage: checks + extends: .Ubuntu_Image + before_script: + - apt-get update + - apt-get -y install curl wget make build-essential libreadline-dev git-core zip unzip + script: + - CI/teal_ci.sh + artifacts: + paths: + - build_teal + + Ubuntu_GCC_Debug: extends: .Ubuntu cache: diff --git a/CI/teal_ci.sh b/CI/teal_ci.sh new file mode 100755 index 0000000000..61cfdb05bc --- /dev/null +++ b/CI/teal_ci.sh @@ -0,0 +1,46 @@ +pushd . + +echo "Install lua 5.1" +cd ~ +curl -R -O https://www.lua.org/ftp/lua-5.1.5.tar.gz +tar -zxf lua-5.1.5.tar.gz +rm lua-5.1.5.tar.gz +cd lua-5.1.5/ +make linux +cd ~ +PATH=$PATH:~/lua-5.1.5/src + +echo "Install luarocks" +luarocksV="3.9.2" +wget https://luarocks.org/releases/luarocks-$luarocksV.tar.gz +tar zxpf luarocks-$luarocksV.tar.gz +rm luarocks-$luarocksV.tar.gz +cd luarocks-$luarocksV/ +./configure --with-lua-bin=$HOME/lua-5.1.5/src --with-lua-include=$HOME/lua-5.1.5/src --prefix=$HOME/luarocks +make build +make install +cd ~ +rm -r luarocks-$luarocksV +PATH=$PATH:~/luarocks/bin + +echo "Install openmwluadocumentor" +git clone https://gitlab.com/ptmikheev/openmw-luadocumentor.git +cd openmw-luadocumentor +luarocks make luarocks/openmwluadocumentor-0.2.0-1.rockspec +cd ~ +rm -r openmw-luadocumentor + + +echo "Install Teal Cyan" +git clone https://github.com/teal-language/cyan.git --depth 1 +cd cyan +luarocks make cyan-dev-1.rockspec + +luarocks show openmwluadocumentor +luarocks show cyan + +LUAROCKS=~/luarocks/bin +export LUAROCKS +popd +pushd docs +./build_teal.sh ../build_teal diff --git a/docs/build_teal.sh b/docs/build_teal.sh old mode 100644 new mode 100755 index dac453a4a4..0325842068 --- a/docs/build_teal.sh +++ b/docs/build_teal.sh @@ -1,8 +1,11 @@ +# Requires the LUAROCKS variable to be set to the luarocks/bin directory, e. g. `~/.luarocks/bin` +# takes an absolute path to the output directory as the argument + DOCS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" FILES_DIR=$(realpath $DOCS_DIR/../files) -OUTPUT_DIR=$(realpath $DOCS_DIR/$1) -DOCUMENTOR_PATH=~/.luarocks/bin/openmwluadocumentor -TEAL_PATH=~/.luarocks/bin/tl +OUTPUT_DIR=$1 +DOCUMENTOR_PATH=$LUAROCKS/openmwluadocumentor +TEAL_PATH=$LUAROCKS/cyan rm -rf $OUTPUT_DIR mkdir $OUTPUT_DIR @@ -17,12 +20,12 @@ build_path() { } cd $FILES_DIR -build_path lua_api/openmw/*lua +build_path "lua_api/openmw/*lua" data_paths=$($DOCS_DIR/source/luadoc_data_paths.sh) for path in $data_paths do - build_path data/$path + build_path "data/$path" done cd $OUTPUT_DIR diff --git a/docs/source/install_luadocumentor_in_docker.sh b/docs/source/install_luadocumentor_in_docker.sh index 35ed9bef08..e0b331a0a7 100644 --- a/docs/source/install_luadocumentor_in_docker.sh +++ b/docs/source/install_luadocumentor_in_docker.sh @@ -14,15 +14,16 @@ cd ~ PATH=$PATH:~/lua-5.1.5/src echo "Install luarocks" -wget https://luarocks.org/releases/luarocks-2.4.2.tar.gz -tar zxpf luarocks-2.4.2.tar.gz -rm luarocks-2.4.2.tar.gz -cd luarocks-2.4.2/ +luarocksV="3.9.2" +wget https://luarocks.org/releases/luarocks-$luarocksV.tar.gz +tar zxpf luarocks-$luarocksV.tar.gz +rm luarocks-$luarocksV.tar.gz +cd luarocks-$luarocksV/ ./configure --with-lua-bin=$HOME/lua-5.1.5/src --with-lua-include=$HOME/lua-5.1.5/src --prefix=$HOME/luarocks make build make install cd ~ -rm -r luarocks-2.4.2 +rm -r luarocks-$luarocksV PATH=$PATH:~/luarocks/bin echo "Install openmwluadocumentor" diff --git a/docs/source/luadoc_data_paths.sh b/docs/source/luadoc_data_paths.sh old mode 100644 new mode 100755 From 7d4222b9ce54170ee0bcfe810c0b4adce12fbe79 Mon Sep 17 00:00:00 2001 From: uramer Date: Sun, 29 Jan 2023 20:58:00 +0100 Subject: [PATCH 03/12] Zip the teal directory --- .gitlab-ci.yml | 192 ++++++++++++++++++++++++------------------------- CI/teal_ci.sh | 2 + 2 files changed, 97 insertions(+), 97 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e6cb3196de..e9be1a39af 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,8 +28,8 @@ variables: extends: .Ubuntu_Image cache: paths: - - apt-cache/ - - ccache/ + - apt-cache/ + - ccache/ stage: build variables: CMAKE_EXE_LINKER_FLAGS: -fuse-ld=mold @@ -74,8 +74,8 @@ Coverity: cache: key: Coverity.ubuntu_20.04.v1 paths: - - apt-cache/ - - ccache/ + - apt-cache/ + - ccache/ variables: CCACHE_SIZE: 2G CC: clang-11 @@ -119,7 +119,7 @@ Ubuntu_GCC: CCACHE_SIZE: 4G # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. timeout: 2h - + Clang_Format: extends: .Ubuntu_Image stage: checks @@ -144,8 +144,7 @@ Teal: - CI/teal_ci.sh artifacts: paths: - - build_teal - + - build_teal.zip Ubuntu_GCC_Debug: extends: .Ubuntu @@ -390,9 +389,9 @@ Ubuntu_Clang_integration_tests: - $CI_PROJECT_ID == "7107382" cache: paths: - - ccache/ + - ccache/ script: - - rm -fr build # remove the build directory + - rm -fr build # remove the build directory - CI/before_install.osx.sh - export CCACHE_BASEDIR="$(pwd)" - export CCACHE_DIR="$(pwd)/ccache" @@ -421,29 +420,29 @@ macOS12_Xcode13: rules: - if: $CI_PIPELINE_SOURCE == "push" before_script: - - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" - - choco source add -n=openmw-proxy -s="https://repo.openmw.org/repository/Chocolatey/" --priority=1 - - choco source disable -n=chocolatey - - choco install git --force --params "/GitAndUnixToolsOnPath" -y - - choco install 7zip -y - - choco install ccache -y - - choco install cmake.install --installargs 'ADD_CMAKE_TO_PATH=System' -y - - choco install vswhere -y - - choco install ninja -y - - choco install python -y - - refreshenv - - | - function Make-SafeFileName { - param( - [Parameter(Mandatory=$true)] - [String] - $FileName - ) - [IO.Path]::GetInvalidFileNameChars() | ForEach-Object { - $FileName = $FileName.Replace($_, '_') + - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" + - choco source add -n=openmw-proxy -s="https://repo.openmw.org/repository/Chocolatey/" --priority=1 + - choco source disable -n=chocolatey + - choco install git --force --params "/GitAndUnixToolsOnPath" -y + - choco install 7zip -y + - choco install ccache -y + - choco install cmake.install --installargs 'ADD_CMAKE_TO_PATH=System' -y + - choco install vswhere -y + - choco install ninja -y + - choco install python -y + - refreshenv + - | + function Make-SafeFileName { + param( + [Parameter(Mandatory=$true)] + [String] + $FileName + ) + [IO.Path]::GetInvalidFileNameChars() | ForEach-Object { + $FileName = $FileName.Replace($_, '_') + } + return $FileName } - return $FileName - } stage: build script: - $time = (Get-Date -Format "HH:mm:ss") @@ -472,22 +471,22 @@ macOS12_Xcode13: cache: key: ninja-v5 paths: - - ccache - - deps - - MSVC2019_64_Ninja/deps/Qt + - ccache + - deps + - MSVC2019_64_Ninja/deps/Qt artifacts: when: always paths: - - "*.zip" - - "*.log" - - MSVC2019_64_Ninja/*.log - - MSVC2019_64_Ninja/*/*.log - - MSVC2019_64_Ninja/*/*/*.log - - MSVC2019_64_Ninja/*/*/*/*.log - - MSVC2019_64_Ninja/*/*/*/*/*.log - - MSVC2019_64_Ninja/*/*/*/*/*/*.log - - MSVC2019_64_Ninja/*/*/*/*/*/*/*.log - - MSVC2019_64_Ninja/*/*/*/*/*/*/*/*.log + - "*.zip" + - "*.log" + - MSVC2019_64_Ninja/*.log + - MSVC2019_64_Ninja/*/*.log + - MSVC2019_64_Ninja/*/*/*.log + - MSVC2019_64_Ninja/*/*/*/*.log + - MSVC2019_64_Ninja/*/*/*/*/*.log + - MSVC2019_64_Ninja/*/*/*/*/*/*.log + - MSVC2019_64_Ninja/*/*/*/*/*/*/*.log + - MSVC2019_64_Ninja/*/*/*/*/*/*/*/*.log # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. timeout: 2h @@ -524,28 +523,28 @@ macOS12_Xcode13: rules: - if: $CI_PIPELINE_SOURCE == "push" before_script: - - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" - - choco source add -n=openmw-proxy -s="https://repo.openmw.org/repository/Chocolatey/" --priority=1 - - choco source disable -n=chocolatey - - choco install git --force --params "/GitAndUnixToolsOnPath" -y - - choco install 7zip -y - - choco install ccache -y - - choco install cmake.install --installargs 'ADD_CMAKE_TO_PATH=System' -y - - choco install vswhere -y - - choco install python -y - - refreshenv - - | - function Make-SafeFileName { - param( - [Parameter(Mandatory=$true)] - [String] - $FileName - ) - [IO.Path]::GetInvalidFileNameChars() | ForEach-Object { - $FileName = $FileName.Replace($_, '_') + - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" + - choco source add -n=openmw-proxy -s="https://repo.openmw.org/repository/Chocolatey/" --priority=1 + - choco source disable -n=chocolatey + - choco install git --force --params "/GitAndUnixToolsOnPath" -y + - choco install 7zip -y + - choco install ccache -y + - choco install cmake.install --installargs 'ADD_CMAKE_TO_PATH=System' -y + - choco install vswhere -y + - choco install python -y + - refreshenv + - | + function Make-SafeFileName { + param( + [Parameter(Mandatory=$true)] + [String] + $FileName + ) + [IO.Path]::GetInvalidFileNameChars() | ForEach-Object { + $FileName = $FileName.Replace($_, '_') + } + return $FileName } - return $FileName - } stage: build script: - $time = (Get-Date -Format "HH:mm:ss") @@ -573,22 +572,22 @@ macOS12_Xcode13: cache: key: msbuild-v5 paths: - - ccache - - deps - - MSVC2019_64/deps/Qt + - ccache + - deps + - MSVC2019_64/deps/Qt artifacts: when: always paths: - - "*.zip" - - "*.log" - - MSVC2019_64/*.log - - MSVC2019_64/*/*.log - - MSVC2019_64/*/*/*.log - - MSVC2019_64/*/*/*/*.log - - MSVC2019_64/*/*/*/*/*.log - - MSVC2019_64/*/*/*/*/*/*.log - - MSVC2019_64/*/*/*/*/*/*/*.log - - MSVC2019_64/*/*/*/*/*/*/*/*.log + - "*.zip" + - "*.log" + - MSVC2019_64/*.log + - MSVC2019_64/*/*.log + - MSVC2019_64/*/*/*.log + - MSVC2019_64/*/*/*/*.log + - MSVC2019_64/*/*/*/*/*.log + - MSVC2019_64/*/*/*/*/*/*.log + - MSVC2019_64/*/*/*/*/*/*/*.log + - MSVC2019_64/*/*/*/*/*/*/*/*.log # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. timeout: 2h @@ -622,7 +621,6 @@ Windows_MSBuild_RelWithDebInfo: - if: $CI_PIPELINE_SOURCE == "push" - if: $CI_PIPELINE_SOURCE == "schedule" - .Ubuntu_AndroidNDK_arm64-v8a: tags: - linux @@ -683,21 +681,21 @@ Windows_MSBuild_RelWithDebInfo: - scripts/find_missing_merge_requests.py --project_id=$CI_PROJECT_ID --ignored_mrs_path=$CI_PROJECT_DIR/.resubmitted_merge_requests.txt .flatpak: - image: 'docker.io/bilelmoussaoui/flatpak-github-actions' - stage: build - script: - - flatpak install -y flathub org.kde.Platform/x86_64/5.15-21.08 - - flatpak install -y flathub org.kde.Sdk/x86_64/5.15-21.08 - - flatpak-builder --ccache --force-clean --repo=repo build CI/org.openmw.OpenMW.devel.yaml - - flatpak build-bundle ./repo openmw.flatpak org.openmw.OpenMW.devel - cache: - key: flatpak - paths: - - ".flatpak-builder" - artifacts: - untracked: false - paths: - - "openmw.flatpak" - # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. - # Flatpak Builds compile all dependencies aswell so need more time. Build results of libraries are cached - timeout: 4h + image: "docker.io/bilelmoussaoui/flatpak-github-actions" + stage: build + script: + - flatpak install -y flathub org.kde.Platform/x86_64/5.15-21.08 + - flatpak install -y flathub org.kde.Sdk/x86_64/5.15-21.08 + - flatpak-builder --ccache --force-clean --repo=repo build CI/org.openmw.OpenMW.devel.yaml + - flatpak build-bundle ./repo openmw.flatpak org.openmw.OpenMW.devel + cache: + key: flatpak + paths: + - ".flatpak-builder" + artifacts: + untracked: false + paths: + - "openmw.flatpak" + # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. + # Flatpak Builds compile all dependencies aswell so need more time. Build results of libraries are cached + timeout: 4h diff --git a/CI/teal_ci.sh b/CI/teal_ci.sh index 61cfdb05bc..f33596d6a3 100755 --- a/CI/teal_ci.sh +++ b/CI/teal_ci.sh @@ -44,3 +44,5 @@ export LUAROCKS popd pushd docs ./build_teal.sh ../build_teal +popd +zip build_teal.zip -r build_teal From dd3c89c5dbe310acf4d03d062a64a361cecff9d6 Mon Sep 17 00:00:00 2001 From: uramer Date: Sun, 29 Jan 2023 23:10:41 +0100 Subject: [PATCH 04/12] Document the Teal workflow --- .../reference/lua-scripting/overview.rst | 9 +++- docs/source/reference/lua-scripting/teal.rst | 44 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 docs/source/reference/lua-scripting/teal.rst diff --git a/docs/source/reference/lua-scripting/overview.rst b/docs/source/reference/lua-scripting/overview.rst index f09b56a47c..44c48d2742 100644 --- a/docs/source/reference/lua-scripting/overview.rst +++ b/docs/source/reference/lua-scripting/overview.rst @@ -1,13 +1,20 @@ Overview of Lua scripting ######################### +.. toctree:: + :hidden: + + teal + Language and sandboxing ======================= OpenMW supports scripts written in Lua 5.1 with some extensions (see below) from Lua 5.2. There are no plans to switch to any newer version of the language, because newer versions are not supported by LuaJIT. -Here are starting points for learning Lua: +There are also experimental declarations available for Teal, a typed dialect of Lua. see :ref:`Teal` for more details. + +Here are some starting points for learning Lua: - `Programing in Lua `__ (first edition, aimed at Lua 5.0) - `Lua 5.1 Reference Manual `__ diff --git a/docs/source/reference/lua-scripting/teal.rst b/docs/source/reference/lua-scripting/teal.rst new file mode 100644 index 0000000000..0b28a57146 --- /dev/null +++ b/docs/source/reference/lua-scripting/teal.rst @@ -0,0 +1,44 @@ +Teal +#### + +What is Teal? +============= + +Teal is a typed dialect of Lua. `Teal's Github repository `_. + +Teal compiles into Lua, so you can use it in any Lua 5.1+ runtime. If you are familiar with TypeScript, Teal is to Lua what TypeScript is to JavaScript. +You can find the basics of the syntax and justification for typed Lua in the `Teal tutorial `_. + +Teal's syntax is mostly the same as Lua, but with additional type declarations and annotations. +It will help you catch many mistakes before even running a script, and provide confidence about large code changes. + +Using the type checker +====================== + +To compile your ``.tl`` files into ``.lua`` files, install `Cyan, Teal's build system `_. + +Create a directory for your project, with a ``tlconfig.lua`` file inside. +All of your scripts (i. e. the ``scripts`` directory) should be within this directory. +``tlconfig.lua`` configures the Teal build system and compiler, see the `complete list here `_. + +.. note:: + You can use ``cyan init`` to set up a directory for a Teal project automatically. + +In addition to setting up a build process, you will need the `declaration files for the OpenMW API `_. +Unpack them into a directory of your choice, and add that path to the ``include_dir`` option in your ``tlconfig.lua``. Alternatively, you can add ``-I `` as an agument to ``Cyan`` commands. + +After everything is ready, run ``cyan build`` in the same directory as ``tlconfig.lua``. It will find all the ``.tl`` files in the ``source_dir``, and put compiled ``.lua`` files at the same relative paths inside ``build_dir``. +Running ``cyan build`` will also perform a type check, notifying you of any mismatches or mistakes. + +.. note:: + ``source_dir`` and ``build_dir`` can be the same directory. In fact, that is the recommended arrangement, so that it's convenient to include the original sources with your scripts. + +IDE support +=========== + +Work on `Teal Language Server `_ is still ongoing, so for now the only supported IDE is `Visual Studio Code `_. +It's available on Windows, Linux and Mac, so most likely you can run it too. +Teal's extension can be found here: `VSCode Marketplace `_ (or simply search for "Teal" in the extension UI). + +.. note:: + VSCode also has a web version, but the Teal extension isn't available there. From 84712b55bb0cf599e3efa97a38c036adf9faef6b Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 11 Feb 2023 12:21:00 +0100 Subject: [PATCH 05/12] Error on missing arguments for the Teal script --- docs/build_teal.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/build_teal.sh b/docs/build_teal.sh index 0325842068..99cf60416b 100755 --- a/docs/build_teal.sh +++ b/docs/build_teal.sh @@ -1,5 +1,12 @@ -# Requires the LUAROCKS variable to be set to the luarocks/bin directory, e. g. `~/.luarocks/bin` -# takes an absolute path to the output directory as the argument +if [ -z "$LUAROCKS" ]; then + echo "Requires the LUAROCKS variable to be set to the luarocks/bin directory, e. g. `~/.luarocks/bin`" + exit +fi + +if [ -z "$1" ]; then + echo "Takes an absolute path to the output directory as the argument" + exit +fi DOCS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" FILES_DIR=$(realpath $DOCS_DIR/../files) From a8d32ebdca4a6700e7b25d39a6ecff9a5abc5f53 Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 11 Feb 2023 12:41:30 +0100 Subject: [PATCH 06/12] Rename the build_teal script --- .gitlab-ci.yml | 2 +- CI/teal_ci.sh | 4 ++-- docs/{build_teal.sh => generate_teal_declarations.sh} | 0 docs/source/reference/lua-scripting/teal.rst | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename docs/{build_teal.sh => generate_teal_declarations.sh} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e9be1a39af..16d668a863 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -144,7 +144,7 @@ Teal: - CI/teal_ci.sh artifacts: paths: - - build_teal.zip + - teal_declarations.zip Ubuntu_GCC_Debug: extends: .Ubuntu diff --git a/CI/teal_ci.sh b/CI/teal_ci.sh index f33596d6a3..722c39f7a8 100755 --- a/CI/teal_ci.sh +++ b/CI/teal_ci.sh @@ -43,6 +43,6 @@ LUAROCKS=~/luarocks/bin export LUAROCKS popd pushd docs -./build_teal.sh ../build_teal +./generate_teal_declarations.sh ../teal_declarations popd -zip build_teal.zip -r build_teal +zip teal_declarations.zip -r teal_declarations diff --git a/docs/build_teal.sh b/docs/generate_teal_declarations.sh similarity index 100% rename from docs/build_teal.sh rename to docs/generate_teal_declarations.sh diff --git a/docs/source/reference/lua-scripting/teal.rst b/docs/source/reference/lua-scripting/teal.rst index 0b28a57146..4ba4f2d507 100644 --- a/docs/source/reference/lua-scripting/teal.rst +++ b/docs/source/reference/lua-scripting/teal.rst @@ -24,7 +24,7 @@ All of your scripts (i. e. the ``scripts`` directory) should be within this dire .. note:: You can use ``cyan init`` to set up a directory for a Teal project automatically. -In addition to setting up a build process, you will need the `declaration files for the OpenMW API `_. +In addition to setting up a build process, you will need the `declaration files for the OpenMW API `_. Unpack them into a directory of your choice, and add that path to the ``include_dir`` option in your ``tlconfig.lua``. Alternatively, you can add ``-I `` as an agument to ``Cyan`` commands. After everything is ready, run ``cyan build`` in the same directory as ``tlconfig.lua``. It will find all the ``.tl`` files in the ``source_dir``, and put compiled ``.lua`` files at the same relative paths inside ``build_dir``. From c31d872f189af30a072571c722278d069fb540f0 Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 11 Feb 2023 12:51:43 +0100 Subject: [PATCH 07/12] Use install_luadocumentor_in_docker for teal_ci --- CI/teal_ci.sh | 29 +------------------ .../source/install_luadocumentor_in_docker.sh | 5 ++-- 2 files changed, 3 insertions(+), 31 deletions(-) mode change 100644 => 100755 docs/source/install_luadocumentor_in_docker.sh diff --git a/CI/teal_ci.sh b/CI/teal_ci.sh index 722c39f7a8..990d12f9f8 100755 --- a/CI/teal_ci.sh +++ b/CI/teal_ci.sh @@ -1,36 +1,9 @@ pushd . -echo "Install lua 5.1" -cd ~ -curl -R -O https://www.lua.org/ftp/lua-5.1.5.tar.gz -tar -zxf lua-5.1.5.tar.gz -rm lua-5.1.5.tar.gz -cd lua-5.1.5/ -make linux -cd ~ -PATH=$PATH:~/lua-5.1.5/src +docs/source/install_luadocumentor_in_docker.sh -echo "Install luarocks" -luarocksV="3.9.2" -wget https://luarocks.org/releases/luarocks-$luarocksV.tar.gz -tar zxpf luarocks-$luarocksV.tar.gz -rm luarocks-$luarocksV.tar.gz -cd luarocks-$luarocksV/ -./configure --with-lua-bin=$HOME/lua-5.1.5/src --with-lua-include=$HOME/lua-5.1.5/src --prefix=$HOME/luarocks -make build -make install -cd ~ -rm -r luarocks-$luarocksV PATH=$PATH:~/luarocks/bin -echo "Install openmwluadocumentor" -git clone https://gitlab.com/ptmikheev/openmw-luadocumentor.git -cd openmw-luadocumentor -luarocks make luarocks/openmwluadocumentor-0.2.0-1.rockspec -cd ~ -rm -r openmw-luadocumentor - - echo "Install Teal Cyan" git clone https://github.com/teal-language/cyan.git --depth 1 cd cyan diff --git a/docs/source/install_luadocumentor_in_docker.sh b/docs/source/install_luadocumentor_in_docker.sh old mode 100644 new mode 100755 index e0b331a0a7..d65e25f85c --- a/docs/source/install_luadocumentor_in_docker.sh +++ b/docs/source/install_luadocumentor_in_docker.sh @@ -28,8 +28,7 @@ PATH=$PATH:~/luarocks/bin echo "Install openmwluadocumentor" git clone https://gitlab.com/ptmikheev/openmw-luadocumentor.git -cd openmw-luadocumentor/luarocks -luarocks --local pack openmwluadocumentor-0.2.0-1.rockspec -luarocks --local install openmwluadocumentor-0.2.0-1.src.rock +cd openmw-luadocumentor +luarocks make luarocks/openmwluadocumentor-0.2.0-1.rockspec cd ~ rm -r openmw-luadocumentor From 4b54c0663588dde3a9a8bb856f957e884d2ba9a1 Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 11 Feb 2023 14:00:00 +0100 Subject: [PATCH 08/12] Remove debug luarocks show --- CI/teal_ci.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/CI/teal_ci.sh b/CI/teal_ci.sh index 990d12f9f8..14aff96bc5 100755 --- a/CI/teal_ci.sh +++ b/CI/teal_ci.sh @@ -9,9 +9,6 @@ git clone https://github.com/teal-language/cyan.git --depth 1 cd cyan luarocks make cyan-dev-1.rockspec -luarocks show openmwluadocumentor -luarocks show cyan - LUAROCKS=~/luarocks/bin export LUAROCKS popd From 2cf6c5b3ce539a7aa9adeadc83325b0d685a8f21 Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 11 Feb 2023 14:09:41 +0100 Subject: [PATCH 09/12] Move generate_teal_declarations.sh to scripts/ --- CI/teal_ci.sh | 9 +++------ docs/source/generate_luadoc.sh | 2 +- {docs => scripts}/generate_teal_declarations.sh | 10 ++++++---- 3 files changed, 10 insertions(+), 11 deletions(-) rename {docs => scripts}/generate_teal_declarations.sh (72%) diff --git a/CI/teal_ci.sh b/CI/teal_ci.sh index 14aff96bc5..f08a1f8c9e 100755 --- a/CI/teal_ci.sh +++ b/CI/teal_ci.sh @@ -1,9 +1,7 @@ -pushd . - docs/source/install_luadocumentor_in_docker.sh - PATH=$PATH:~/luarocks/bin +pushd . echo "Install Teal Cyan" git clone https://github.com/teal-language/cyan.git --depth 1 cd cyan @@ -12,7 +10,6 @@ luarocks make cyan-dev-1.rockspec LUAROCKS=~/luarocks/bin export LUAROCKS popd -pushd docs -./generate_teal_declarations.sh ../teal_declarations -popd + +scripts/generate_teal_declarations.sh ./teal_declarations zip teal_declarations.zip -r teal_declarations diff --git a/docs/source/generate_luadoc.sh b/docs/source/generate_luadoc.sh index 7c8815e808..0c5a8e5a6a 100755 --- a/docs/source/generate_luadoc.sh +++ b/docs/source/generate_luadoc.sh @@ -7,7 +7,7 @@ DOCUMENTOR_PATH=~/.luarocks/bin/openmwluadocumentor if [ ! -x $DOCUMENTOR_PATH ]; then if [ -f /.dockerenv ] || [ -f /home/docs/omw_luadoc_docker ]; then - . install_luadocumentor_in_docker.sh + ./install_luadocumentor_in_docker.sh else # running on Windows? DOCUMENTOR_PATH="$APPDATA/LuaRocks/bin/openmwluadocumentor.bat" diff --git a/docs/generate_teal_declarations.sh b/scripts/generate_teal_declarations.sh similarity index 72% rename from docs/generate_teal_declarations.sh rename to scripts/generate_teal_declarations.sh index 99cf60416b..94f6ea125a 100755 --- a/docs/generate_teal_declarations.sh +++ b/scripts/generate_teal_declarations.sh @@ -4,13 +4,15 @@ if [ -z "$LUAROCKS" ]; then fi if [ -z "$1" ]; then - echo "Takes an absolute path to the output directory as the argument" + echo "Takes a path to the output directory as the argument" exit fi -DOCS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -FILES_DIR=$(realpath $DOCS_DIR/../files) -OUTPUT_DIR=$1 +SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +OPENMW_DIR=$(realpath $SCRIPTS_DIR/..) +DOCS_DIR=$(realpath $OPENMW_DIR/docs) +FILES_DIR=$(realpath $OPENMW_DIR/files) +OUTPUT_DIR=$(realpath "$1") DOCUMENTOR_PATH=$LUAROCKS/openmwluadocumentor TEAL_PATH=$LUAROCKS/cyan From 7a7fd128aad8d437d93985dd33a94a464616b028 Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 11 Feb 2023 12:17:44 +0100 Subject: [PATCH 10/12] Revert formatting .gitlab-ci.yml --- .gitlab-ci.yml | 189 +++++++++++++++++++++++++------------------------ 1 file changed, 95 insertions(+), 94 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 16d668a863..be4b18ca89 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,8 +28,8 @@ variables: extends: .Ubuntu_Image cache: paths: - - apt-cache/ - - ccache/ + - apt-cache/ + - ccache/ stage: build variables: CMAKE_EXE_LINKER_FLAGS: -fuse-ld=mold @@ -74,8 +74,8 @@ Coverity: cache: key: Coverity.ubuntu_20.04.v1 paths: - - apt-cache/ - - ccache/ + - apt-cache/ + - ccache/ variables: CCACHE_SIZE: 2G CC: clang-11 @@ -119,7 +119,7 @@ Ubuntu_GCC: CCACHE_SIZE: 4G # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. timeout: 2h - + Clang_Format: extends: .Ubuntu_Image stage: checks @@ -389,9 +389,9 @@ Ubuntu_Clang_integration_tests: - $CI_PROJECT_ID == "7107382" cache: paths: - - ccache/ + - ccache/ script: - - rm -fr build # remove the build directory + - rm -fr build # remove the build directory - CI/before_install.osx.sh - export CCACHE_BASEDIR="$(pwd)" - export CCACHE_DIR="$(pwd)/ccache" @@ -420,29 +420,29 @@ macOS12_Xcode13: rules: - if: $CI_PIPELINE_SOURCE == "push" before_script: - - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" - - choco source add -n=openmw-proxy -s="https://repo.openmw.org/repository/Chocolatey/" --priority=1 - - choco source disable -n=chocolatey - - choco install git --force --params "/GitAndUnixToolsOnPath" -y - - choco install 7zip -y - - choco install ccache -y - - choco install cmake.install --installargs 'ADD_CMAKE_TO_PATH=System' -y - - choco install vswhere -y - - choco install ninja -y - - choco install python -y - - refreshenv - - | - function Make-SafeFileName { - param( - [Parameter(Mandatory=$true)] - [String] - $FileName - ) - [IO.Path]::GetInvalidFileNameChars() | ForEach-Object { - $FileName = $FileName.Replace($_, '_') - } - return $FileName + - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" + - choco source add -n=openmw-proxy -s="https://repo.openmw.org/repository/Chocolatey/" --priority=1 + - choco source disable -n=chocolatey + - choco install git --force --params "/GitAndUnixToolsOnPath" -y + - choco install 7zip -y + - choco install ccache -y + - choco install cmake.install --installargs 'ADD_CMAKE_TO_PATH=System' -y + - choco install vswhere -y + - choco install ninja -y + - choco install python -y + - refreshenv + - | + function Make-SafeFileName { + param( + [Parameter(Mandatory=$true)] + [String] + $FileName + ) + [IO.Path]::GetInvalidFileNameChars() | ForEach-Object { + $FileName = $FileName.Replace($_, '_') } + return $FileName + } stage: build script: - $time = (Get-Date -Format "HH:mm:ss") @@ -471,22 +471,22 @@ macOS12_Xcode13: cache: key: ninja-v5 paths: - - ccache - - deps - - MSVC2019_64_Ninja/deps/Qt + - ccache + - deps + - MSVC2019_64_Ninja/deps/Qt artifacts: when: always paths: - - "*.zip" - - "*.log" - - MSVC2019_64_Ninja/*.log - - MSVC2019_64_Ninja/*/*.log - - MSVC2019_64_Ninja/*/*/*.log - - MSVC2019_64_Ninja/*/*/*/*.log - - MSVC2019_64_Ninja/*/*/*/*/*.log - - MSVC2019_64_Ninja/*/*/*/*/*/*.log - - MSVC2019_64_Ninja/*/*/*/*/*/*/*.log - - MSVC2019_64_Ninja/*/*/*/*/*/*/*/*.log + - "*.zip" + - "*.log" + - MSVC2019_64_Ninja/*.log + - MSVC2019_64_Ninja/*/*.log + - MSVC2019_64_Ninja/*/*/*.log + - MSVC2019_64_Ninja/*/*/*/*.log + - MSVC2019_64_Ninja/*/*/*/*/*.log + - MSVC2019_64_Ninja/*/*/*/*/*/*.log + - MSVC2019_64_Ninja/*/*/*/*/*/*/*.log + - MSVC2019_64_Ninja/*/*/*/*/*/*/*/*.log # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. timeout: 2h @@ -523,28 +523,28 @@ macOS12_Xcode13: rules: - if: $CI_PIPELINE_SOURCE == "push" before_script: - - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" - - choco source add -n=openmw-proxy -s="https://repo.openmw.org/repository/Chocolatey/" --priority=1 - - choco source disable -n=chocolatey - - choco install git --force --params "/GitAndUnixToolsOnPath" -y - - choco install 7zip -y - - choco install ccache -y - - choco install cmake.install --installargs 'ADD_CMAKE_TO_PATH=System' -y - - choco install vswhere -y - - choco install python -y - - refreshenv - - | - function Make-SafeFileName { - param( - [Parameter(Mandatory=$true)] - [String] - $FileName - ) - [IO.Path]::GetInvalidFileNameChars() | ForEach-Object { - $FileName = $FileName.Replace($_, '_') - } - return $FileName + - Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" + - choco source add -n=openmw-proxy -s="https://repo.openmw.org/repository/Chocolatey/" --priority=1 + - choco source disable -n=chocolatey + - choco install git --force --params "/GitAndUnixToolsOnPath" -y + - choco install 7zip -y + - choco install ccache -y + - choco install cmake.install --installargs 'ADD_CMAKE_TO_PATH=System' -y + - choco install vswhere -y + - choco install python -y + - refreshenv + - | + function Make-SafeFileName { + param( + [Parameter(Mandatory=$true)] + [String] + $FileName + ) + [IO.Path]::GetInvalidFileNameChars() | ForEach-Object { + $FileName = $FileName.Replace($_, '_') } + return $FileName + } stage: build script: - $time = (Get-Date -Format "HH:mm:ss") @@ -572,22 +572,22 @@ macOS12_Xcode13: cache: key: msbuild-v5 paths: - - ccache - - deps - - MSVC2019_64/deps/Qt + - ccache + - deps + - MSVC2019_64/deps/Qt artifacts: when: always paths: - - "*.zip" - - "*.log" - - MSVC2019_64/*.log - - MSVC2019_64/*/*.log - - MSVC2019_64/*/*/*.log - - MSVC2019_64/*/*/*/*.log - - MSVC2019_64/*/*/*/*/*.log - - MSVC2019_64/*/*/*/*/*/*.log - - MSVC2019_64/*/*/*/*/*/*/*.log - - MSVC2019_64/*/*/*/*/*/*/*/*.log + - "*.zip" + - "*.log" + - MSVC2019_64/*.log + - MSVC2019_64/*/*.log + - MSVC2019_64/*/*/*.log + - MSVC2019_64/*/*/*/*.log + - MSVC2019_64/*/*/*/*/*.log + - MSVC2019_64/*/*/*/*/*/*.log + - MSVC2019_64/*/*/*/*/*/*/*.log + - MSVC2019_64/*/*/*/*/*/*/*/*.log # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. timeout: 2h @@ -621,6 +621,7 @@ Windows_MSBuild_RelWithDebInfo: - if: $CI_PIPELINE_SOURCE == "push" - if: $CI_PIPELINE_SOURCE == "schedule" + .Ubuntu_AndroidNDK_arm64-v8a: tags: - linux @@ -681,21 +682,21 @@ Windows_MSBuild_RelWithDebInfo: - scripts/find_missing_merge_requests.py --project_id=$CI_PROJECT_ID --ignored_mrs_path=$CI_PROJECT_DIR/.resubmitted_merge_requests.txt .flatpak: - image: "docker.io/bilelmoussaoui/flatpak-github-actions" - stage: build - script: - - flatpak install -y flathub org.kde.Platform/x86_64/5.15-21.08 - - flatpak install -y flathub org.kde.Sdk/x86_64/5.15-21.08 - - flatpak-builder --ccache --force-clean --repo=repo build CI/org.openmw.OpenMW.devel.yaml - - flatpak build-bundle ./repo openmw.flatpak org.openmw.OpenMW.devel - cache: - key: flatpak - paths: - - ".flatpak-builder" - artifacts: - untracked: false - paths: - - "openmw.flatpak" - # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. - # Flatpak Builds compile all dependencies aswell so need more time. Build results of libraries are cached - timeout: 4h + image: 'docker.io/bilelmoussaoui/flatpak-github-actions' + stage: build + script: + - flatpak install -y flathub org.kde.Platform/x86_64/5.15-21.08 + - flatpak install -y flathub org.kde.Sdk/x86_64/5.15-21.08 + - flatpak-builder --ccache --force-clean --repo=repo build CI/org.openmw.OpenMW.devel.yaml + - flatpak build-bundle ./repo openmw.flatpak org.openmw.OpenMW.devel + cache: + key: flatpak + paths: + - ".flatpak-builder" + artifacts: + untracked: false + paths: + - "openmw.flatpak" + # When CCache doesn't exist (e.g. first build on a fork), build takes more than 1h, which is the default for forks. + # Flatpak Builds compile all dependencies aswell so need more time. Build results of libraries are cached + timeout: 4h From 463dcdb61080a35074b48a1576cc66cf97dc060c Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 11 Feb 2023 14:13:49 +0100 Subject: [PATCH 11/12] Use fixed openmwluadocumentor commit --- docs/source/install_luadocumentor_in_docker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/install_luadocumentor_in_docker.sh b/docs/source/install_luadocumentor_in_docker.sh index d65e25f85c..a1ec253600 100755 --- a/docs/source/install_luadocumentor_in_docker.sh +++ b/docs/source/install_luadocumentor_in_docker.sh @@ -28,6 +28,7 @@ PATH=$PATH:~/luarocks/bin echo "Install openmwluadocumentor" git clone https://gitlab.com/ptmikheev/openmw-luadocumentor.git +git checkout 78577b255d19a1f4f4f539662e00357936b73c33 cd openmw-luadocumentor luarocks make luarocks/openmwluadocumentor-0.2.0-1.rockspec cd ~ From b883cc5a1bbed587c0cfae118c065cec9a257217 Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 11 Feb 2023 14:31:28 +0100 Subject: [PATCH 12/12] Move the Teal docs page out of Overview --- docs/source/reference/lua-scripting/index.rst | 1 + docs/source/reference/lua-scripting/overview.rst | 8 ++------ docs/source/reference/lua-scripting/teal.rst | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/source/reference/lua-scripting/index.rst b/docs/source/reference/lua-scripting/index.rst index 75157982c9..c6adfc7723 100644 --- a/docs/source/reference/lua-scripting/index.rst +++ b/docs/source/reference/lua-scripting/index.rst @@ -12,4 +12,5 @@ OpenMW Lua scripting overview api + teal diff --git a/docs/source/reference/lua-scripting/overview.rst b/docs/source/reference/lua-scripting/overview.rst index 44c48d2742..36334492a7 100644 --- a/docs/source/reference/lua-scripting/overview.rst +++ b/docs/source/reference/lua-scripting/overview.rst @@ -1,18 +1,14 @@ Overview of Lua scripting ######################### -.. toctree:: - :hidden: - - teal - Language and sandboxing ======================= OpenMW supports scripts written in Lua 5.1 with some extensions (see below) from Lua 5.2. There are no plans to switch to any newer version of the language, because newer versions are not supported by LuaJIT. -There are also experimental declarations available for Teal, a typed dialect of Lua. see :ref:`Teal` for more details. +.. note:: + There are also experimental declarations available for Teal, a typed dialect of Lua. see :ref:`Teal` for more details. Here are some starting points for learning Lua: diff --git a/docs/source/reference/lua-scripting/teal.rst b/docs/source/reference/lua-scripting/teal.rst index 4ba4f2d507..7808210807 100644 --- a/docs/source/reference/lua-scripting/teal.rst +++ b/docs/source/reference/lua-scripting/teal.rst @@ -1,3 +1,4 @@ +#### Teal ####