Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: 使用xmake来管理依赖 #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ hades
kys-c++
.vscode

.xmake/
/build/
compile_commands.json
13 changes: 13 additions & 0 deletions repo/packages/l/libass/patches/0.16.0/fix_inc_fribidi.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/libass/ass_shaper.h b/libass/ass_shaper.h
index 66bfed0..c31e72a 100644
--- a/libass/ass_shaper.h
+++ b/libass/ass_shaper.h
@@ -21,7 +21,7 @@

typedef struct ass_shaper ASS_Shaper;

-#include <fribidi.h>
+#include <fribidi/fribidi.h>
#include <stdbool.h>
#include "ass_render.h"

1 change: 1 addition & 0 deletions repo/packages/l/libass/port/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define CONFIG_SOURCEVERSION "tarball: ${GIT_TAG}"
29 changes: 29 additions & 0 deletions repo/packages/l/libass/port/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
add_rules("mode.debug", "mode.release")

set_languages("ansi")

set_warnings("all", "warning")

add_requires("freetype", "fribidi", "harfbuzz")
if is_plat("linux") then
add_requires("fontconfig")
end

target("ass")
set_kind("$(kind)")
add_files("libass/*.c|*ass_coretext.c|*ass_fontconfig.c|*ass_directwrite.c")
if is_plat("windows") then
add_files("libass/*ass_directwrite.c")
elseif is_plat("macosx") then
add_files("libass/*ass_coretext.c")
else
add_files("libass/*ass_fontconfig.c")
end
add_headerfiles("libass/ass.h", "libass/ass_types.h", {prefixdir = "ass"})
add_configfiles("config.h.in")
set_configdir("$(buildir)/config")
add_includedirs("$(buildir)/config")
add_packages("freetype", "fribidi", "harfbuzz")
if is_plat("linux") then
add_packages("fontconfig")
end
23 changes: 23 additions & 0 deletions repo/packages/l/libass/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package("libass")

set_homepage("https://github.com/libass/libass")
set_description("libass is a portable subtitle renderer for the ASS/SSA subtitle format.")
set_license("ISC")

set_urls("https://github.com/libass/libass/archive/$(version).tar.gz",
"https://github.com/libass/libass.git")

add_versions("0.16.0", "246091cf034b097dbe362c72170e6996f8d2c19ffe664ce6768ec44eb9ca5c1c")
add_patches("0.16.0", path.join(os.scriptdir(), "patches", "0.16.0", "fix_inc_fribidi.patch"), "9e777779aa548a9e345dee2782a6eb77cc0ccc8371f6d00c1fac35a1ae367db9")

add_deps("freetype", "fribidi", "harfbuzz")
if is_plat("linux") then
add_deps("fontconfig")
end

on_install(function (package)
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
os.cp(path.join(package:scriptdir(), "port", "config.h.in"), "config.h.in")
local configs = {}
import("package.tools.xmake").install(package, configs)
end)
15 changes: 15 additions & 0 deletions repo/packages/m/mlcc/port/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
add_rules("mode.debug", "mode.release")

set_languages("cxx14")

set_warnings("all", "warning")

add_requires("libiconv")

target("mlcc")
set_kind("static")
set_kind("$(kind)")
-- XXX: for smallpot(contains PotConv)
add_files("*.cpp|PotConv.cpp")
add_headerfiles("*.h|PotConv.h")
add_packages("libiconv")
15 changes: 15 additions & 0 deletions repo/packages/m/mlcc/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package("mlcc")

set_homepage("https://github.com/scarsty/mlcc.git")
set_description("mlcc utils")
set_license("Unknown")

set_urls("https://github.com/scarsty/mlcc.git")

add_deps("libiconv")

on_install(function (package)
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
local configs = {}
import("package.tools.xmake").install(package, configs)
end)
12 changes: 12 additions & 0 deletions repo/packages/p/picosha2/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package("picosha2")

set_kind("library", {headeronly = true})
set_homepage("https://github.com/okdshin/PicoSHA2")
set_description("header-file-only, SHA256 hash generator in C++")
set_license("MIT")

add_urls("https://github.com/okdshin/PicoSHA2.git")

on_install(function (package)
os.cp("picosha2.h", package:installdir("include"))
end)
24 changes: 24 additions & 0 deletions repo/packages/s/smallpot/patches/ffmpeg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/src/PotStream.cpp b/src/PotStream.cpp
index e59667e..06955c5 100644
--- a/src/PotStream.cpp
+++ b/src/PotStream.cpp
@@ -37,10 +37,10 @@ int PotStream::openFile(const std::string& filename)
time_base_packet_ = 1e3 * av_q2d(stream_->time_base);
total_time_ = format_ctx_->duration * 1e3 / AV_TIME_BASE;
start_time_ = format_ctx_->start_time * 1e3 / AV_TIME_BASE;
- codec_ = avcodec_find_decoder(stream_->codecpar->codec_id);
+ codec_ = (AVCodec *)avcodec_find_decoder(stream_->codecpar->codec_id);
codec_ctx_ = avcodec_alloc_context3(codec_);
avcodec_parameters_to_context(codec_ctx_, stream_->codecpar);
- av_codec_set_pkt_timebase(codec_ctx_, stream_->time_base);
+ // av_codec_set_pkt_timebase(codec_ctx_, stream_->time_base);
//codec_ctx_ = stream_->codec;
avcodec_open2(codec_ctx_, codec_, nullptr);

