Jump to content
Justin Huang

buildCommand for c/c++ object file

Recommended Posts

Hi,

I'd like to encode the .o/.so buildCommand in IPXACT XML fileSet, such that user can rebuild the .o/.so file from XML.

For example, the .o/.so generation command look like this:

% g++ -c hello.cpp -o hello.o
% g++ hello.o -shared -fPIC -o libhello.so

Should I encode XML fileSet like below?

<ipxact:fileSet>
  <ipxact:file>
    <ipxact:name>hello.cpp</ipxact:name>
    <ipxact:fileType>cppSource</ipxact:fileType>
  </ipxact:file>
  <ipxact:file>
    <ipxact:name>hello.so</ipxact:name>
    <ipxact:fileType>swObjectLibrary</ipxact:fileType>
    <ipxact:buildCommand>
      <ipxact:command>g++</ipxact:command>
      <ipxact:flags>hello.o -shared -fPIC -o hello.so</ipxact:flags>
      <ipxact:targetName>hello.so</ipxact:targetName>
    </ipxact:buildCommand>
    <ipxacxt:dependency>hello.o</ipxacxt:dependency>
  </ipxact:file>
  <ipxact:file>
    <ipxact:name>hello.o</ipxact:name>
    <ipxact:fileType>swObject</ipxact:fileType>
    <ipxact:buildCommand>
      <ipxact:command>g++</ipxact:command>
      <ipxact:flags>-c hello.cpp -o hello.o</ipxact:flags>
      <ipxact:targetName>hello.o</ipxact:targetName>
    </ipxact:buildCommand>
  </ipxact:file>
</ipxact:fileSet>

 

Thanks,

Justin

Edited by Justin Huang
added <ipxact:dependency> element

Share this post


Link to post
Share on other sites

Hello Justin,

The flags element should not contain the whole command; it should contain the flags only. Also you miss a dependency on hello.cpp for hello.o. I would suggest to describe it like this:

		<ipxact:fileSet>
			<ipxact:name>fs-sw</ipxact:name>
			<ipxact:file>
				<ipxact:name>hello.cpp</ipxact:name>
				<ipxact:fileType>cppSource</ipxact:fileType>
			</ipxact:file>
			<ipxact:file>
				<ipxact:name>hello.o</ipxact:name>
				<ipxact:fileType>swObject</ipxact:fileType>
				<ipxact:buildCommand>
					<ipxact:command>g++</ipxact:command>
					<ipxact:targetName>hello.o</ipxact:targetName>
				</ipxact:buildCommand>
				<ipxact:dependency>hello.cpp</ipxact:dependency>
			</ipxact:file>
			<ipxact:file>
				<ipxact:name>hello.so</ipxact:name>
				<ipxact:fileType>swObjectLibrary</ipxact:fileType>
				<ipxact:buildCommand>
					<ipxact:command>g++</ipxact:command>
					<ipxact:flags>-shared -fPIC</ipxact:flags>
					<ipxact:targetName>hello.so</ipxact:targetName>
				</ipxact:buildCommand>
				<ipxact:dependency>hello.o</ipxact:dependency>
			</ipxact:file>
		</ipxact:fileSet>

Best regards,
Erwin

Share this post


Link to post
Share on other sites

Hi Erwin,

What if we used customized inhouse tool to compile hello.c into hello.s (assembly code) and then generate hello.o from hello.s as shown below.

how to describe it in IP-XACT XML?

hello.s: hello.c
    cmd1 flags1
    cmd2 flags2

hello.o: hello.s
    cmd3 flags3

2nd question:

if hello.c includes a few headers, e.g., a.h, b.h, ..., should these header files be listed as dependency in IP-XACT XML?

Share this post


Link to post
Share on other sites

Hi Justin,

It is not possible to describe multiple build commands to support cmd1 and cmd1. Command cmd1 will probably generate an intermediate file that is used for command cmd2. I think you have add this intermediate file to the file set and move cmd2 to the build command for that file.

For the 2nd question, all header files should be listed explicitly in the file set with isIncludeFile set to true. The dependency must be added to the files that include those files or to the whole file set.

Best regards,
Erwin

 

Share this post


Link to post
Share on other sites

Hi Erwin,

Why are the '-c' and '-o' options discarded in the buildCommand section for .o target?

If the command to build a target, e.g., tgt.out from input.txt, is ' exe -i input.txt -o a -opta x -optb y -optc z ', where the '-o' option does not mean output, how to map this command to 'ipxact:command, ipxact:flags, and ipxact:targetName, ipxact:dependency'?

Does ipxact has assumption that each build command should have -o option which means output, and -c option for dependency? How can I know which option should be remved from ipxact:flags?

Thanks,

Justin

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×