atilaneves / reggae

Build system in D, Python, Ruby, Javascript or Lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request for Help - Configuring Reggae without dub.sdl

o3o opened this issue · comments

commented

I am facing difficulties in using the Reggae without relying on a dub file.
In this GitHub example I am attempting to import the library simple-math from the ~/.dub repository using the following code snippet:

string simple = buildPath(dubPackagesDir, "/simple-math/1.1.0/simple-math/source");
   

However, I encounter the error Error: variable simple cannot be read at compile time.

The only workaround I found is declaring simple as an enum with the home path explicitly written:

enum simple = buildPath("/home/o3o", ".dub", "packages",  "/simple-math/1.1.0/simple-math/source");

but this approach feels inconvenient and lacks portability.

I appreciate any assistance or guidance to resolve this issue. Thank you!

The only way to do things at module level is to use enum. Otherwise, you can write the same code in a runtime manner inside a D function.

commented

Thank you for your reply.
In my example, I wrote:

// reggaefile.d

import reggae;
import reggae.path;

Build reggaeBuild() {
   import std.process: environment;
   //enum simple = buildPath("/home/o3o", ".dub", "packages",  "simple-math/1.1.0/simple-math/source");

   string simple = buildPath(dubPackagesDir, "/simple-math/1.1.0/simple-math/source");
   auto app = scriptlike!(
         App(
            SourceFileName(`src/app.d`),
            BinaryFileName(`math`)
            ),
         Flags(),
         ImportPaths([simple])
         );
   return Build(app);
}

but I'm encountering same issues, and despite your advice to use a function, the problem persists.
I apologize for any confusion, but could you please provide more guidance or corrections to the code?

Oh, right. You're trying to use simple as a template argument to scriptlike, which can't work unless its known at compile-time.

commented

You're right! thank you