473,387 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to retrieve output from makefile build

When building using a makefile, is there a way to retrieve all the output build generated by the make file. Because when i build with a cmd window, all the output of the build shows in the cmd window. But when using the same command in python, it seems that I can't retrieve all the build info. It does build properly but the information I am trying to retrieve is not there. I am using the os.popen function but it is not working well.

My code is:
os.chdir("c:\\ProjectDir")
CmdLine = "makel"
RetBuild = os.popen(CmdLine)
sys.stdout.flush()

# lets find out if the build was a success with no error.
for Line in RetBuild:
# lets write in a log file the return of the build.
fpLog.write(Line)
Mar 13 '07 #1
7 2478
bartonc
6,596 Expert 4TB
When building using a makefile, is there a way to retrieve all the output build generated by the make file. Because when i build with a cmd window, all the output of the build shows in the cmd window. But when using the same command in python, it seems that I can't retrieve all the build info. It does build properly but the information I am trying to retrieve is not there. I am using the os.popen function but it is not working well.

My code is:
Expand|Select|Wrap|Line Numbers
  1.         os.chdir("c:\\ProjectDir")
  2.         CmdLine = "makel"
  3.         RetBuild = os.popen(CmdLine)
  4.         sys.stdout.flush()
  5.  
  6.         # lets find out if the build was a success with no error.        
  7.         for Line in RetBuild:  
  8.             # lets write in a log file the return of the build.
  9.             fpLog.write(Line)
1st: code tags work here, spaces don't.
2nd:
Expand|Select|Wrap|Line Numbers
  1. import sys
  2. logFile = open('fpLog', 'w')
  3. sys.stdout = logFile
  4.  
  5. # do your build
  6.  
  7. logFile.close()
might do the trick.
Mar 13 '07 #2
1st: code tags work here, spaces don't.
2nd:
Expand|Select|Wrap|Line Numbers
  1. import sys
  2. logFile = open('fpLog', 'w')
  3. sys.stdout = logFile
  4.  
  5. # do your build
  6.  
  7. logFile.close()
might do the trick.

Sorry, I forgot to mention that fpLog is from a class i built. So bassically, fpLog.write(Line) write a line in a file. This has no problem, and also I do build using different tools such with visual C++ using the msdev and I do retrieve all the build information. But with the make, I can't retrieve all the build information that I do see when building using directly the command line in a Cmd Window.
Mar 13 '07 #3
dshimer
136 Expert 100+
If you are trying to trap the output of a command to a list of lines try
Expand|Select|Wrap|Line Numbers
  1. RetBuild = os.popen(CmdLine).read().split('\n')
Mar 13 '07 #4
If you are trying to trap the output of a command to a list of lines try
Expand|Select|Wrap|Line Numbers
  1. RetBuild = os.popen(CmdLine).read().split('\n')

One other point is I do retrieve some little information from the build such as this line

(C) Copyright OPUS Software 1987-91. All rights reserved.

This line is probably the compiler header. So I can retrieve this line with no problem in my log file. But the information I am looking is a line at the end of the build to see if the build was successfull such as the following line: Output.out is up to date
This line can only be seen in the Cmd window. But I just can't retrieve it in my file. And I know that I am going through all the lines of the output build since I do build other project using other tools such as Visual Studio, and I can retrieve all the output line with no problem. But with the make file, the os.popen function output only a few lines.
Mar 13 '07 #5
When using the os.system command, I see all of the proper output in my cmd window. It is as if the os.system and os.popen are not returning the same thing
Mar 13 '07 #6
dshimer
136 Expert 100+
When using the os.system command, I see all of the proper output in my cmd window. It is as if the os.system and os.popen are not returning the same thing
Without regard to stdout, and the log file, if you just run
Expand|Select|Wrap|Line Numbers
  1.  RetBuild = os.popen(CmdLine).read().split('\n')
from inside your ide, or python for that matter, does the list stored in RetBuild contain all the information? I'm just trying to establish that there isn't a second issue because I have used this code quite a bit and it generally returns exactly what I'd expect.
Mar 14 '07 #7
Without regard to stdout, and the log file, if you just run
Expand|Select|Wrap|Line Numbers
  1.  RetBuild = os.popen(CmdLine).read().split('\n')
from inside your ide, or python for that matter, does the list stored in RetBuild contain all the information? I'm just trying to establish that there isn't a second issue because I have used this code quite a bit and it generally returns exactly what I'd expect.
Exactly, that is my problem, the popen function, does not return everthing I am expecting. I did try the following but it did only return a couple of lines.

Expand|Select|Wrap|Line Numbers
  1.  RetBuild = os.popen(CmdLine).read().split('\n')
I am not seing the result of the built.
Mar 14 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Gg | last post by:
Hi, I have a project that depends on other projets. So I have a Makefile that calls Makefile of sub-projects to build the libs if needed. Once libs are built, the main Makefile link everything...
4
by: newbiecpp | last post by:
I am very sorry to post this one because I know it is out of topic but I cannot find the proper news group. I understand that most senior C++ programmers know makefile very well. My question is...
4
by: Sharp Tool | last post by:
Hi I have downloaded a program that is written in C++ that I would like to compile into a Win XP executable. The program contains a Makefile written for Unix/linux/cygwin. I would like to...
5
by: Jacobo Rodriguez Villar | last post by:
Hello, Is there any way (or program) to convert and maintain easily a C++ project (vs7.1) to a Makefile file, in order to build it in Linux? Many thanks -- Jacobo Rodríguez Villar ...
4
by: Jess | last post by:
Hello, I am now trying to use makefile to compile C++ programs. My makefile looks like: f1.o : f1.cpp h1.h h2.h g++ -c f1.cpp f2.o : f2.cpp h2.h h3.h g++ -c f2.cpp
0
by: avico83 | last post by:
Hello everyone! I'm having a problem building an image from an opensource code. I'm trying to build the image with the Makefile that came with the source code . There is a Script called by the...
8
by: xz | last post by:
I am a rookie of C++ and got so confused with the Makefile these days. Could anyone be so kind and give a little sample Makefile for the following particular example? Let's say I have the...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
14
by: Anna Smidt | last post by:
After having programmed since 8 years only VB6 I want to learn C++.NET now. It's amazing that everything has to be prepared first. For example I want to build the DirectShow baseclass, but the only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.