Comments (10)
I'm noticing this with file.abspath
as well.
from premake-core.
I believe this has been resolved by #880, closing based on this, please reopen if this doesn't fix the issue.
from premake-core.
FWIW, Premake always tries to make all paths relative for properties that are not paths. For example the buildcommands, is just a string, since it contains a command line and not a path. Because the goal of premake is to allow the project to be moved around, it should basically only ever output relative paths into project files, so you can zip up the project, send it to someone without premake, and allow it to be unpacked and build.
This is the reason why using %{file.abspath}
turns into a relative path inside of command line options. The PR that @samsinsane references, allows you to disable that by writing %{!file.abspath}
, and while that works, it obviously also breaks the concept of movable projects.. So use with care.
from premake-core.
I do agree with the original poster that the behavior of abspath
is counterintuitive in this case. Ideally, Premake probably should just output the absolute path in this case and not require the '!'.
from premake-core.
The Visual Studio action actually replaces it with a Visual Studio token. %(Fullpath) or something. Which is cool, because it keeps to the movable project goal. But it does result in inconsistent paths at times. In particular the "google protocol buffers" compiler can't handle mixed paths, which causes all kinds of trouble for us here.
I've contemplated just removing all the logic from the detoken function, and just do what people write. I'd be all for that, as it kind of demystifies the behavior of detoken. I'm getting about 2-3 emails a month about it here internally ;)
But I wanted to discuss that with the rest here first.. @starkos, @samsinsane.
from premake-core.
And just to clarify this further, as much as I'd like to remove that, I'm also reluctant... for example
buildcommands {
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
'c2o -c "%{cfg.objdir}/%{file.basename}.xo" -o "%{cfg.objdir}/%{file.basename}.obj"'
}
in on of the unit-test, it expects:
$(SILENT) cxc -c "hello.x" -o "obj/Debug/hello.xo"
which makes perfect sense, and is what I would like to maintain... The problem is however, if we remove the make relative behavior from detoken, it becomes:
$(SILENT) cxc -c "hello.x" -o "D:/dev-premake/premake-vendor/obj/Debug/hello.xo"
which is clearly less desirable.
Ideally, a buildcommand isn't just a string, but a list of objects. something like:
buildcommands {
buildcommand { path('cxc.exe'), option('-c'), path('%{file.path}'), option('-o'), path('%{cfg.objdir}/%{file.basename}.xo')
}
it's just so inconvenient to write that...
from premake-core.
That's an interesting idea, I feel that would be quite inconvenient to write though. I personally prefer the usage of !
, it's simple and easy to use, sadly it's also really easy to forget about. Should we re-open this issue?
from premake-core.
What if we add another value to the pathVars
tables like makeRelative
? And then use that value when setting dontMakeRelative
in detoken.expand()
, to prevent abspath
replacements from getting converted? Does that clean things up?
from premake-core.
One of the other ideas one of my colleagues had, was to do a late join. As in, instead of returning a string from detoken, we return an AST. Generally the AST is just a single string, but in the case where you do something like %{file.path} we know it's a path, so it could build a 'tree' of <string><path><string>
..
The "action" gets to resolve it at the end, instead of the detoken trying to figure it all out.
it's a big refactor for sure, but I think it would allow us to get the best of both worlds.
@starkos I think that would allow us to control it for API's entirely, say buildcommands
we set that flag, and it will never do the abspath replacement.. a useful addition for sure. Not sure how much it helps though. For some tokens you want it, for others you don't. It almost like if you write file.abspath
then keep it abs.. but it you write cfg.objdir
you don't want abs, unless you explicitly asked for it, like what file.abspath
implies.
from premake-core.
Hmm…maybe we can allow actions to register a "token expander" function, kind of like they can register a string escaping function now. If the action doesn't set one, then a default gets used. That might help reduce the amount of refactoring that is needed?
from premake-core.
Related Issues (20)
- Linking starts before any compilation resulting in undefined reference to main function. HOT 5
- CUDA support? HOT 7
- Command line arguments? HOT 7
- <command-line>: error: macro names must be identifiers HOT 11
- XCode does not show linked Libraries HOT 8
- Object File Collision Detection Part II: Visual Studio C++ modules HOT 1
- Premake 6
- [VS] Source Build Help HOT 4
- Error while building Premake 5 on CentOS 7 HOT 6
- xcode4 bug with generated file with same name, but different path
- How to handle conflicting API (in external modules)? HOT 1
- Issue trying to fix x86 Linux build HOT 1
- configmap for externalproject does not map correctly HOT 1
- The Makefile generated by `premake5 gmake2` calls `sh.exe` HOT 9
- Api in _preload.lua inaccessible HOT 6
- It would be nice to have better error identification. HOT 3
- Make failing Command Tokens fail the build HOT 1
- Visual Studio "Previous IPDB not found, fall back to full compilation." HOT 3
- Premake system toolset selection issue HOT 5
- Configuration filters don't work correctly for postbuildcommands in C# projects HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from premake-core.