premake / premake/premake-core

Allow specifying root directory for the project sources

Open
#2,129 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C
Stars
3.6k
Forks
654
Avg merge
1d 1h
Merged PRs (30d)
13

Description

For various reasons, I can't have Premake files in the root directory of the project, but have to put it into a subdirectory, let's call it build/premake. This means that even my simplest project definitions look like this:

project "foo"
  kind "StaticLib"
  symbols "On"

  local srcdir = "../../foo/"

  vpaths {
     ["Source Files"] = srcdir .. "**.cpp",
     ["Header Files"] = srcdir .. "**.h",
  }

  includedirs { srcdir .. "include" }

  files {
    srcdir .. "include/foo/bar.h",
    -- a dozen more of them...
    srcdir .. "src/foo/foo.cpp",
    -- and a dozen more of those...
  }

Having to write srcdir .. everywhere is aggravating.

My existing build system allows to do this instead

srcdir ../../foo; // This line makes all the paths relative to this directory.

library foo {
  includedirs = include;

  headers {
    include/foo/foo.h
    ...
  }

  sources {
    src/foo/foo.cpp
    ...
  }

}

and I find this much more convenient.

So I wonder if a similar option could be added to Premake? I'd be willing to implement it, but I'd appreciate any hints about how to do it because I am not sure how to get an option set at the current project level in translate() function which is where, I think, prepending of srcdir should be implemented.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the project-level path handling around the translate() function mentioned in the issue, and identify how current project options are made available there. Define the root-directory behavior for project paths, then verify that source, header, include, and vpath entries can omit the repeated prefix without changing existing relative-path behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.