How to create an alias for a build target with a relative path in Scons?

Background

I tried Scons by creating a basic C ++ project that has two subprojects:

  • Prj1 is an exe that depends on Prj2
  • Prj2 is a DLL that exports some functions.

You can see the directory structure and contents of my SConstruct and SConscript files here

Problem

The problem I am facing is that in order to create these goals from the command line, I must specify both the relative path to their build directory and their extensions for specific platforms.

For example, to create Prj1 I need to do:


build> scons ../bin/project1.exe

Similarly, to create Prj2 I need to do:


build> scons ../bin/project2.dll

Question

How can I get SCons to create these projects without specifying a relative path extension and platform extension?

Desired:


build> scons project1 
build> scons project2

  • - , , , - . :

prj1_env.Alias( 'project1', PROG)
prj1_env.Alias( 'project1', os.path.join( BIN_DIR, PROG) )

+3
1

.:)


  • < href= "/questions/360459/how-do-i-get-projects-to-place-their-build-output-into-the-same-directory-with-scons" > Scons?

Alias ​​ . , , "project1" ( PROG) . . PrefixProgram :

def PrefixProgram(env, outdir, trgt, srcs):
    return env.Program(target = os.path.join(outdir, trgt), source = srcs)

:

target = PrefixProgram( prj1_env, BIN_DIR, PROG, SOURCES )
prj1_env.Alias("project1", target)

, , :

prj1_env.Alias("project1", PrefixProgram( prj1_env, BIN_DIR, PROG, SOURCES ))

, .

, .

+3

Source: https://habr.com/ru/post/1699430/


All Articles