-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Add xmake pack
command to generate installation package like cmake/cpack
#1433
Milestone
Comments
xpack
command to generate installation package like cmake/cpackxmake pack
command to generate installation package like cmake/cpack
Merged
New Scope Apis (xpack)we can call includes("@builtin/xpack")
xpack("test")
set_formats("nsis")
set_description("hello")
add_targets("test", "foo") local apis = {
values = {
-- set package version, we will also get it from project/target
"xpack.set_version",
-- set package homepage url
"xpack.set_homepage",
-- set package title
"xpack.set_title",
-- set author
"xpack.set_author",
-- set maintainer,
"xpack.set_maintainer",
-- set package description
"xpack.set_description",
-- set input kind, e.g. binary, source
"xpack.set_inputkind",
-- set package copyright
"xpack.set_copyright",
-- set company name
"xpack.set_company",
-- set package formats, e.g. nsis, deb, rpm, targz, zip, srctargz, srczip, runself, ...
-- we can also add custom formats
"xpack.set_formats",
-- set the base name of the output file
"xpack.set_basename",
-- set the extension of the output file
"xpack.set_extension",
-- add targets to be packaged
"xpack.add_targets",
-- add package components
"xpack.add_components",
-- set installed binary directory, e.g. bin
"xpack.set_bindir",
-- set installed library directory, e.g. lib
"xpack.set_libdir",
-- set installed include directory, e.g. include
"xpack.set_includedir",
-- set prefix directory, e.g. prefixdir/bin, prefixdir/lib ..
"xpack.set_prefixdir",
-- set nsis display icon
"xpack.set_nsis_displayicon",
-- set package component title
"xpack_component.set_title",
-- set package component description
"xpack_component.set_description",
-- enable/disable this component by default
"xpack_component.set_default"
},
paths = {
-- set the spec file path, support the custom variable pattern, e.g. set_specfile("", {pattern = "%${([^\n]-)}"})
"xpack.set_specfile",
-- set icon file path, e.g foo.ico
"xpack.set_iconfile",
-- set package license file, we will also get them from target
"xpack.set_licensefile",
-- add source files
"xpack.add_sourcefiles",
-- add install files, we will also get them from target
"xpack.add_installfiles",
-- add source files for component
"xpack_component.add_sourcefiles",
-- add install files for component
"xpack_component.add_installfiles"
},
script = {
-- add custom load script
"xpack.on_load",
-- add custom package script before packing package
"xpack.before_package",
-- rewrite custom package script
"xpack.on_package",
-- add custom package script after packing package
"xpack.after_package",
-- add custom commands script before installing
"xpack.before_installcmd",
-- add custom commands script before uninstalling
"xpack.before_uninstallcmd",
-- rewrite custom install commands script, we will also get it from target/rules
"xpack.on_installcmd",
-- rewrite custom uninstall commands script, we will also get it from target/rules
"xpack.on_uninstallcmd",
-- add custom commands script after installing
"xpack.after_installcmd",
-- add custom commands script after uninstalling
"xpack.after_uninstallcmd",
-- add custom load script in component
"xpack_component.on_load",
-- add custom commands script before installing in component
"xpack_component.before_installcmd",
-- add custom commands script before uninstalling in component
"xpack_component.before_uninstallcmd",
-- rewrite custom install commands script in component, we will also get it from target/rules
"xpack_component.on_installcmd",
-- rewrite custom uninstall commands script in component, we will also get it from target/rules
"xpack_component.on_uninstallcmd",
-- add custom commands script after installing in component
"xpack_component.after_installcmd",
-- add custom commands script after uninstalling in component
"xpack_component.after_uninstallcmd"
},
keyvalues = {
-- set the spec variable
"xpack.set_specvar"
}
}
Examplehttps://github.com/xmake-io/xmake/blob/dev/tests/plugins/pack/xmake.lua set_version("1.0.0")
add_rules("mode.debug", "mode.release")
includes("@builtin/xpack")
add_requires("zlib", {configs = {shared = true}})
target("test")
set_kind("binary")
add_files("src/*.cpp")
if is_plat("windows") then
add_files("src/*.rc")
end
target("foo")
set_kind("shared")
add_files("src/*.cpp")
add_headerfiles("include/(*.h)")
add_packages("zlib")
xpack("test")
set_formats("nsis", "zip", "targz", "srczip", "srctargz", "runself")
set_title("hello")
set_author("ruki")
set_description("A test installer.")
set_homepage("https://xmake.io")
set_licensefile("LICENSE.md")
add_targets("test", "foo")
add_installfiles("src/(assets/*.png)", {prefixdir = "images"})
add_sourcefiles("(src/**)")
set_iconfile("src/assets/xmake.ico")
add_components("LongPath")
on_load(function (package)
if package:from_source() then
package:set("basename", "test-$(plat)-src-v$(version)")
else
package:set("basename", "test-$(plat)-$(arch)-v$(version)")
end
end)
after_installcmd(function (package, batchcmds)
if package:from_source() then
batchcmds:runv("echo", {"hello"})
else
batchcmds:mkdir(package:installdir("resources"))
batchcmds:cp("src/assets/*.txt", package:installdir("resources"), {rootdir = "src"})
batchcmds:mkdir(package:installdir("stub"))
end
end)
after_uninstallcmd(function (package, batchcmds)
batchcmds:rmdir(package:installdir("resources"))
batchcmds:rmdir(package:installdir("stub"))
end)
xpack_component("LongPath")
set_default(false)
set_title("Enable Long Path")
set_description("Increases the maximum path length limit, up to 32,767 characters (before 256).")
on_installcmd(function (component, batchcmds)
batchcmds:rawcmd("nsis", [[
${If} $NoAdmin == "false"
; Enable long path
WriteRegDWORD ${HKLM} "SYSTEM\CurrentControlSet\Control\FileSystem" "LongPathsEnabled" 1
${EndIf}]])
end)
Pack packages$ xmake pack |
Pack NSIS packageIt will download and install NSIS (makensis.exe) first automically. $ xmake pack
note: install or modify (m) these packages (pass -y to skip confirm)?
in xmake-repo:
-> nsis 3.09
please input: y (y/n/m)
=> install nsis 3.09 .. ok
[ 25%]: compiling.release src\main.cpp
[ 37%]: compiling.release src\main.cpp
[ 50%]: linking.release foo.dll
[ 62%]: linking.release test.exe
packing build\xpack\test\test-windows-x64-v1.0.0.exe
pack ok |
More example: Pack xmake installation package https://github.com/xmake-io/xmake/blob/dev/core/xpack.lua |
Support pack zip/tar.gz archivexpack("test")
set_formats("zip", "targz") $ xmake pack
$ xmake pack --formats=zip,targz |
Support components and custom nsis commandsxpack("test")
add_components("LongPath")
xpack_component("LongPath")
set_default(false)
set_title("Enable Long Path")
set_description("Increases the maximum path length limit, up to 32,767 characters (before 256).")
on_installcmd(function (component, batchcmds)
batchcmds:rawcmd("nsis", [[
${If} $NoAdmin == "false"
; Enable long path
WriteRegDWORD ${HKLM} "SYSTEM\CurrentControlSet\Control\FileSystem" "LongPathsEnabled" 1
${EndIf}]])
end) |
Merged
Pack source zip/tar.gz packagexpack("test")
set_formats("srczip", "srctargz")
add_sourcefiles("(src/**)") $ xmake pack
packing build/xpack/test/test-macosx-src-v1.0.0.zip ..
packing build/xpack/test/test-macosx-src-v1.0.0.tar.gz ..
pack ok Pack runself packagexpack("test")
set_formats("runself")
add_sourcefiles("(src/**)")
on_installcmd(function (package, batchcmds)
batchcmds:runv("make", {"install"})
end) $ xmake pack
packing build/xpack/test/test-macosx-src-v1.0.0.gz.run
pack ok
$ sh ./build/xpack/test/test-macosx-src-v1.0.0.gz.run Lines 79 to 112 in 51efaa7
|
Pack srpm packagePack xmake project with targetsxpack("test")
set_homepage("https://xmake.io")
set_license("Apache-2.0")
set_description("A cross-platform build utility based on Lua.")
set_formats("srpm")
add_sourcefiles("(src/**)")
add_sourcefiles("./xmake.lua")
add_targets("demo") Pack 3rd build system projectxpack("test")
set_homepage("https://xmake.io")
set_license("Apache-2.0")
set_description("A cross-platform build utility based on Lua.")
set_formats("srpm")
add_sourcefiles("(src/**)")
add_sourcefiles("./configure")
on_buildcmd(function (package, batchcmds)
batchcmds:runv("./configure")
batchcmds:runv("make")
end)
on_installcmd(function (package, batchcmds)
batchcmds:runv("make", {"install", "PREFIX=%{buildroot}"})
end) |
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Roadmaps
Refs
The text was updated successfully, but these errors were encountered: