问题描述
我是Premake的新手.我使用Premake 4.4 beta 5是因为Premake 5存在一些问题,即它无法生成正确的VS2010解决方案(使用2010编译器生成VS2012解决方案),并且在一个项目下编写时会为所有项目设置libdirs和链接.
I am new to Premake. I am using Premake 4.4 beta 5 because Premake 5 has a few issues where it does not generate proper VS2010 solutions (generates VS2012 solutions with 2010 compiler), and it setting libdirs and links for all projects when written under one project.
无论如何,我遇到的问题是我编写了一个Premake脚本.一切正常,但令人讨厌的是,它包括项目中包含的所有文件之间共有的多个父文件夹.因此,在接触之前,您必须打开多个文件夹,其中仅包含一个文件夹.这是一张使您理解的图像: premake_common_parent_folders
Anyways, the issue I am having is that I wrote a Premake script. It all works fine, but there is an annoyance where it includes multiple parent folders in common between all the files included in the project. So you have to open multiple folders containing nothing but a single folder, before you get to the meat. Here's is an image so that you understand: premake_common_parent_folders
我在光盘上的文件夹结构如下:
My folder structure on disc looks something like this:
- 构建
- premake4.lua
- premake4.4-beta5.exe
- build
- premake4.lua
- premake4.4-beta5.exe
- StaticLib
- 包括
- Example.h
- StaticLib
- include
- Example.h
- Example.cpp
这是我的预制棒:
_targetdir = '../bin/' .. _ACTION local function ProjectCommon() targetdir( _targetdir .. '/' .. project().name ) files { '../src/' .. project().name .. '/**.*', } includedirs { '../src/' .. project().name .. '/include', } end solution( 'Example' ) location( _ACTION ) configurations { "Release", "Debug" } project( 'Test' ) ProjectCommon() language( 'C++' ) kind( 'ConsoleApp' ) includedirs { '../src/StaticLib/include', } libdirs { _targetdir .. '/StaticLib', } links { solution().name, } project( 'StaticLib' ) ProjectCommon() targetname( solution().name ) language( 'C++' ) kind( 'StaticLib' )
我想知道是否可以通过单个include文件夹将实现文件直接放在项目下.隐藏所有项目文件(src和[项目名称])之间公用的父文件夹.
I want to know if there is a way to have the implementation files directly under the project with the single include folder. Hiding the parent folders common between all project files (src and [Project Name]).
希望它看起来像这样: premake_no_common_parent_folders
The hope is to have it look something like this: premake_no_common_parent_folders
推荐答案
从理论上讲(没试过,我很久没有使用Premake 4了),您可以使用虚拟路径来重写结构.
In theory (untested, I haven't used Premake 4 in a long time) you can use virtual paths to rewrite the structure.
vpaths { ["*"] = "../src/" }
另一方面,Premake 5会自动修剪路径顶部的空白组,因此,如果您进行升级,则不需要这样做.
Premake 5, on the other hand, automatically trims otherwise empty groups from the top of the path, so this isn't necessary if you upgrade.
说到Premake 5,我不熟悉您提到的任何一个bug.如果尚未,请打开问题.我愿意打赌在一个项目下编写时为所有项目设置libdirs和链接"是项目脚本的问题,而不是Premake本身的问题,因为这将是一个非常基本的缺陷.
Speaking of Premake 5, I'm not familiar with either of the bugs you mention; you should open an issue if you haven't already. I'd be willing to bet "setting libdirs and links for all projects when written under one project" is an issue with your project script rather than Premake itself, as that would be a pretty fundamental flaw.
这篇关于在Premake中隐藏项目文件的公共父文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
- include
- 包括