Why does the success of assembling SCons depend on the name variant_dir?

I am so bored of this behavior. Therefore, in the SConstruct file , we have the last line, similar to this:

import compilers, os

env = Environment(ENV = os.environ, TOOLS = ['default'])

def set_compiler(compiler_name):
    env.Replace(FORTRAN = compiler_name)
    env.Replace(F77 = compiler_name)
    env.Replace(F90 = compiler_name)
    env.Replace(F95 = compiler_name)

def set_flags(flags):
    env.Replace(FORTRANFLAGS = flags)
    env.Replace(F77FLAGS = flags)
    env.Replace(F90FLAGS = flags)
    env.Replace(F95FLAGS = flags)

mod_dir_prefix = {
    "gfortran": "-J ",
    "ifort": "-???",
    "pgfortran": "-module " 
}

flags = {
    ("gfortran", "debug"): "-O0 -g -Wall -Wextra -pedantic -fimplicit-none -fbounds-check -fbacktrace",
    ("gfortran", "release"): "-O3",
    ("pgfortran", "debug"): "-O0 -g -C -traceback",
    ("pgfortran",  "release"): "-O4"
}

if not GetOption('clean'):
    print "\nAvailable Fortran compilers:\n"

    for k, v in compilers.compilers_dict().iteritems():
        print "%10s : %s" % (k, v)

    compiler = raw_input("\nChoose compiler: ")

    set_compiler(compiler)

    debug_or_release = raw_input("\nDebug or release: ")

    set_flags(flags[(compiler, debug_or_release)])

    env.Replace(FORTRANMODDIRPREFIX = mod_dir_prefix[compiler])

    env.Replace(LINK = compiler)
    env.Replace(LINKCOM = "$LINK -o $TARGET $LINKFLAGS $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $_FRAMEWORKPATH $_FRAMEWORKS $FRAMEWORKSFLAGS")
    env.Replace(LINKFLAGS = "")

env.Replace(FORTRANMODDIR = '#Mod')
Export('env')

SConscript('Sources/SConscript', variant_dir='Build', duplicate=0)

compilers.py is my own module for finding Fortran compilers that are available.

In the Sources folder, we have a couple of Fortran source files.

Sources \ SConscript

Import('env')
env.Program('app', Glob('*.f90'))

Scons supports Fortran and everything works fine.

gfortran -o Temp\kinds.o -c -O3 -JMod Sources\kinds.f90
gfortran -o Temp\math.o -c -O3 -JMod Sources\math.f90
gfortran -o Temp\sorts.o -c -O3 -JMod Sources\sorts.f90
gfortran -o Temp\utils.o -c -O3 -JMod Sources\utils.f90
gfortran -o Temp\main.o -c -O3 -JMod Sources\main.f90
gfortran -o Temp\app.exe Temp\kinds.o Temp\main.o Temp\math.o Temp\sorts.o Temp\utils.o
scons: done building targets.

After renaming the variant_dir name to say #Binor #Build, an error message appears:

gfortran -o Bin\kinds.o -c -O3 -JMod Sources\kinds.f90
gfortran -o Bin\main.o -c -O3 -JMod Sources\main.f90
Sources\main.f90:3.11:

  USE sorts
           1
Fatal Error: Can't open module file 'sorts.mod' for reading at (1): No such file or directory

Of course, compilation order matters. But why does it depend on the variant_dir name? Sounds like a mistake, but maybe I'm doing something wrong.

P.S. duplicate.
P.P.S. SCons 2.0.1 Windows Python 2.7 Mac OS X Python 2.5.1.

+3
1

, .

-, , , , Fortran .

scons [your_arguments] -n --tree=all | less

, , , Scons.

:

( ):

env.Replace(FORTRANMODDIR = '#Mod') env.Replace(FORTRANPATH = '.' ] Export('env')

, "" SConscript ( src build), , , .

scons (2.3.0) duplicate=0, , -module build/ -module src/ (ifort) , , . .

+1

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


All Articles