Skip to content

Commit

Permalink
[48_14] Separate research from xmake.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii authored Oct 5, 2023
1 parent 73a21da commit 5e0ce6b
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 234 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci-xmake-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ on:
- 'src/**'
- '!src/Plugins/Windows/**'
- 'tests/**'
- 'misc/xmake/packages.lua'
- 'xmake.lua'
- 'xmake/packages.lua'
- 'xmake/research.lua'
- '.github/workflows/ci-xmake-macos.yml'
pull_request:
branches: [ branch-1.2 ]
paths:
- 'src/**'
- '!src/Plugins/Windows/**'
- 'tests/**'
- 'misc/xmake/packages.lua'
- 'xmake.lua'
- 'xmake/packages.lua'
- 'xmake/research.lua'
- '.github/workflows/ci-xmake-macos.yml'

jobs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-xmake-mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- 'tests/**'
- 'xmake.lua'
- 'xmake/packages.lua'
- 'xmake/research.lua'
- '.github/workflows/ci-xmake-mingw.yml'
pull_request:
branches: [ branch-1.2 ]
Expand All @@ -20,6 +21,7 @@ on:
- 'tests/**'
- 'xmake.lua'
- 'xmake/packages.lua'
- 'xmake/research.lua'
- '.github/workflows/ci-xmake-mingw.yml'
workflow_dispatch:

Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/ci-xmake-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ on:
- '!src/Plugins/Macos/**'
- '!src/Plugins/Windows/**'
- 'tests/**'
- 'misc/xmake/packages.lua'
- 'xmake.lua'
- '.github/workflows/ci-xmake-ubuntu.yml'
- 'xmake.lua'
- 'xmake/packages.lua'
- 'xmake/research.lua'
pull_request:
branches: [ branch-1.2 ]
paths:
- 'src/**'
- '!src/Plugins/Macos/**'
- '!src/Plugins/Windows/**'
- 'tests/**'
- 'misc/xmake/packages.lua'
- 'xmake.lua'
- '.github/workflows/ci-xmake-ubuntu.yml'
- 'xmake.lua'
- 'xmake/packages.lua'
- 'xmake/research.lua'

jobs:
linuxbuild:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-xmake-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- 'tests/**'
- 'xmake.lua'
- 'xmake/packages.lua'
- 'xmake/research.lua'
- '.github/workflows/ci-xmake-windows.yml'
pull_request:
branches: [ branch-1.2 ]
Expand All @@ -20,6 +21,7 @@ on:
- 'tests/**'
- 'xmake.lua'
- 'xmake/packages.lua'
- 'xmake/research.lua'
- '.github/workflows/ci-xmake-windows.yml'
workflow_dispatch:

Expand Down
246 changes: 18 additions & 228 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,6 @@ end
set_allowedmodes("releasedbg", "release", "debug")
add_rules("mode.releasedbg", "mode.release", "mode.debug")

--
-- global variables in configurations domain
--
local TeXmacs_files = {
"TeXmacs(/doc/**)",
"TeXmacs(/examples/**)",
"TeXmacs(/fonts/**)",
"TeXmacs(/langs/**)",
"TeXmacs(/misc/**)",
"TeXmacs(/packages/**)",
"TeXmacs(/progs/**)",
"TeXmacs(/styles/**)",
"TeXmacs(/texts/**)",
"TeXmacs/COPYING", -- copying files are different
"TeXmacs/INSTALL",
"LICENSE", -- license files are same
"TeXmacs/README",
"TeXmacs/TEX_FONTS",
"TeXmacs(/plugins/**)" -- plugin files
}

--
-- Add packages from xrepo or platform package manager
--
Expand Down Expand Up @@ -630,218 +609,29 @@ if is_plat("wasm", "linux") then
end
end


function add_target_research_on_wasm()
set_languages("c++17")
set_version(XMACS_VERSION, {build = "%Y-%m-%d"})

