Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/AllayMC/DataExtractor
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolLoong committed Dec 18, 2023
2 parents 7bfb145 + 4036955 commit 66d3799
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 2 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
on:
push:
branches:
- master
- dev
paths:
- .github/workflows/build.yml
- scripts/localbdslibrary.lua
- src/**
- xmake.lua
pull_request:
branches:
- master
- dev
paths:
- .github/workflows/build.yml
- scripts/localbdslibrary.lua
- src/**
- xmake.lua
workflow_dispatch:

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Read bdsversion file
id: read-bdsversion
run: |
$content = Get-Content -Path .\bdsversion -Raw
$type = ($content | Select-String -Pattern 'type=(.*)' | ForEach-Object { $_.Matches.Groups[1].Value }).Trim()
$version = ($content | Select-String -Pattern 'version=(.*)' | ForEach-Object { $_.Matches.Groups[1].Value }).Trim()
echo "::set-output name=version_type::$type"
echo "::set-output name=version_number::$version"
printf '%s\n' "$type"
printf '%s\n' "$version"
- uses: xmake-io/github-action-setup-xmake@v1

- uses: actions/cache@v3
name: xmake cache
with:
path: |
~/AppData/Local/.xmake
.xmake
build/bds/lib
key: |
xmake-dataextractor-windows-x64-${{ github.sha }}
restore-keys: |
xmake-dataextractor-windows-x64-
- uses: actions/cache@v3
name: bdslib cache
with:
path: |
build/bds/lib
key: |
bdslib-${{ steps.read-bdsversion.outputs.version_type }}-${{ steps.read-bdsversion.outputs.version_number }}
- run: |
xmake repo -u
- run: |
xmake bds-lib -b --${{ steps.read-bdsversion.outputs.version_type }}=${{ steps.read-bdsversion.outputs.version_number }}
- run: |
xmake f -a x64 -m release -p windows -v -y --ccache=n
- run: |
xmake -w -y
- uses: actions/upload-artifact@v3
with:
name: DataExtractor-Windows-X64-${{ github.sha }}
path: |
build/windows/x64/release/DataExtractor.dll
build/windows/x64/release/DataExtractor.pdb
2 changes: 2 additions & 0 deletions bdsversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type=release
version=1.20.50.03
55 changes: 53 additions & 2 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ target("DataExtractor")
task("bds-lib")
on_run(function ()
import("core.base.option")
local actions = {"remote", "local", "clean", "tool"}
local actions = {"remote", "local", "clean", "tool", "bdsversion"}
-- error if multiple actions are specified or no action is specified
local action = nil
for _, a in ipairs(actions) do
Expand Down Expand Up @@ -93,6 +93,54 @@ task("bds-lib")
local tool_dir = path.join(config.buildir(), "tools")
os.rm(tool_dir)
print("[localbdslibrary] Toolchain has been cleared.")
elseif action == "bdsversion" then
import("utils.archive")
import("core.project.config")
import("net.http")

local pe_editor_version = "v3.3.0"
local lib_path = path.join(config.buildir(), "bds", "lib")
local bedrock_server_api = path.join(lib_path, "bedrock_server_api.lib")
local bedrock_server_var = path.join(lib_path, "bedrock_server_var.lib")
if os.isfile(bedrock_server_api) and os.isfile(bedrock_server_var) then
print("[localbdslibrary] Local bds library found, skipping generation")
return
end

local release_ver = "1.20.50.03"
local tools_path = path.join(config.buildir(), "tools", "PeEditor-" .. pe_editor_version .. ".exe")
if not os.isfile(tools_path) then
-- not found, download it
print("[localbdslibrary] Downloading PeEditor.exe...")
http.download("https://github.com/LiteLDev/PeEditor/releases/download/" .. pe_editor_version .. "/PeEditor.exe", tools_path)
if not os.isfile(tools_path) then
raise("[localbdslibrary] Failed to download PeEditor.exe")
end
print("[localbdslibrary] PeEditor.exe downloaded successfully")
end
local url = nil
local bds_path = nil
if option.get("release") then
url = "https://minecraft.azureedge.net/bin-win/bedrock-server-".. option.get("release") ..".zip"
bds_path = path.join(config.buildir(), "bds" , "instance" , "bedrock-server-".. option.get("release") ..".zip")
elseif option.get("preview") then
url = "https://minecraft.azureedge.net/bin-win-preview/bedrock-server-".. option.get("preview") ..".zip"
bds_path = path.join(config.buildir(), "bds" , "instance" , "bedrock-server-".. option.get("preview") ..".zip")
else
raise("[localbdslibrary] Failed to set bedrock version")
end
print("[localbdslibrary] Downloading bedrock_server...")
http.download(url, bds_path)
if not os.isfile(bds_path) then
raise("[localbdslibrary] Failed to download bedrock_server")
end
print("[localbdslibrary] bedrock_server downloaded successfully")
local unzip_path = path.join(config.buildir(), "bds" , "instance")
archive.extract(bds_path, unzip_path)
if not os.exists(lib_path) then
os.mkdir(lib_path)
end
os.vexec("%s -l -o %s --pdb %s", tools_path, lib_path , path.join(unzip_path, "bedrock_server.pdb"))
end
end)

Expand All @@ -103,6 +151,9 @@ task("bds-lib")
{'r', "remote", "k", nil, "Use remote BDS library"},
{'l', "local", "k", nil, "Use local BDS library"},
{'c', "clean", "k", nil, "Clean local BDS library"},
{'t', "tool", "k", nil, "Remove toolchain"}
{'t', "tool", "k", nil, "Remove toolchain"},
{'b', "bdsversion", "k", nil, "From specified bdsversion to install BDS library"},
{nil, "release", "kv", "1.20.50.03", "choose release version"},
{nil, "preview", "kv", "1.20.60.22", "choose preview version"}
}
}

0 comments on commit 66d3799

Please sign in to comment.