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

如何让mingw输出的动态库是`xxx.dll`,而不是`libxxx.so`? #178

Closed
actboy168 opened this Issue Aug 1, 2018 · 10 comments

Comments

Projects
None yet
2 participants
@actboy168

actboy168 commented Aug 1, 2018

我自己改了https://github.com/tboox/xmake/blob/master/xmake/platforms/mingw/xmake.lua#L38

但有没有不修改xmake的方法?

@waruqi

This comment has been minimized.

Member

waruqi commented Aug 1, 2018

你改了啥?如果只是修改目标文件后缀名,可以在after_build里面修改

target("test")
    after_build(function (target)
        local targetfile = target:targetfile()
        os.mv(targetfile, path.join(path.directory(targetfile), path.basename(targetfile) .. ".exe"))
    end)
@actboy168

This comment has been minimized.

actboy168 commented Aug 1, 2018

这样改,不会改link的路径。如果另一个target依赖了它,编译出来的文件是link libxxx.so 而不是 'xxx.dll'

@waruqi

This comment has been minimized.

Member

waruqi commented Aug 1, 2018

你可以同时修改basename,或者追加 links,都会被继承过去的。

target("test")
    after_build(function (target)
        local targetfile = target:targetfile()
        os.mv(targetfile, path.join(path.directory(targetfile), path.basename(targetfile) .. ".exe"))
        target:set("basename", "xxxx")
    end)

basename那个link问题我一会看下

@actboy168

This comment has been minimized.

actboy168 commented Aug 1, 2018

还是不行啊。我认为应该有个可以指定输出名的函数?

另外mingw的动态库名默认应该是xxx.dll更妥当吧

@waruqi

This comment has been minimized.

Member

waruqi commented Aug 1, 2018

设置basename 不就是输出名么 。我是说等我修复刚那个提到basename 修改link不上的bug后 你再试下。现在还没时间看么 得等晚上抽空看下。。。

mingw的动态库后缀 这个每个用户的需求不一样 之前还有人说 so更妥当的。。

或者我可以提供个设置目标文件名format的接口。。不过得等上几天了

@actboy168

This comment has been minimized.

actboy168 commented Aug 1, 2018

设置basename 不就是输出名么 。我是说等我修复刚那个提到basename 修改link不上的bug后 你再试下。现在还没时间看么 得等晚上抽空看下。。。

我的理解是,如果basename是xxx的话,那么最终的文件名就是libxxx.so,所以我改basename并不会有帮助。

或者我可以提供个设置目标文件名format的接口。。不过得等上几天了

谢谢

@waruqi

This comment has been minimized.

Member

waruqi commented Aug 1, 2018

我的理解是,如果basename是xxx的话,那么最终的文件名就是libxxx.so,所以我改basename并不会有帮助。

单纯改是这样,我刚的意思是,按刚才贴的例子,after_build里面去 重命名文件,然后同步改下basename去配合link(等我修完bug后)。。

如果你不急的话,等后两天我抽空改进下相关接口。

@waruqi

This comment has been minimized.

Member

waruqi commented Aug 2, 2018

后来我想了下,mingw下动态库命名,确实.dll可能会更好些,我现在默认改成dll了,你可以更新到master版本试试,如果是在windows下,可以下载开发版本安装包试下,xmake-v2.2.2-dev

对于目标文件的命名格式设置,我后期还会提供更灵活的接口来定制化设置。

@waruqi waruqi modified the milestones: v2.2.1, v2.2.2 Aug 2, 2018

@waruqi waruqi added the improvement label Aug 2, 2018

@waruqi

This comment has been minimized.

Member

waruqi commented Aug 3, 2018

我想起来了,这个当前版本已经是有接口支持的:

target("test")
    set_filename("test.dll")

这个会去修改文件全名,但是不会干扰deps里面的link的,还是会正常link,如果优先设置了这个,会忽略basename的设置,你也可以试试。。这个 之前忘记加到文档里面去了,现在我加上了:set_filename

最近记性不太好了。。 = =

@actboy168

This comment has been minimized.

actboy168 commented Aug 9, 2018

好的,谢谢

@actboy168 actboy168 closed this Aug 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment