Helpful ReplyHot!Can i build MPLAB.X projects from the command line?

Page: 12 > Showing page 1 of 2
Author
ca
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2011/10/06 05:15:31
  • Location: 0
  • Status: offline
2012/06/26 02:30:32 (permalink)
5 (1)

Can i build MPLAB.X projects from the command line?

Basically, we have a build server and would like it to build our MPLAB.X projects (just like it builds our Visual Studio projects).
This requires (well other ways are possible but are just not really an option) MPLAB.X to be invoked from the command line without starting the GUI.
Is this possible and if so where do I find the tutorial :) ?
 
/Claus
#1
Jose Diaz
Administrator
  • Total Posts : 1672
  • Reward points : 0
  • Joined: 2010/06/23 11:10:56
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2012/06/26 14:46:06 (permalink)
+1 (1)
You can. In Windows, add as the first thing to your path: $instDirMPLABX\gnuBins\GnuWin32. Then in a terminal (cmd . exe) cd to the MPLAB X folder (the one containing the nbproject directory). Then type make.
If you have several configurations you need to tell make which configuration to make. If the configuration is called other:
c:XXXX> make -f nbproject/Makefile-other.mk SUBPROJECTS= .build-conf
For Linux just make sure make is installed (most likely it will be). For Mac, install XCode ( to get the GNU make) simply use the one that comes with MPLAB X by adding to the path /Applications/microchip/mplabx/mplab_ide.app/Contents/Resources/mplab_ide
which is where make is stored.
#2
ca
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2011/10/06 05:15:31
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2012/06/27 03:03:03 (permalink)
0
Using make fits perfectly in my environment (already using it)
My scenario is as follows:
We have developers using both Windows and Linux (all using MPLAB.X).
We use Subversion and use Jenkins as build server.
Which project files should I commit to Subversion?
Will the mix of Windows and Linux result in any problems (due to different path formats or other)?
#3
Jose Diaz
Administrator
  • Total Posts : 1672
  • Reward points : 0
  • Joined: 2010/06/23 11:10:56
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2012/06/27 16:29:20 (permalink)
0
I cannot type an answer here since some characters are flagged as 'dangerous' and the post aborts..
So, please read my comments in the attached file.
 

Attachment(s)

Attachments are not available: Download requirements not met
#4
ca
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2011/10/06 05:15:31
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2012/06/27 21:18:38 (permalink)
0
Ok so this matches what we were experiencing ourself.
The best workaround we could come up with is to fire up MPLAB.X on the build server to make it generate those file that are not under version control. We've added
Makefile
nbproject/configurations.xml
nbproject/project.xml
To version control and MPLAB.X then generates the remaining files once it starts.
After a minute or so MPLAB.X would usually be done generating those files and we would kill it of (possibly in a not so pretty way). We can now call make.
 
I find it very hard to believe that a full blown IDE as netbeans does not support something like this. Is it a netbeans issue or a restriction caused by the MPLAB.X "customization"?
#5
tony4l
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2003/11/07 12:36:16
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2012/07/09 05:03:32 (permalink)
0
Now, you want to try and avoid having to run the IDE to recreate the projects?. It gets more complicated and not really officially supported.

 
May I suggest to rethink this strategy?
 
1. Having the possibility to use make to build projects is a blessing. Building a project using a simple command is industry standard and supports high-level integration builds. It would add to the number of award-winning features for MPLABX if that could be on the list of features.
 
