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 8941229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:15:11+00:00 2026-06-15T11:15:11+00:00

edit Totally rewritten example, the issue is the same. I have SConsctruct file: env

  • 0

edit Totally rewritten example, the issue is the same.

I have SConsctruct file:

env = Environment()

def write_main( out ):
    out.write("""
              #include <iostream>

              int main(int argc, char **argv)
              {{
                std::cout << "[{0}]" << std::endl;
                return 0;
              }}

              \n""".format(ARGUMENTS.get('print', 'nothing'))
            )

def generate_main(env, target, source):
    with open( env.GetBuildPath( target[0] ), 'w') as out:
        write_main( out )

main_builder = env.Builder( action = generate_main )
main_cpp = main_builder( env, env.GetBuildPath('main.cpp'), [] )

prog = env.Program( target='main', source=main_cpp )

Now if I run:

$ scons print=one && ./main 
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
generate_main(["main.cpp"], [])
g++ -o main.o -c main.cpp
g++ -o main main.o
scons: done building targets.
[one]

$ scons print=two && ./main
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
[one]

$ rm main.cpp
$ scons print=two && ./main
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
generate_main(["main.cpp"], [])
g++ -o main.o -c main.cpp
g++ -o main main.o
scons: done building targets.
[two]

So you can clearly see that the middle build was incorrect.
How can this be solved?

note: If I move body of write_main to generate_main (so I have only one function) it rebuilds correctly.

note:

One solution I can think of is providing all functions with target object so they can call Depends explicitly. In that example that would mean calling something like:

Depends( target, env.Variable( ARGUMENTS.get('print', 'nothing') ) )

Is there any other approach which would allow me to maintain current signature of write_main without requiring any knowledge about it in generate_main?

And how do I enforce particular syntax highlighting for a piece of code? (in above shell output gets weird/incorrect colors)

  • 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-06-15T11:15:12+00:00Added an answer on June 15, 2026 at 11:15 am

    You can create explicit dependencies in SCons using the Depends() function.

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

Sidebar

Related Questions

EDIT My issue was related to snippet syntax all along... The configuration below totally
EDIT: See my answer below--> I am wanting to have a view that when
Edit (updated question) I have a simple C program: // it is not important
EDIT : It turned out that this can only be done through an external
EDIT: Here is the edited control file (control.ascx): <%@ Control Language=C# AutoEventWireup=true CodeFile=Sale.ascx.cs Inherits=Enmasse.Modules.Demo_Enmasse.Sale
I have a ListView with edit text in each items and I want to
Edit: Totally forgot to mention I'm coding in Java I'm having a real hard
I have to support a website developed in umbraco. I am totally new to
Alright totally new to jeditable, Say I have some <div> 's and <input type='hidden'
I have a simple grouped uitableview with a nav bar and an Edit nav

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.