Modifying project configuration with command line

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi there,

 

I'm currently looking for a way change project configuration in Atmel Studio 7.0 with some kind of CLI since I need to automate the project building process. Preferably, without having to automate the GUI. For example, I would like to add or remove a symbol.

 

In the picture attached, I can see some kind of command and options are being used for the toolchain compiler, but I'm not sure where I could edit the option values without relying on the GUI.

 

I'm wondering, is there a CLI or maybe a way to dump configs so it can alter the cproj configs I'm using during building. If it can help you, I'm automating the build with python scripts.

 

Thank you for your help in advance!

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm actually considering something similar - Using a python script to automate AVR programming, but to do so while reaching into the .hex output file from the compiler, incrementing a serial number, and moving on.  There exist intelhex modules for Python.

 

What I'd suggest is generating two .hex files, one with your symbol, one without, and then use your python script to choose which .hex file to use.  Leave all the rest of the command line options alone.  If that helps any...

 

Have fun,

 

S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The project properties are stored in a file of type .cproj and it is in XML format. I'm sure Python has a module for reading, parsing and writing XML which might be the way to go.

 

If you go this way you might have a choice to make: XML parsers are generally of two types - "DOM" or "SAX". Both might be available in/for Python.

 

DOM - The complete XML file is read into memory in a tree data structure, which you can traverse and manipulate at will. (DOM - "Document Object Model".) If, for manipulating some node, you are dependent on a value that was earlier in the XML file you just traverse to there and pick up that value. Think of it as "random access" if you like.

 

SAX - The XML file is read and nodes are "reported" sequentially. (SAX - "Simple API for XML".) The SAX parser calls a function in your program for each node (and attribute etc) encountered. If, for manipulating some node, you are dependent on a value that was earlier in the XML file that value had to be saved by your program when it was reported. Think of it as "sequential access" if you like.

 

Unless you know that you need that "random access" then I would advice to go for a SAX parser. The "navigation language" in DOM parsers requires a bit more knowledge and understanding of "XML theory". Not very complicated - but maybe philosophically a bit different from your usual languages and APIs. A complication to avoid unless you need it.

 


 

If the changes are simple/trivial (e.g. just changing the value of an option from one thing to another, then an "ordinary" Python script that reads the file ass plain text and uses regexps for locating and substituting stuff might be the way to go.

 

Sorry, no specifics doing regexps'es and substitution. It's been 10+ years since I did regexp'es in Python, but it definitively is doable.

 


 

If you need and want help understanding the specific format of the project .cproj file then I might be able to toss in some help. Ask ,and we'll wee how good it gets. :-)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your feedback!

 

I opted for different project config made by adding symbols manually in the end. Modifying project files with an xml parser or adding additional hex files wasn't a viable option for our situation unfortunately.

 

Still, I'm working on something else and there seems to be an issue with xml parsers in python and the project file. I tried a few ones (DOM, etree) and they cannot seem to parse the file when they get to the microsoft URL field. Maybe the cproj file format is not standard?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

2Legit2Quit wrote:
they cannot seem to parse the file when they get to the microsoft URL field

Can you be more specific, about

1) Precise Python code (you should be able to produce a minimal but complete Python program/script that demonstrates the problem),

2) Specific error you get, or detailed description of symptoms if there is no actual error,

3) Possibly attach the actual XML (.cproj) file you're trying to parse.

 

As I hinted at earlier, I'm not an authority when it comes to Python as such, but I've meddled with it in the past (we have others here that are swearing on Python being the scripting language, and they might be lured into this thread... ;-)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you tried xml.etree.elementtree in Python? I've had a lot of success using that to read XML in Python.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
SAX parser

Not to be confused with saxophone player ...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
we have others here that are swearing on Python being the scripting language, and they might be lured into this thread

and...

 

Bait was taken..

clawson wrote:
Have you [..] ?

 

;-)

 

 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How many different configurations are you talking about ?

 

In one of my projects I had 5 different configurations varying only by 1 defined symbol and a different target base filename. I tried unsuccessfully to do this in one makefile but the necessity to perform a clean before each build caught me out.

 

I ended up creating 5 separate build configurations. OK - It took me an hour but that was it. Job done. This was in Eclipse mind, and you can build them all iin one hit., I'd be really surprised if Atmel Studio didn't offer a similar feature.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

N.Winterbottom wrote:
the necessity to perform a clean before each build

Why was that necessary?

 

A "bog-standard" makefile might be written so that all build intermediates and results go into the same directories, but it could of-course be written so that different builds go into different sub-directories. You'd have to be meticulous to have all rules written so that dependencies and stuff refers to a varying sub-directory but I can't see why it should not work.

 

Not that this would be easier to do than just going with Studio. I am just curious about the "necessity".

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry for the late response - something to do with the time of year.

 

I was defining various symbols which were used in #ifdef type sections. Unless you clean or otherwise change the directory for build intermediates (.o files) they will not be re-built because the source file hasn't changed.

 

I suppose multiple makefiles in separate directories would suffice. (I think Eclipse uses this technique)

 

I would hope the OP has solved his problem by now - It would be nice to know what he actually did.