summaryrefslogtreecommitdiff
path: root/core/src/cli
diff options
context:
space:
mode:
authorruki <[email protected]>2024-09-24 23:22:20 +0800
committerruki <[email protected]>2024-09-24 23:22:20 +0800
commitc2294cfacd63067dbe3ec1f9cd43f4d85808219c (patch)
tree95d9bf5d048df8c261b0917ff43e3bb4f3c9842b /core/src/cli
parent583f8e6944130e157ec85b8a975a76733b3eb775 (diff)
rename demo to cli
Diffstat (limited to 'core/src/cli')
-rw-r--r--core/src/cli/xmake.c12
-rw-r--r--core/src/cli/xmake.icobin0 -> 119943 bytes
-rw-r--r--core/src/cli/xmake.lua90
-rw-r--r--core/src/cli/xmake.rc43
-rwxr-xr-xcore/src/cli/xmake.sh75
5 files changed, 220 insertions, 0 deletions
diff --git a/core/src/cli/xmake.c b/core/src/cli/xmake.c
new file mode 100644
index 000000000..82ed54e25
--- /dev/null
+++ b/core/src/cli/xmake.c
@@ -0,0 +1,12 @@
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "xmake/xmake.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * main
+ */
+tb_int_t main(tb_int_t argc, tb_char_t** argv)
+{
+ return xm_engine_run("xmake", argc, argv, tb_null, tb_null);
+}
diff --git a/core/src/cli/xmake.ico b/core/src/cli/xmake.ico
new file mode 100644
index 000000000..52c8ef389
--- /dev/null
+++ b/core/src/cli/xmake.ico
Binary files differ
diff --git a/core/src/cli/xmake.lua b/core/src/cli/xmake.lua
new file mode 100644
index 000000000..e093191a6
--- /dev/null
+++ b/core/src/cli/xmake.lua
@@ -0,0 +1,90 @@
+target("cli")
+
+ -- disable this target if only build libaries
+ if has_config("onlylib") then
+ set_default(false)
+ end
+
+ -- add deps
+ add_deps("xmake")
+
+ -- make as a binary
+ set_kind("binary")
+ set_basename("xmake")
+ set_targetdir("$(buildir)")
+
+ -- add definitions
+ add_defines("__tb_prefix__=\"xmake\"")
+
+ -- add includes directory
+ add_includedirs("$(projectdir)", "$(projectdir)/src")
+
+ -- add common source files
+ add_files("**.c")
+
+ -- add resource files (it will be enabled after publishing new version)
+ if is_plat("windows") then
+ add_files("*.rc")
+ end
+
+ -- add links
+ if is_plat("windows") then
+ add_syslinks("ws2_32", "advapi32", "shell32")
+ add_ldflags("/export:malloc", "/export:free", "/export:memmove")
+ elseif is_plat("android") then
+ add_syslinks("m", "c")
+ elseif is_plat("macosx") and is_config("runtime", "luajit") then
+ add_ldflags("-all_load", "-pagezero_size 10000", "-image_base 100000000")
+ elseif is_plat("mingw") then
+ add_ldflags("-static-libgcc", {force = true})
+ elseif is_plat("haiku") then
+ add_syslinks("pthread", "network", "m", "c")
+ else
+ add_syslinks("pthread", "dl", "m", "c")
+ end
+
+ -- enable xp compatibility mode
+ if is_plat("windows") then
+ if is_arch("x86") then
+ add_ldflags("/subsystem:console,5.01")
+ else
+ add_ldflags("/subsystem:console,5.02")
+ end
+ end
+
+ -- add install files
+ if is_plat("windows") then
+ add_installfiles("$(projectdir)/../LICENSE.md")
+ add_installfiles("$(projectdir)/../NOTICE.md")
+ add_installfiles("$(projectdir)/../xmake/(**.lua)")
+ add_installfiles("$(projectdir)/../xmake/(scripts/**)")
+ add_installfiles("$(projectdir)/../xmake/(templates/**)")
+ add_installfiles("$(projectdir)/../scripts/xrepo.bat")
+ add_installfiles("$(projectdir)/../scripts/xrepo.ps1")
+ else
+ add_installfiles("$(projectdir)/../(xmake/**.lua)", {prefixdir = "share"})
+ add_installfiles("$(projectdir)/../(xmake/scripts/**)", {prefixdir = "share"})
+ add_installfiles("$(projectdir)/../(xmake/templates/**)", {prefixdir = "share"})
+ add_installfiles("$(projectdir)/../scripts/xrepo.sh", {prefixdir = "bin", filename = "xrepo"})
+ end
+
+ before_installcmd(function (target, batchcmds, opt)
+ -- we need to avoid some old files interfering with xmake's module import.
+ local package = opt.package
+ if target:is_plat("windows") then
+ batchcmds:rmdir(package:installdir("actions"))
+ batchcmds:rmdir(package:installdir("core"))
+ batchcmds:rmdir(package:installdir("includes"))
+ batchcmds:rmdir(package:installdir("languages"))
+ batchcmds:rmdir(package:installdir("modules"))
+ batchcmds:rmdir(package:installdir("platforms"))
+ batchcmds:rmdir(package:installdir("plugins"))
+ batchcmds:rmdir(package:installdir("repository"))
+ batchcmds:rmdir(package:installdir("rules"))
+ batchcmds:rmdir(package:installdir("templates"))
+ batchcmds:rmdir(package:installdir("scripts"))
+ batchcmds:rmdir(package:installdir("themes"))
+ batchcmds:rmdir(package:installdir("toolchains"))
+ end
+ end)
+
diff --git a/core/src/cli/xmake.rc b/core/src/cli/xmake.rc
new file mode 100644
index 000000000..2167c8f25
--- /dev/null
+++ b/core/src/cli/xmake.rc
@@ -0,0 +1,43 @@
+#include "xmake.config.h"
+#include "winres.h"
+
+#define _STR(x) #x
+#define STR(x) _STR(x)
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION XM_CONFIG_VERSION_MAJOR, XM_CONFIG_VERSION_MINOR, XM_CONFIG_VERSION_ALTER, 0
+ PRODUCTVERSION XM_CONFIG_VERSION_MAJOR, XM_CONFIG_VERSION_MINOR, XM_CONFIG_VERSION_ALTER, 0
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+#ifdef _DEBUG
+ FILEFLAGS VS_FF_DEBUG
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS VOS_NT_WINDOWS32
+ FILETYPE VFT_APP
+ FILESUBTYPE VFT2_UNKNOWN
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004B0"
+ BEGIN
+ VALUE "Comments", "A cross-platform build utility based on Lua\nwebsite: https://xmake.io"
+ VALUE "CompanyName", "The TBOOX Open Source Group"
+ VALUE "FileDescription", "XMake build utility"
+ VALUE "FileVersion", XM_CONFIG_VERSION "+" STR(XM_CONFIG_VERSION_BUILD)
+ VALUE "InternalName", "xmake"
+ VALUE "LegalCopyright", "Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io"
+ VALUE "LegalTrademarks", ""
+ VALUE "OriginalFilename", "xmake.exe"
+ VALUE "ProductName", "XMake"
+ VALUE "ProductVersion", XM_CONFIG_VERSION "+" STR(XM_CONFIG_VERSION_BUILD)
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
+
+
+IDI_APP ICON DISCARDABLE "xmake.ico"
diff --git a/core/src/cli/xmake.sh b/core/src/cli/xmake.sh
new file mode 100755
index 000000000..531a6e86a
--- /dev/null
+++ b/core/src/cli/xmake.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+target "cli"
+ add_deps "xmake"
+ set_kind "binary"
+ set_basename "xmake"
+ set_targetdir "${buildir}"
+
+ # add definitions
+ add_defines "__tb_prefix__=\"xmake\""
+
+ # add includes directory
+ add_includedirs "${projectdir}/core" "${projectdir}/core/src"
+
+ # add the common source files
+ add_files "**.c"
+
+ # add links
+ if is_plat "macosx" && is_config "runtime" "luajit"; then
+ add_ldflags "-all_load" "-pagezero_size 10000" "-image_base 100000000"
+ elif is_plat "mingw"; then
+ add_ldflags "-static-libgcc"
+ fi
+
+ # add install files
+ add_installfiles "${projectdir}/(xmake/**.lua)" "share"
+ add_installfiles "${projectdir}/(xmake/scripts/*)" "share"
+ add_installfiles "${projectdir}/(xmake/scripts/cmake_importfiles/**)" "share"
+ add_installfiles "${projectdir}/(xmake/scripts/completions/**)" "share"
+ add_installfiles "${projectdir}/(xmake/scripts/xpack/**)" "share"
+ add_installfiles "${projectdir}/(xmake/scripts/xrepo/**)" "share"
+ add_installfiles "${projectdir}/(xmake/scripts/virtualenvs/**)" "share"
+ add_installfiles "${projectdir}/(xmake/scripts/pac/**)" "share"
+ add_installfiles "${projectdir}/(xmake/scripts/conan/**)" "share"
+ add_installfiles "${projectdir}/(xmake/scripts/module/**)" "share"
+ add_installfiles "${projectdir}/(xmake/templates/**)" "share"
+ add_installfiles "${projectdir}/scripts/xrepo.sh" "bin" "xrepo"
+
+ # fix os.exec() call incorrect program from /mingw64/bin. e.g. python, ..
+ #
+ # because xmake is installed to /mingw64/bin/xmake,
+ # os.exec/CreateProcess always gives the highest priority to finding the process from /mingw64/bin (if it exists),
+ # rather than from the $PATH environment variable.
+ #
+ # we install the xmake executable into a separate directory to ensure
+ # that os.exec() does not look for additional executables.
+ #
+ # @see https://github.com/xmake-io/xmake/issues/3628
+ if is_host "msys"; then
+ after_install "xmake_after_install"
+ fi
+
+ # add syslinks
+ add_options "atomic"
+ if is_plat "mingw" "msys" "cygwin"; then
+ add_syslinks "ws2_32" "pthread" "m"
+ elif is_plat "bsd"; then
+ add_syslinks "pthread" "m"
+ elif is_plat "haiku"; then
+ add_syslinks "pthread" "network" "m"
+ elif test_nz "${TERMUX_ARCH}"; then
+ add_syslinks "m" "dl"
+ else
+ add_syslinks "pthread" "dl" "m" "c"
+ fi
+
+xmake_after_install() {
+ local target=${1}
+ local installdir=${2}
+ if test_eq "${project_generator}" "gmake"; then
+ print "\t@if test -f ${installdir}/bin/xmake.exe; then rm ${installdir}/bin/xmake.exe; fi" >> "${xmake_sh_makefile}"
+ print "\t@cp ${projectdir}/scripts/msys/xmake.sh ${installdir}/bin/xmake" >> "${xmake_sh_makefile}"
+ print "\t@cp ${buildir}/xmake.exe ${installdir}/share/xmake" >> "${xmake_sh_makefile}"
+ fi
+}