-
-
Notifications
You must be signed in to change notification settings - Fork 784
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
"phony target" request #68
Comments
You can add a phony target without target kind to only add target's building deps. For example:
And run command to build these tests: $ xmake build testsuite xmake also support option("name")
set_showmenu(true)
set_default("world")
target("test")
set_kind("binary")
add_files("*.c")
after_build(function (target)
print("hello $(name)!")
end) So the default value of this variable $ xmake f --name=xmake The result is:
And you also can add target("test")
set_kind("binary")
add_files("$(name)/*c")
add_links("$(name)_$(arch)")
... Please checkout the lastest commit 23ffe01, I fixed Thanks! |
Oh, sounds interesting. What about |
Sorry but I couldn't understand this code you wrote: option("name")
set_showmenu(true)
set_default("world")
target("test")
set_kind("binary")
add_files("*.c")
after_build(function (target)
print("hello $(name)!")
end) Will target Also, use Another question, could I do something in phony target? For example, copying something? |
Sorry, I couldn't understand what you mean. If you want to pass variable to If you want to use target("test")
on_build(function (target)
-- quietly run make
os.run("make")
-- run make and output info
os.exec("make")
end) For second question, you can copying something on the custom build or other scripts. target("testsuite")
set_default(false)
add_deps("testprogadd", "testprogsub", "testprogmul", "testprogdiv", "testprogmod")
on_build(function (target)
os.cp("file1", "file2", "dir/*", "to_destfile_or_dir")
end
after_build(function (target)
os.cp("file1", "file2", "dir/*", "to_destfile_or_dir")
end
on_package(function (target)
os.cp("file1", "file2", "dir/*", "to_destfile_or_dir")
end |
I do not mean to use make in script. What I said is xmake: $ /path/to/xmake
# args[0] would be absolute path what is I wanna to get |
You can get the absolute path from os.run("$(programdir)/xmake") |
😄 |
Are you sure it really works? target("test")
on_build(function (target)
os.exec("$(programdir)/xmake --version")
end)
on_clean(function (target)
os.exec("$(programdir)/xmake --version")
end) got: error: invalid variable: $(programdir) By the way, if there is not target("test")
on_build(function (target)
os.exec("$(programdir)/xmake --version")
end) got: error: bad argument #1 to 'pairs' (table expected, got nil) Why there must be The reason why I wanna use
And set_xmakever("2.1.3")
set_project("winpty")
set_languages("ansi","gnuxx11")
add_defines("_WIN32_WINNT=0x0501")
target("winpty")
set_kind("shared")
add_headers("include/*")
add_includedirs("include","gen")
add_defines("COMPILING_WINPTY_DLL")
add_links("advapi32","user32")
add_files(
"libwinpty/AgentLocation.cc",
"libwinpty/winpty.cc",
"shared/BackgroundDesktop.cc",
"shared/Buffer.cc",
"shared/DebugClient.cc",
"shared/GenRandom.cc",
"shared/OwnedHandle.cc",
"shared/StringUtil.cc",
"shared/WindowsSecurity.cc",
"shared/WindowsVersion.cc",
"shared/WinptyAssert.cc",
"shared/WinptyException.cc",
"shared/WinptyVersion.cc")
before_build(function (target)
os.cd("shared")
os.exec("UpdateGenVersion.bat")
os.cd("..")
end) Sorry, it's little long. Can be seen at xmake.lua Please have a mind at I try to write add_subdirs(path.join("winpty","src")) But it fails with So, when building subdirs, xmake does not enter it? How to solve this? How to build submodule with xmake? Would be better if there is |
I'm sorry, I forgot to add os.exec("$(xmake) --version") About About the third problem, the default directoy of the before_build(function (target)
os.cd("$(scriptdir)/shared")
os.exec("UpdateGenVersion.bat")
os.cd("-")
end) Or before_build(function (target)
os.exec("$(scriptdir)/shared/UpdateGenVersion.bat")
end) And it's no problem about
|
Great!!!:+1::smile: |
I improved phony target to support the following case: set_kind("binary")
target("test1")
add_files("*.c")
target("test2")
add_files("*.c")
target("alltests")
set_kind("phony") <--- If you do not set kind, this target kind is `binary` instead of `phony`
add_deps("test1", "test2") |
Feature request!
The idea of phony target comes from makefile. It is a target that do not actually build anything.
I think it has meanings to add this feature. For example, I have
testadd
,testsub
... So a phony targettestsuite
might be needed to build all tests together then put them into a certain directory. It's also possible in xmake today but a little troublesome.There is also an another feature request. That is,
$(xmake)
. makefile has$(MAKE)
to let script usemake
itself. I found it's also useful to add such.Oh, finally I suddenly get an idea. To let commandline pass vars to script. I think we could do things as below at last:
The text was updated successfully, but these errors were encountered: