Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6587527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:55:42+00:00 2026-05-25T16:55:42+00:00

I’m trying to get SCons to copy a Makefile project from the source dir

  • 0

I’m trying to get SCons to copy a Makefile project from the source dir to the build dir and run some commands to produce libmoo.a, but I’m running into a dependency cycle error. Details follow:

./SConstruct:

env = Environment()
Export('env')

dirs = ['.']

variant_dir = 'build'

for dir in dirs:
        SConscript(dir + '/' + 'SConscript', variant_dir=variant_dir + '/' + dir, duplicate=0)

./SConscript:

import os
Import('env')

env.Command(env.Dir('moo2').abspath, env.Dir('#moo').abspath, ["echo copying moo to the build dir", Copy("$TARGET", "$SOURCE")])

env.Command(env.Dir('moo2/Makefile').abspath, env.Dir('moo2').abspath, 'echo would run moo2.configure')

moolib = env.Command(env.Dir('moo2/libmoo.a').abspath, env.Dir('moo2/Makefile').abspath, 'echo would run make')

Default(moolib)

Error running scons:

scons: *** Found dependency cycle(s):
  build/moo2/Makefile -> build/moo2 -> build/moo2/Makefile
  build/moo2/libmoo.a -> build/moo2 -> build/moo2/Makefile -> build/moo2/libmoo.a

Also tried without using .abspath, but that shouldn’t matter, right?

I don’t see any cycles:

  • build/moo2/libmoo.a requires build/moo2/Makefile
  • build/moo2/Makefile requires build/moo2
  • build/moo2 requires (source/)moo

How is scons seeing a cycle? It seems to think that build/moo2/Makefile depends on build/moo2/libmoo.a, which is not what I intended to specify.

Any related suggestions are also welcome 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:55:43+00:00Added an answer on May 25, 2026 at 4:55 pm

    There’s no need for the env.Dir(‘moo’).abspath anywhere in your SConscript. So that would change it to:

    Import('env')
    env.Command('moo2', '#moo', ["echo copying moo to the build dir", Copy("$TARGET", "$SOURCE")])
    env.Command('moo2/Makefile', 'moo2', 'echo would run moo2.configure')  # Look Here
    moolib = env.Command('moo2/libmoo.a', 'moo2/Makefile', 'echo would run make')
    Default(moolib)
    

    But that still yields the same error:

    scons: *** Found dependency cycle(s):
    build/moo2/Makefile -> build/moo2 -> build/moo2/Makefile
    build/moo2/libmoo.a -> build/moo2/Makefile -> build/moo2/libmoo.a
    

    So why is that?
    SCons automatically makes a directory depend on all the files contained within.
    See the line with the “# Look Here” comment. You’ve added a dependency moo2/Makefile now depends on moo2. moo2 depends on all it’s contents by default, and thus your cycle.

    So how do we fix it?

    Import('env')
    env.Install('moo2',Glob('#moo/*'))
    env.Command('moo2/Makefile', env.Glob('moo2/*'), 'echo would run moo2.configure')
    moolib = env.Command('moo2/libmoo.a', 'moo2/Makefile', 'echo would run make')
    Default(moolib)
    

    I’ve changed from using Copy() to env.Install(). Since Copy is not attached to the build Environment() object, it won’t know about the variant dir. Install() and Copy() are functionally equivalent, with env.Install() being env aware.
    Additionally I have it copying/depending on all the files in the directory, rather than the directory itself.

    Now let’s give that a try:

    /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /Users/bdbaddog/devel/scons/trunk/bootstrap/src/script/scons.py --tree=prune
    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    Install file: "moo/abc.c" as "build/moo2/abc.c"
    Install file: "moo/configure" as "build/moo2/configure"
    Install file: "moo/def.c" as "build/moo2/def.c"
    echo would run moo2.configure
    would run moo2.configure
    echo would run make
    would run make
    +-build/moo2/libmoo.a
      +-build/moo2/Makefile
      | +-build/moo2/abc.c
      | | +-moo/abc.c
      | +-build/moo2/configure
      | | +-moo/configure
      | +-build/moo2/def.c
      | | +-moo/def.c
      | +-/bin/echo
      +-/bin/echo
    scons: done building targets.
    

    Note the “–tree=prune” this flag will have SCons print out the dependency tree and prune duplications in the tree (so if a 2 files depend on the same tree of files, you’ll only see it once)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.