SanderMertens / bake

Bake, A build system for building, testing and running C & C++ projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when using os

yuvaldolev opened this issue · comments

Hi, I'm using bake for a c++ project, and it's awesome.
I wanted to link the project with a library that is only available for linux so I used ${os linux} but I'm getting an error:

error environment variable '' is not set
error environment variable '' is not set
 from environment variable '' is not set
 from environment variable '' is not set
 from environment variable '' is not set
 from environment variable '' is not set
 from environment variable '' is not set
 from failed to locate binary for package 'bake.${os linux}'
 from could not load driver 'bake.${os linux}'

This is my project.json file:

{
    "id": "Jobs",
    "type": "package",
    "value": {
        "author": "Yuval Dolev",
        "description": "A job scheduler that uses natural sounding syntax for C++",
        "version": "1.0.0",
        "repository": "Jobs",
        "license": "MIT License",
        "language": "cpp"
    },
    "lang.cpp": {
        "include": ["include"],
        "cpp-standard": "c++17"
    },
    "${os linux}": {
        "lang.cpp": {
            "lib": ["m"]
        }
    }
}

Is there a problem with my project.json?
Thanks!

Hmm, this looks like a regression issue. I'm looking into it.

Thanks

Actually, this is "by design". You cannot use ${ ... } at the root of the JSON document, as that is reserved for drivers, value and dependee attributes. To achieve what you want you can do:

{
    "id": "Jobs",
    "type": "package",
    "value": {
        "author": "Yuval Dolev",
        "description": "A job scheduler that uses natural sounding syntax for C++",
        "version": "1.0.0",
        "repository": "Jobs",
        "license": "MIT License",
        "language": "cpp"
    },
    "lang.cpp": {
        "include": ["include"],
        "cpp-standard": "c++17",
        "${os linux}": {
            "lib": ["m"]
        }
    }
}

The reason you cannot use ${ .. } at this level is to keep it simple to discover which drivers a project uses, as bake needs this information at early stages of the build process (before parsing the template functions).

The error message is pretty bad though, I'll fix that.

Thank you!!