Compare commits
7 Commits
d9e2c19cd4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 4bbcde461d | |||
| cba15111e7 | |||
| 3bc95acf7b | |||
| 4986fd1940 | |||
| a7bc4abbae | |||
| 1d3d7b07a0 | |||
| a7fcaa95fe |
32
.gitea/workflows/linux.yml
Normal file
32
.gitea/workflows/linux.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Linux arm64
|
||||||
|
run-name: Build And Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Packages cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ github.workspace }}/build/.packages
|
||||||
|
key: ${{ runner.os }}-xmake_cache
|
||||||
|
|
||||||
|
- name: XMake config
|
||||||
|
run: xmake f -p linux -y
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: xmake
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: xmake test
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
This project is used to compile a GDExtension (godot engine cpp extension), and try to use xmake to manage the project.
|
This project is used to compile a GDExtension (godot engine cpp extension), and try to use xmake to manage the project.
|
||||||
|
|
||||||
|
Forked from [Github](https://github.com/chaosddp/gdextension-cpp-xmake-template)
|
||||||
|
|
||||||
## Install xmake
|
## Install xmake
|
||||||
|
|
||||||
Install xmake from [here](https://xmake.io/#/guide/installation).
|
Install xmake from [here](https://xmake.io/#/guide/installation).
|
||||||
@@ -57,4 +59,4 @@ xmake ext-class -n MySprite2D -b Sprite2D -s myexample1 -d sample
|
|||||||
|
|
||||||
For better support in vscode, you can use command "Xmake: UpdateIntellisense" to generate *compile_commands.json*, then update "compileCommands" field in *c_cpp_properties.json* to point to the file.
|
For better support in vscode, you can use command "Xmake: UpdateIntellisense" to generate *compile_commands.json*, then update "compileCommands" field in *c_cpp_properties.json* to point to the file.
|
||||||
|
|
||||||
NOTE: not tested on other platforms execept windows.
|
NOTE: not tested on other platforms except windows and linux.
|
||||||
@@ -18,4 +18,4 @@ GODOT_PROJECT_FOLDER = "demo"
|
|||||||
PUBLISH_FOLDER = "publish"
|
PUBLISH_FOLDER = "publish"
|
||||||
|
|
||||||
|
|
||||||
includes("godot.lua")
|
includes("xmake/godot.lua")
|
||||||
15
xmake/editor.lua
Normal file
15
xmake/editor.lua
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
target("Editor")
|
||||||
|
set_default(false)
|
||||||
|
|
||||||
|
-- Disable building
|
||||||
|
on_build((function() end))
|
||||||
|
|
||||||
|
on_run(
|
||||||
|
(function(godot_project_folder)
|
||||||
|
return function(target)
|
||||||
|
local project_file = path.join(godot_project_folder, "project.godot")
|
||||||
|
os.execv("echo", {"godot", project_file})
|
||||||
|
os.exec("godot " .. project_file)
|
||||||
|
end
|
||||||
|
end)(GODOT_PROJECT_FOLDER)
|
||||||
|
)
|
||||||
26
xmake/godot.lua
Normal file
26
xmake/godot.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
------- project settings -------
|
||||||
|
|
||||||
|
-- project name
|
||||||
|
set_project(PROJECT_NAME)
|
||||||
|
|
||||||
|
-- project version
|
||||||
|
set_version(VERSION)
|
||||||
|
|
||||||
|
-- min version of xmake we need to run
|
||||||
|
-- NOTE: this is the version i used to develop this template, may not 100% correct
|
||||||
|
set_xmakever("2.9.0")
|
||||||
|
|
||||||
|
add_rules("mode.debug", "mode.release")
|
||||||
|
|
||||||
|
-- c++17 is required for godot 4.x, we use c++20 here
|
||||||
|
set_languages("c++20")
|
||||||
|
|
||||||
|
-- use latest 4.x version by default
|
||||||
|
add_requires("godotcpp4")
|
||||||
|
|
||||||
|
|
||||||
|
includes("tasks.lua")
|
||||||
|
|
||||||
|
includes("target.lua")
|
||||||
|
|
||||||
|
includes("editor.lua")
|
||||||
72
xmake/target.lua
Normal file
72
xmake/target.lua
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
|
||||||
|
if is_mode("debug") then
|
||||||
|
add_defines("DEBUG_ENABLED")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- more on https://xmake.io/#/manual/project_target
|
||||||
|
target(PROJECT_NAME)
|
||||||
|
set_kind("shared")
|
||||||
|
set_default(true)
|
||||||
|
|
||||||
|
add_packages("godotcpp4")
|
||||||
|
|
||||||
|
-- more on https://xmake.io/#/manual/project_target?id=targetadd_files
|
||||||
|
add_files("../src/**.cpp")
|
||||||
|
|
||||||
|
-- change the output name
|
||||||
|
set_basename(PROJECT_NAME .. ".$(os)_$(mode)_$(arch)")
|
||||||
|
|
||||||
|
-- libraries will saved in os level folder
|
||||||
|
set_targetdir("../" .. GODOT_PROJECT_FOLDER .. "/lib")
|
||||||
|
|
||||||
|
-- where to save .obj files
|
||||||
|
-- we use a seprate folder, so that it will not populate the targer folder
|
||||||
|
set_objectdir("../build/.objs")
|
||||||
|
|
||||||
|
-- where .d files are saved
|
||||||
|
set_dependir("../build/.deps")
|
||||||
|
|
||||||
|
-- set_optimize("smallest")
|
||||||
|
|
||||||
|
-- handlers
|
||||||
|
|
||||||
|
-- before_run(function (target) end)
|
||||||
|
-- after_run(function (target) end)
|
||||||
|
-- before_build(function (target) end)
|
||||||
|
-- after_build(function (target) end)
|
||||||
|
-- before_clean(function (target) end)
|
||||||
|
-- after_clean(function (target) end)
|
||||||
|
|
||||||
|
on_run(
|
||||||
|
(function(godot_project_folder)
|
||||||
|
return function(target)
|
||||||
|
local cmd = format("godot --path %s", godot_project_folder)
|
||||||
|
os.execv("echo", {cmd})
|
||||||
|
os.exec(cmd)
|
||||||
|
end
|
||||||
|
end)(GODOT_PROJECT_FOLDER)
|
||||||
|
)
|
||||||
|
|
||||||
|
on_package(function(target)
|
||||||
|
import("core.base.task")
|
||||||
|
|
||||||
|
target_platform = "Unknown"
|
||||||
|
|
||||||
|
if is_plat("windows") then
|
||||||
|
target_platform = "Windows Desktop"
|
||||||
|
elseif is_plat("macosx") then
|
||||||
|
target_platform = "macOS"
|
||||||
|
elseif is_plat("linux") then
|
||||||
|
target_platform = "Linux/X11"
|
||||||
|
elseif is_plat("android") then
|
||||||
|
target_platform = "Android"
|
||||||
|
end
|
||||||
|
|
||||||
|
task.run("export", {}, target_platform)
|
||||||
|
end)
|
||||||
|
|
||||||
|
after_clean(function (target)
|
||||||
|
import("core.base.task")
|
||||||
|
task.run("clean-publish")
|
||||||
|
end)
|
||||||
@@ -1,27 +1,3 @@
|
|||||||
------- project settings -------
|
|
||||||
|
|
||||||
-- project name
|
|
||||||
set_project(PROJECT_NAME)
|
|
||||||
|
|
||||||
-- project version
|
|
||||||
set_version(VERSION)
|
|
||||||
|
|
||||||
-- min version of xmake we need to run
|
|
||||||
-- NOTE: this is the version i used to develop this template, may not 100% correct
|
|
||||||
set_xmakever("2.9.0")
|
|
||||||
|
|
||||||
add_rules("mode.debug", "mode.release")
|
|
||||||
|
|
||||||
-- c++17 is required for godot 4.x, we use c++20 here
|
|
||||||
set_languages("c++20")
|
|
||||||
|
|
||||||
-- use latest 4.x version by default
|
|
||||||
add_requires("godotcpp4")
|
|
||||||
|
|
||||||
|
|
||||||
------- custom tasks -------
|
|
||||||
|
|
||||||
|
|
||||||
-- NOTE:
|
-- NOTE:
|
||||||
-- xmake cannot accept the global variables in on_xxx functions, so we use a wrapper function to bind it
|
-- xmake cannot accept the global variables in on_xxx functions, so we use a wrapper function to bind it
|
||||||
|
|
||||||
@@ -30,7 +6,7 @@ add_requires("godotcpp4")
|
|||||||
-- target_platform: the target platform, like "Windows Desktop"
|
-- target_platform: the target platform, like "Windows Desktop"
|
||||||
-- name: the export execute name, it will be endswith ".exe" on windows
|
-- name: the export execute name, it will be endswith ".exe" on windows
|
||||||
task("export")
|
task("export")
|
||||||
on_run((function(godot_project_folder, publish_folder)
|
on_run((function(godot_project_folder, publish_folder, project_name)
|
||||||
return function(target_platform)
|
return function(target_platform)
|
||||||
local name = godot_project_folder
|
local name = godot_project_folder
|
||||||
|
|
||||||
@@ -59,13 +35,15 @@ task("export")
|
|||||||
|
|
||||||
local godot_project_file = path.join(godot_project_folder, "project.godot")
|
local godot_project_file = path.join(godot_project_folder, "project.godot")
|
||||||
|
|
||||||
local export_path = path.absolute(path.join(publish_folder, name))
|
local export_path = path.absolute(path.join(publish_folder, project_name))
|
||||||
|
|
||||||
os.execv("echo", {"godot", godot_project_file, export_mode, target_platform, export_path})
|
local cmd = format("godot %s --headless --%s %s %s", godot_project_file, export_mode, "\"" .. target_platform .. "\"", export_path)
|
||||||
os.exec("godot %s --headless --%s %s %s", godot_project_file, export_mode, "\"" .. target_platform .. "\"", export_path)
|
|
||||||
|
os.execv("echo", {cmd})
|
||||||
|
os.exec(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
end)(GODOT_PROJECT_FOLDER, PUBLISH_FOLDER))
|
end)(GODOT_PROJECT_FOLDER, PUBLISH_FOLDER, PROJECT_NAME))
|
||||||
task_end()
|
task_end()
|
||||||
|
|
||||||
|
|
||||||
@@ -228,88 +206,20 @@ android.release.arm64 = "res://lib/libProjectName.android_release_arm64.so"
|
|||||||
task_end()
|
task_end()
|
||||||
|
|
||||||
|
|
||||||
|
task("import-assets")
|
||||||
|
on_run((function(godot_project_folder, project_name)
|
||||||
|
return function ()
|
||||||
|
local godot_project_file = path.join(godot_project_folder, "project.godot")
|
||||||
|
|
||||||
|
local cmd = format("godot --headless --import %s", godot_project_file)
|
||||||
|
os.execv("echo", {cmd})
|
||||||
------- output settings -------
|
os.exec(cmd)
|
||||||
|
|
||||||
-- more on https://xmake.io/#/manual/project_target
|
|
||||||
target(PROJECT_NAME)
|
|
||||||
set_kind("shared")
|
|
||||||
set_default(true)
|
|
||||||
|
|
||||||
add_packages("godotcpp4")
|
|
||||||
|
|
||||||
-- more on https://xmake.io/#/manual/project_target?id=targetadd_files
|
|
||||||
add_files("src/*.cpp")
|
|
||||||
|
|
||||||
-- change the output name
|
|
||||||
set_basename(PROJECT_NAME .. ".$(os)_$(mode)_$(arch)")
|
|
||||||
|
|
||||||
-- libraries will saved in os level folder
|
|
||||||
set_targetdir(GODOT_PROJECT_FOLDER .. "/lib")
|
|
||||||
|
|
||||||
-- where to save .obj files
|
|
||||||
-- we use a seprate folder, so that it will not populate the targer folder
|
|
||||||
set_objectdir("build/.objs")
|
|
||||||
|
|
||||||
-- where .d files are saved
|
|
||||||
set_dependir("build/.deps")
|
|
||||||
|
|
||||||
-- set_optimize("smallest")
|
|
||||||
|
|
||||||
-- handlers
|
|
||||||
|
|
||||||
-- before_run(function (target) end)
|
|
||||||
-- after_run(function (target) end)
|
|
||||||
-- before_build(function (target) end)
|
|
||||||
-- after_build(function (target) end)
|
|
||||||
-- before_clean(function (target) end)
|
|
||||||
-- after_clean(function (target) end)
|
|
||||||
|
|
||||||
on_run(
|
|
||||||
(function(godot_project_folder)
|
|
||||||
return function(target)
|
|
||||||
os.execv("echo", {"godot --path", godot_project_folder})
|
|
||||||
os.exec("godot --path " .. godot_project_folder)
|
|
||||||
end
|
|
||||||
end)(GODOT_PROJECT_FOLDER)
|
|
||||||
)
|
|
||||||
|
|
||||||
on_package(function(target)
|
|
||||||
import("core.base.task")
|
|
||||||
|
|
||||||
target_platform = "Unknown"
|
|
||||||
|
|
||||||
if is_plat("windows") then
|
|
||||||
target_platform = "Windows Desktop"
|
|
||||||
elseif is_plat("macosx") then
|
|
||||||
target_platform = "macOS"
|
|
||||||
elseif is_plat("linux") then
|
|
||||||
target_platform = "Linux/X11"
|
|
||||||
elseif is_plat("android") then
|
|
||||||
target_platform = "Android"
|
|
||||||
end
|
end
|
||||||
|
end)(GODOT_PROJECT_FOLDER, PROJECT_NAME))
|
||||||
|
|
||||||
task.run("export", {}, target_platform)
|
set_menu {
|
||||||
end)
|
usage = "xmake import-assets",
|
||||||
|
|
||||||
after_clean(function (target)
|
description = "Import project assets",
|
||||||
import("core.base.task")
|
}
|
||||||
task.run("clean-publish")
|
task_end()
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
target("Editor")
|
|
||||||
set_default(false)
|
|
||||||
-- Disable building
|
|
||||||
on_build((function() end))
|
|
||||||
on_run(
|
|
||||||
(function(godot_project_folder)
|
|
||||||
return function(target)
|
|
||||||
local project_file = path.join(godot_project_folder, "project.godot")
|
|
||||||
os.execv("echo", {"godot", project_file})
|
|
||||||
os.exec("godot " .. project_file)
|
|
||||||
end
|
|
||||||
end)(GODOT_PROJECT_FOLDER)
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user