build_glue_on_config()
add_tm_configure("research", TM_CONFIGURE_VARS)
add_configfiles("src/System/config.h.xmake", {
filename = "research/config.h",
variables = {
MACOSX_EXTENSIONS = is_plat("macosx"),
USE_PLUGIN_PDF = false,
USE_PLUGIN_BIBTEX = true,
USE_PLUGIN_LATEX_PREVIEW = false,
USE_PLUGIN_TEX = true,
USE_PLUGIN_ISPELL = true,
NOMINMAX = is_plat("windows"),
SIZEOF_VOID_P = 8,
USE_FONTCONFIG = is_plat("linux"),
USE_STACK_TRACE = (not is_plat("mingw")) and (not is_plat("wasm")) and (not is_plat("windows")),
USE_GS = not is_plat("wasm"),
GS_FONTS = "../share/ghostscript/fonts:/usr/share/fonts:",
GS_LIB = "../share/ghostscript/9.06/lib:",
GS_EXE = "",
USE_FREETYPE = true,
USE_ICONV = true,
}
})

add_packages("lolly")
add_packages("freetype")
add_packages("s7")
add_rules("qt.widgetapp_static")
add_frameworks("QtGui", "QtWidgets", "QtCore", "QtSvg", "QWasmIntegrationPlugin")

add_includedirs(libmogan_headers, {public = true})
add_includedirs("$(buildir)/research")
add_files(libmogan_srcs)
add_files(plugin_qt_srcs_on_wasm)
add_files(plugin_bibtex_srcs)
add_files(plugin_freetype_srcs)
add_files(plugin_database_srcs)
add_files(plugin_ispell_srcs)
add_files(plugin_metafont_srcs)
add_files(plugin_tex_srcs)
add_files(plugin_latex_preview_srcs)
add_files(plugin_openssl_srcs)
add_files(plugin_xml_srcs)
add_files("src/Mogan/Research/research.cpp")

add_ldflags("-s --preload-file $(projectdir)/TeXmacs@TeXmacs", {force = true})

before_build(function (target)
target:add("forceincludes", path.absolute("$(buildir)/research/config.h"))
target:add("forceincludes", path.absolute("$(buildir)/research/tm_configure.hpp"))
end)
end

function add_target_research_on_others()
set_version(XMACS_VERSION)
set_installdir(INSTALL_DIR)

if is_plat("macosx") then
set_filename("Mogan")
elseif is_plat("mingw", "windows") then
set_filename("mogan.exe")
else
set_filename("mogan")
end

if is_plat("windows") then
set_optimize("smallest");
end

if is_mode("debug", "releasedbg") and is_plat("mingw", "windows") then
add_rules("qt.console")
else
add_rules("qt.widgetapp")
end

add_frameworks("QtGui", "QtWidgets", "QtCore", "QtPrintSupport", "QtSvg")
if is_plat("macosx") then
add_frameworks("QtMacExtras")
end

add_packages("lolly")
if is_plat("mingw", "windows") then
add_packages("qt5widgets")
end

add_deps("libmogan")
add_includedirs({
"$(buildir)",
})
before_build(function (target)
target:add("forceincludes", path.absolute("$(buildir)/config.h"))
target:add("forceincludes", path.absolute("$(buildir)/tm_configure.hpp"))
end)
add_files("src/Mogan/Research/research.cpp")

if is_plat("linux") then
add_rpathdirs("@executable_path/../lib")
end
if not is_plat("windows") then
add_syslinks("pthread")
end

if is_plat("mingw") and is_mode("release") then
add_deps("windows_icon")
end

set_configdir(INSTALL_DIR)
set_configvar("DEVEL_VERSION", DEVEL_VERSION)
set_configvar("PACKAGE", "Mogan Research")
set_configvar("XMACS_VERSION", XMACS_VERSION)

-- install man.1 manual file
add_configfiles("(misc/man/texmacs.1.in)", {
filename = "texmacs.1",
pattern = "@([^\n]-)@",
})