2. The need to exclude (.gitignore) the files
nbproject/Makefile-*
nbproject/Package-*
nbproject/private
nbproject/private/*
creates a problem for git users. When you check out a different branch of the same project that contains a different fileset to build, MPLABX will not notice that its source files have changed and fails to regenerate its private Makefiles. This creates an extra-cumbersome needs to shutdown MPLABX, manually clear the build directory and restart MPLABX.
 
Both are showstoppers for integrating MPLABX into a workflow with an CI-Server based on git source control.
 
Thanks,
T
 

beware of ASCII characters when posting. better safe than sorry!
#6
ZanderChief
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2013/01/17 00:53:54
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/01/17 00:58:50 (permalink)
0
I also find it hard to believe this is not supported.
 
Many of use have intentions to automate builds and testing. This can not be done (easily) when the process is so tightly coupled with the IDE.
 
Thanks,
Chris
#7
Jose Diaz
Administrator
  • Total Posts : 1672
  • Reward points : 0
  • Joined: 2010/06/23 11:10:56
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/01/18 17:38:01 (permalink)
0
We are working on a utility which you can run from the command line that will take an MPLAB X project and will regenerate the makefiles without having to open the IDE.
It'll be done in the first half of this year. So, you will not have to run the whole IDE in some special GUI-less mode. A light weight utility will do it.
You also have makefile projects coming in v1.7 where you tell MPLAB X what to run for debug and for production images so you have total control (and you need to create your own ant/maven/make/cmake, etc files).
So until we get the regeneration utilty done, you need to open the IDE to regenerate the files.
"I find it very hard to believe that a full blown IDE as netbeans does not support something like this"
The reason for the current design is that NetBeans C/C++ regenerates makefiles when the IDE is open. We based our design in NetBeans C/C++. 
 
"May I suggest to rethink this strategy?"
The utility has been in the plan for a long time. We just have not gotten to it. 
Jose
 
#8
pflieger
New Member
  • Total Posts : 26
  • Reward points : 0
  • Joined: 2012/12/03 22:24:27
  • Location: Fort Wayne, IN
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/03/06 12:11:30 (permalink)
0
Well, Jose, I guess I'll wait. Since my server is headless, there's no way I can open the IDE on my Linux box. I think we're going to get another system up and running, copy over the source and configs, build, capture the make files, move them to our linux box...
 
Ugh, but hey the IDE is free so I guess you get what you pay for.
#9
mike_jones
New Member
  • Total Posts : 30
  • Reward points : 0
  • Joined: 2013/03/05 20:24:13
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/03/06 20:47:55 (permalink)
0
Check this out
http://www.microchip.com/forums/m652420-print.aspx
 
You will have to copy C:\Program Files (x86)\Microchip\MPLABX\gnuBins\GnuWin32 and issue make.
#10
Jose Diaz
Administrator
  • Total Posts : 1672
  • Reward points : 0
  • Joined: 2010/06/23 11:10:56
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/03/08 10:49:11 (permalink)
+2 (1)
Mike,
Thaks for the link.
There are two issues:
1) Can I build from the command line. Yes (as explained in your link)
2) Can I re-create the makefiles from the command line so that a make runs in a different machine?. Not yet. We are working in the utility that will allow you to do this.We will make this happen.
Jose
 
#11
bfoz
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2007/03/30 14:03:58
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/03/31 14:21:16 (permalink)
0
Thanks for the update Jose.
 
Any idea when this utility will be ready? I see the earlier post that said "in the first half of the year", but can you be more specific?
 
I'm looking at setting up some rake tasks for compiling, etc. and I'm wondering how I should plan to architect it. Once the regen-utility is available I imagine I could have the Rakefile shell out to the generated Makefile. In the meantime, is the set of commands that the Makefile calls stable enough that I could replicate them in a rake task? Is the project file format documented well enough that I could write a gem to parse it and generate the commands to run?
 
Thanks for any help.
#12
ch
Starting Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2011/04/19 02:06:27
  • Location: Autriche
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/04/02 04:25:40 (permalink)
0
I'd also like to see this tool.
Also, it'd be great if the IDE and the Compilers could be installed without having to run X11.
#13
Jose Diaz
Administrator
  • Total Posts : 1672
  • Reward points : 0
  • Joined: 2010/06/23 11:10:56
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/04/02 07:44:09 (permalink)
0

bofz,
The utility is being tested. I am not sure if it will make it into v1.80.

" In the meantime, is the set of commands that the Makefile calls stable enough that I could replicate them in a rake task? Is the project file format documented well enough that I could write a gem to parse it and generate the commands to run? "

I would really recommend you wait for the utility to come out. There are a lot of nuances in creating a makefile for a project. For example: some options to the compiler are adjusted based on the version of the compiler. You do not want to deal with that.

This is what the utility does. Please undestand that this might change since we have not released it yet. I am just trying to give you a flavor of it so you can plan for the future.

c:\Program Files (x86)\Microchip\MPLABX\mplab_ide\bin>prjMakefilesGenerator
prjMakefilesGenerator [-help] [-v] [project_path[:config_name]*]+
        <project_path> - path to the MPLAB-X project in the file system
        [config_name]  - (optional) name of a build configuration to generate the makefile for.
                         If missing, the makefiles are generated for all the build configurations.

        -help          - displays this help screen.
        -v             - verbose processing.
        Example: prjMakefilesGenerator /home/usr/prj1:default:custom /home/usr/prj2 /home/usr/prj3:xc16
        The tool will generate the makefiles for:
          1.    The configurations named 'default' and 'custom' of the project named 'prj1'
          2.    All the configurations of the project named 'prj2' (all because none in particular is specified)
          3.    The configuration named 'xc16' of the project named 'prj3'

So if you pass the path to a project it will recreate all the makefiles for all configurations. If you pass the configuration names, it will only recreate the makefiles for those configurations.

This utility will follow the very same algorithm that IDE would follow to create the makefiles.

Jose
PS. The utility is a batch file that runs a java program. Shell scripts will be available for Linux/Mac
#14
Jose Diaz
Administrator
  • Total Posts : 1672
  • Reward points : 0
  • Joined: 2010/06/23 11:10:56
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/04/02 08:15:18 (permalink)
0
ch,

You can try:
$ sudo ./MPLABX-v1.XX-linux-installer.run --mode text
$ sudo ./xc32-v1.XX-linux-installer.run --mode text

Note that that this is not an officially tested way of installing the IDE but it should work.
 
#15
bfoz
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2007/03/30 14:03:58
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/04/02 10:09:31 (permalink)
0
Thanks. You're right, I probably don't want to deal with handling all of the compiler versions, so I'll try to wait for the tool.
 
If you need someone to help test the new utility, let me know.
#16
Guest
Super Member
  • Total Posts : 80499
  • Reward points : 0
  • Joined: 2003/01/01 00:00:00
  • Location: 0
  • Status: online
Re:Can i build MPLAB.X projects from the command line? 2013/04/03 06:03:12 (permalink)
0
Jose,
 
Thanks, indeed that does work.
 
In the meantime, I've a little NetBeans plugin that works like this:
run mplab_ide with --openallconfigs /path/to/project
This will activate all the available configurations and therefore recreate the makefiles.
Plugin is available here: https://github.com/zeha/at.zeha.netbeans.cliglue
 
-ch
 
#17
jswanson
Super Member
  • Total Posts : 296
  • Reward points : 0
  • Joined: 2003/11/07 12:44:05
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/04/04 01:48:55 (permalink)
0
Hi Jose,
 
I used your suggestions as to which files to include in revision control. However, I find that if the configurations are modified on one machine the project will not load on another giving a "Error in XML".  Deleting the local private folder and reloading fixed the problem.  Is this correct?
 
Jeremy.
#18
Jose Diaz
Administrator
  • Total Posts : 1672
  • Reward points : 0
  • Joined: 2010/06/23 11:10:56
  • Location: 0
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/04/04 09:04:58 (permalink)
0
No, the "Error in XML" happens if the configurations.xml is not well formed.
I am not sure what happened there. Please look at:
http://www.microchip.com/forums/fb.ashx?m=716409
 
#19
ch
Starting Member
  • Total Posts : 44
  • Reward points : 0
  • Joined: 2011/04/19 02:06:27
  • Location: Autriche
  • Status: offline
Re:Can i build MPLAB.X projects from the command line? 2013/05/06 15:59:08 (permalink)
0
I see prjMakefilesGenerator has now shipped in 1.80 (as a beta).
Thanks for making this happen.
 
Appears to work properly with XC32, but for XC8 projects, an additional option is given in the generated Makefile:
"--output=-mcof,+elf"
This causes the build to abort, with this error message:
:: error: unknown suboption "elf" 
#20
Page: 12 > Showing page 1 of 2
Jump to:
© 2017 APG vNext Commercial Version 4.5