@@ -436,4 +436,4 @@ void PotStream::getRatio(int& x, int& y)
// }
// }
// }
-//}
\ No newline at end of file
+//}
43 changes: 43 additions & 0 deletions repo/packages/s/smallpot/port/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
add_rules("mode.debug", "mode.release")

add_repositories("local-repo repo")

set_languages("cxx14")

set_warnings("all", "warning")

-- add_requireconfs("*", {build = true})

add_requires("libsdl", "libsdl_ttf", "libsdl_image")
add_requires("ffmpeg")
add_requires("libass")

add_requires("mlcc 9a69cfdf86927bd269f8bbc812d68062a976dc73")

target("libsmallpot")
set_kind("$(kind)")
set_basename("smallpot")
add_files("src/*.cpp|pot.cpp|Engine.cpp")
add_files("src/others/*.cpp")
add_includedirs("src/others")
add_headerfiles("src/PotDll.h")
if is_plat("windows") then
add_defines("_WINDLL")
add_cxflags("/utf-8")
end
add_packages("libsdl", "libsdl_ttf", "libsdl_image", "libsdl_mixer")
add_packages("ffmpeg")
add_packages("libass")
add_packages("mlcc")

-- target("smallpot")
-- add_files("src/*.cpp")
-- add_files("src/others/*.cpp")
-- add_includedirs("src/others")
-- if is_plat("windows") then
-- add_cxflags("/utf-8")
-- end
-- add_packages("libsdl", "libsdl_ttf", "libsdl_image", "libsdl_mixer")
-- add_packages("ffmpeg")
-- add_packages("libass")
-- add_packages("mlcc")
22 changes: 22 additions & 0 deletions repo/packages/s/smallpot/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package("smallpot")

set_homepage("https://github.com/scarsty/smallpot")
set_description("小水壶播放器:一个轻量级播放器")
set_license("MIT")

add_urls("https://github.com/scarsty/smallpot.git")

add_patches("master", path.join(os.scriptdir(), "patches", "ffmpeg.patch"), "99fdb9358f8a10161e43d9d7c23006f722c8d3f72a56003f686a53650257155d")

add_deps("libsdl", "libsdl_ttf", "libsdl_image")
add_deps("ffmpeg")
add_deps("libass")
add_deps("mlcc 9a69cfdf86927bd269f8bbc812d68062a976dc73")

add_defines("_WINDLL")

on_install(function (package)
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
local configs = {}
import("package.tools.xmake").install(package, configs)
end)
10 changes: 5 additions & 5 deletions src/Script.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once
#include "FunctionTrait.h"
#ifdef _WIN32
#include "lua.hpp"
#else
#include "lua5.3/lua.hpp"
#endif
extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
#include <string>
#include <array>
#include <type_traits>
Expand Down
64 changes: 64 additions & 0 deletions xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
add_rules("mode.debug", "mode.release")

add_repositories("local-repo repo")

set_languages("cxx20")

set_warnings("all", "warning")

option("audio")
set_default("sdl")
set_values("sdl", "bass")
option_end()

option("bass-dir")
set_default("")
option_end()

option("bassmidi-dir")
set_default("")
option_end()

if is_plat("windows") then
add_defines("NOMINMAX")
add_defines("_CRT_SECURE_NO_WARNINGS")
end

add_requires("libsdl", "libsdl_ttf", "libsdl_image")
if get_config("audio") == "sdl" then
add_requires("libsdl_mixer")
end
add_requires("lua")
add_requires("opencc")
add_requires("sqlite3")
add_requires("libiconv")
add_requires("asio")
add_requires("yaml-cpp")
add_requires("libzip")
add_requires("picosha2")

-- add_requires("smallpot")

target("kys")
add_files("src/*.cpp")
add_files("mlcc/strfunc.cpp")
add_files("mlcc/filefunc.cpp")
add_files("mlcc/PotConv.cpp")
add_files("others/Hanz2Piny.cpp")
add_includedirs("mlcc", "others", "local/include")
if is_plat("windows") then
add_cxflags("/utf-8")
end
add_packages("libsdl", "libsdl_ttf", "libsdl_image")
add_packages("lua", "opencc", "sqlite3", "libiconv", "asio", "picosha2", "yaml-cpp", "libzip")
if get_config("audio") == "sdl" then
add_defines("USE_SDL_MIXER_AUDIO")
add_packages("libsdl_mixer")
else
add_links("bass", "bassmidi")
add_includedirs("$(bass-dir)/c", "$(bassmidi-dir)/c")
add_linkdirs("$(bass-dir)/c/x64", "$(bassmidi-dir)/c/x64")
add_runenvs("PATH", "$(bass-dir)/x64", "$(bassmidi-dir)/x64")
end
-- add_defines("WITH_SMALLPOT")
-- add_packages("smallpot")