-- package metadata
if is_plat("macosx") then
set_configvar("APPCAST", "")
set_configvar("OSXVERMIN", "")
add_configfiles("(packages/macos/Info.plist.in)", {
filename = "Info.plist",
pattern = "@(.-)@",
})
add_installfiles({
"packages/macos/Xmacs.icns",
"packages/macos/TeXmacs-document.icns",
"src/Plugins/Cocoa/(English.lproj/**)",
"src/Plugins/Cocoa/(zh_CN.lproj/**)",
"misc/scripts/mogan.sh"
})
elseif is_plat("linux") then
add_installfiles({
"misc/scripts/mogan"
})
end

-- install icons
add_installfiles("TeXmacs/misc/images/text-x-texmacs.svg", {prefixdir="share/icons/hicolor/scalable/mimetypes"})
add_installfiles("TeXmacs/misc/mime/texmacs.desktop", {prefixdir="share/applications"})
add_installfiles("TeXmacs/misc/mime/texmacs.xml", {prefixdir="share/mime/packages"})
add_installfiles("TeXmacs/misc/pixmaps/TeXmacs.xpm", {prefixdir="share/pixmaps"})

if is_plat("mingw", "windows") then
add_installfiles(TeXmacs_files)
else
add_installfiles("misc/scripts/tm_gs", {prefixdir="share/Xmacs/bin"})
add_installfiles(TeXmacs_files, {prefixdir="share/Xmacs"})
end

-- install tm files for testing purpose
if is_mode("releasedbg") then
if is_plat("mingw", "windows") then
add_installfiles({
"TeXmacs(/tests/*.tm)",
"TeXmacs(/tests/*.bib)",
})
else
add_installfiles({
"TeXmacs(/tests/*.tm)",
"TeXmacs(/tests/*.bib)",
}, {prefixdir="share/Xmacs"})
end
end

-- deploy necessary dll
if is_plat("windows") then
set_values("qt.deploy.flags", {"-printsupport"})
elseif is_plat("mingw") then
-- qt on mingw provides debug dll only, without "d" suffix.
set_values("qt.deploy.flags", {"-printsupport", "--debug"})
end

after_install(function (target)
print("after_install of target research")
import("xmake.global")
global.copy_icons(target)

if is_plat("macosx") and is_arch("arm64") then
local app_dir = target:installdir() .. "/../../"
os.rm(app_dir .. "Contents/Resources/include")
os.rm(app_dir .. "Contents/Frameworks/QtQmlModels.framework")
os.rm(app_dir .. "Contents/Frameworks/QtQml.framework")
os.rm(app_dir .. "Contents/Frameworks/QtQuick.framework")
os.execv("codesign", {"--force", "--deep", "--sign", "-", app_dir})
end
end)

on_run(function (target)
name = target:name()
if is_plat("mingw", "windows") then
os.execv(target:installdir().."/bin/mogan.exe")
elseif is_plat("linux", "macosx") then
print("Launching " .. target:targetfile())
os.execv(target:targetfile(), {}, {envs=RUN_ENVS})
else
print("Unsupported plat $(plat)")
end
end)
end

includes("xmake/research.lua")
target("research") do
set_version(XMACS_VERSION, {build = "%Y-%m-%d"})
if is_plat("wasm") then
add_tm_configure("research", TM_CONFIGURE_VARS)
add_target_research_on_wasm()
else
set_installdir(INSTALL_DIR)
set_configdir(INSTALL_DIR)
set_configvar("DEVEL_VERSION", DEVEL_VERSION)
set_configvar("XMACS_VERSION", XMACS_VERSION)
add_target_research_on_others()
on_run(function (target)
name = target:name()
if is_plat("mingw", "windows") then
os.execv(target:installdir().."/bin/mogan.exe")
elseif is_plat("linux", "macosx") then
print("Launching " .. target:targetfile())
os.execv(target:targetfile(), {}, {envs=RUN_ENVS})
else
print("Unsupported plat $(plat)")
end
end)
end
end

Expand Down
Loading

0 comments on commit 5e0ce6b

Please sign in to comment.