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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:18:17+00:00 2026-05-11T03:18:17+00:00

In SCons, my command generators create ridiculously long command lines. I’d like to be

  • 0

In SCons, my command generators create ridiculously long command lines. I’d like to be able to split these commands across multiple lines for readability in the build log.

e.g. I have a SConscipt like:

import os  # create dependency def my_cmd_generator(source, target, env, for_signature):     return r'''echo its a small world after all \         its a small world after all'''  my_cmd_builder = Builder(generator=my_cmd_generator, suffix = '.foo')  env = Environment() env.Append( BUILDERS = {'MyCmd' : my_cmd_builder } )  my_cmd = env.MyCmd('foo.foo',os.popen('which bash').read().strip()) AlwaysBuild(my_cmd) 

When it executes, I get:

scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... echo its a small world after all \ its a small world after all its a small world after all sh: line 1: its: command not found scons: *** [foo.foo] Error 127 scons: building terminated because of errors. 

Doing this in the python shell with os.system and os.popen works — I get a readable command string and the sub-shell process interprets all the lines as one command.

>>> import os >>> cmd = r'''echo its a small world after all \ ... its a small world after all''' >>> print cmd echo its a small world after all \ its a small world after all >>> os.system( cmd) its a small world after all its a small world after all 0 

When I do this in SCons, it executes each line one at a time, which is not what I want.

I also want to avoid building up my commands into a shell-script and then executing the shell script, because that will create string escaping madness.

Is this possible?

UPDATE:
cournape,
Thanks for the clue about the $CCCOMSTR. Unfortunately, I’m not using any of the languages that SCons supports out of the box, so I’m creating my own command generator. Using a generator, how can I get SCons to do:

echo its a small world after all its a small world after all'  

but print

echo its a small world after all \     its a small world after all 

?

  • 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. 2026-05-11T03:18:17+00:00Added an answer on May 11, 2026 at 3:18 am

    Thanks to cournape’s tip about Actions versus Generators ( and eclipse pydev debugger), I’ve finally figured out what I need to do. You want to pass in your function to the ‘Builder’ class as an ‘action’ not a ‘generator’. This will allow you to actually execute the os.system or os.popen call directly. Here’s the updated code:

    import os  def my_action(source, target, env):     cmd = r'''echo its a small world after all \         its a small world after all'''     print cmd     return os.system(cmd)  my_cmd_builder = Builder(     action=my_action,  # <-- CRUCIAL PIECE OF SOLUTION     suffix = '.foo')  env = Environment() env.Append( BUILDERS = {'MyCmd' : my_cmd_builder } )  my_cmd = env.MyCmd('foo.foo',os.popen('which bash').read().strip()) 

    This SConstruct file will produce the following output:

    scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... my_action(['foo.foo'], ['/bin/bash']) echo its a small world after all \         its a small world after all its a small world after all its a small world after all scons: done building targets. 

    The other crucial piece is to remember that switching from a ‘generator’ to an ‘action’ means the target you’re building no longer has an implicit dependency on the actual string that you are passing to the sub-process shell. You can re-create this dependency by adding the string into your environment.

    e.g., the solution that I personally want looks like:

    import os  cmd = r'''echo its a small world after all \         its a small world after all'''  def my_action(source, target, env):     print cmd     return os.system(cmd)  my_cmd_builder = Builder(     action=my_action,     suffix = '.foo')  env = Environment() env['_MY_CMD'] = cmd  # <-- CREATE IMPLICIT DEPENDENCY ON CMD STRING env.Append( BUILDERS = {'MyCmd' : my_cmd_builder } )  my_cmd = env.MyCmd('foo.foo',os.popen('which bash').read().strip()) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Hmm, I just made a sample table and your query… May 11, 2026 at 8:41 pm
  • Editorial Team
    Editorial Team added an answer Check this link out. You could write a C or… May 11, 2026 at 8:41 pm
  • Editorial Team
    Editorial Team added an answer Yes the tree from Joern Zafferer (bassistance) is good. There… May 11, 2026 at 8:41 pm

Related Questions

In SCons, my command generators create ridiculously long command lines. I'd like to be
Today is officially my first day with C++ :P I've downloaded Visual C++ 2005
I have been getting an error message that I can't resolve. It originates from
In my Java application, I want to run a batch file that calls scons
I didn't give a lot of info in my last question. I've built llv8call

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.