Author Topic: suggestion: add "Download" button into Compiler Framework"  (Read 67389 times)

Offline gonboy

  • Multiple posting newcomer
  • *
  • Posts: 29
suggestion: add "Download" button into Compiler Framework"
« on: September 10, 2012, 07:30:40 am »
Hope to

Add "Download" button into Compiler Framework.
you can define command by yourself. and select one "download tool" from the ComboBox.

It's useful for the Embedded Developing!

===========================
other: maybe can add custom tool's buttons(which can enalbe or disable),So you can use it .
« Last Edit: September 10, 2012, 07:37:18 am by gonboy »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #1 on: September 10, 2012, 02:31:26 pm »
other: maybe can add custom tool's buttons(which can enalbe or disable),So you can use it .
You can do thsi already with the Tools / Tools plus plugin. THen, assign a shortcut to this menu entry using the KeyBinder plugin.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #2 on: September 11, 2012, 01:16:38 am »
Add "Download" button into Compiler Framework.
you can define command by yourself. and select one "download tool" from the ComboBox.
Do you have more details on this?  I am not sure if I understand what you want this button to actually do.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #3 on: September 11, 2012, 06:44:34 am »
Do you have more details on this?  I am not sure if I understand what you want this button to actually do.
I guess he means "download to target" for embedded development. Fort this step you usually have to call a certain tool depending on the framework / target platform you use.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Alatar

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #4 on: October 27, 2012, 03:20:19 pm »
I thing it will be more useful to add ability to redefine "Run" action for the target. For example, when I compile for AVR I don`t need to run output binary on host system and I wont to flash it to target MCU. It is comfortably to use same key for this action that I use to run desktop program.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #5 on: October 27, 2012, 10:29:27 pm »
I thing it will be more useful to add ability to redefine "Run" action for the target. For example, when I compile for AVR I don`t need to run output binary on host system and I wont to flash it to target MCU. It is comfortably to use same key for this action that I use to run desktop program.

Couldn't he just make the executable target a script that does whatever he wants with the remote system?

Offline Alatar

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #6 on: November 01, 2012, 06:38:21 am »
But how can I do this in current trunk version?

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #7 on: November 03, 2012, 08:00:30 pm »
Project->Set programs' arguments then change the Host Application to a script that does whatever you need it to.

Offline Alatar

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #8 on: December 14, 2012, 02:10:30 pm »
>> Project->Set programs' arguments then change the Host Application to a script that does whatever you need it to.

Thanks, but you forget to tell me, that first I need to change Target type to "Dynamic library" and disable some library-specific options. =)
Second there is no variables substitution in this dialog, so I need to write target manually and edit it, if I copy or edit target. Additionally, I can`not change "pause when execution ends" for library target and I need to change options related to Run action in two different places ("Project->Properties...->Build Targets" and "Project->Set programs' arguments").
So I think this future need some redesign =).
By the way, can I send program`s output somewhere to "Logs & others" panel (to "Code::Blocks", "build log", or to separate tab, like in Tools+)? Another idea - allow to launch Tools/Tools+ command on "Run".

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #9 on: December 14, 2012, 03:37:51 pm »
Another idea - allow to launch Tools/Tools+ command on "Run".
You can do this already now by using macros in the Tools/Tools+ setup.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #10 on: December 14, 2012, 03:47:32 pm »
Adding variable substitution to the run target would be a useful feature I think.

I was also hoping to convince the other devs to make the "commands only" target runnable. This would add some flexibility as well.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #11 on: December 14, 2012, 04:25:42 pm »
Adding variable substitution to the run target would be a useful feature I think.
What do you mean by that? I didn't get the idea.

I was also hoping to convince the other devs to make the "commands only" target runnable. This would add some flexibility as well.
You know usually its easier to convince people with a patch... ;D
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #12 on: December 15, 2012, 02:39:38 am »
Adding variable substitution to the run target would be a useful feature I think.
What do you mean by that? I didn't get the idea.

Just to run the standard macro substitutions on the assembled command line string for the run target after the user clicks run (assume that we don't already do this?)

Quote
I was also hoping to convince the other devs to make the "commands only" target runnable. This would add some flexibility as well.
You know usually its easier to convince people with a patch... ;D

But of course ;) unless someone wants to get in ahead of me. :) Wasn't sure what the rationale was for commands only and whether it was a conscious decision that it should not be "runnable"

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #13 on: December 15, 2012, 08:58:24 am »
Wasn't sure what the rationale was for commands only and whether it was a conscious decision that it should not be "runnable"
Well the issue here is: What to run? There is no executable produced or alike. So it will need some tweaking - currently C::B would report that the executable has not been built yet. Note that pre- and post-build steps actually should work. So what exactly would you "run"?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Alatar

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #14 on: December 15, 2012, 01:12:22 pm »
Another idea - allow to launch Tools/Tools+ command on "Run".
You can do this already now by using macros in the Tools/Tools+ setup.

Can you explain me how to do this? I don`t found.
I`m work with different MCU type at same time and each of them use his own download tool. I can create several Tools+ items and bind them to keyboard shortcuts but I need to remember which shortcut I need to use with current project. It will be more comfortable if I press F9 and CB build and download firmware with Tools+ item selected in project settings.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #15 on: December 15, 2012, 03:27:15 pm »
Wasn't sure what the rationale was for commands only and whether it was a conscious decision that it should not be "runnable"
Well the issue here is: What to run? There is no executable produced or alike. So it will need some tweaking - currently C::B would report that the executable has not been built yet. Note that pre- and post-build steps actually should work. So what exactly would you "run"?

If it is an interpreted language, it would be the command to run the main module. No "build" is required but there might some deployment steps that could be put in the pure/post build commands.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #16 on: December 16, 2012, 07:41:15 am »
If it is an interpreted language, it would be the command to run the main module. No "build" is required but there might some deployment steps that could be put in the pure/post build commands.
And what would be the difference to a pre-/ post-build step in the commands only target? (Sorry to maybe sound dumb - but I still don't see the advantage and seem missing the obvious...?!)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #17 on: December 16, 2012, 04:17:04 pm »
If it is an interpreted language, it would be the command to run the main module. No "build" is required but there might some deployment steps that could be put in the pure/post build commands.
And what would be the difference to a pre-/ post-build step in the commands only target? (Sorry to maybe sound dumb - but I still don't see the advantage and seem missing the obvious...?!)

My idea is that interpreted (or any other non-compiled) projects be able to use the build framework like compiled projects. Seems a little odd that you would have to press build to run the project right? I can see cases where you would want to define both build and run.The build steps would only need to be run if there are changes to sources (e.g. resources might need to be repackages into zip files). The run command should run the main module. I have several small projects that could take advantage of this.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #18 on: December 16, 2012, 06:48:58 pm »
My idea is that interpreted (or any other non-compiled) projects be able to use the build framework like compiled projects.
Oh - OK. But doesn't this require even more changes? Like adopting the build framework?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #19 on: December 16, 2012, 08:43:14 pm »
Assuming I understand the idea being discussed, the following would be the core of the necessary changes (I think):
Code
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 8684)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -1880,9 +1880,15 @@
     else
     {
         // commands-only target?
-        cbMessageBox(_("You can't \"run\" a commands-only target..."));
-        m_pProject->SetCurrentlyCompilingTarget(0);
-        return -1;
+        if (target->GetHostApplication().IsEmpty())
+        {
+            cbMessageBox(_("You must select a host application to \"run\" a commands-only target..."));
+            m_pProject->SetCurrentlyCompilingTarget(0);
+            return -1;
+        }
+        Manager::Get()->GetMacrosManager()->ReplaceEnvVars(hostapStr);
+        command << hostapStr << strSPACE;
+        command << target->GetExecutionParameters();
     }
 
     wxString script = command;
@@ -1903,7 +1909,7 @@
         cmd << command;
 
     Manager::Get()->GetLogManager()->Log(_("Checking for existence: ") + f.GetFullPath(), m_PageIndex);
-    if (!wxFileExists(f.GetFullPath()))
+    if ( (target->GetTargetType() != ttCommandsOnly) && !wxFileExists(f.GetFullPath()) )
     {
         int ret = cbMessageBox(_("It seems that this project has not been built yet.\n"
                                 "Do you want to build it now?"),
(Note: this code was very quickly stuck together; do not commit without changing/fixing/polishing.)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #20 on: December 16, 2012, 10:03:47 pm »
Assuming I understand the idea being discussed, the following would be the core of the necessary changes (I think):
Well if thats what dmoore means its OK with me. But I assumed he means even more: Like calling a certain pre-compiler in the build stage... but I might think too complicated...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #21 on: December 17, 2012, 02:36:58 am »
For now, Alpha's patch is good enough for me  :) (I haven't tested yet)

I would need to think about what else, if anything, is really needed.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #22 on: December 17, 2012, 03:14:27 pm »
For now, Alpha's patch is good enough for me  :) (I haven't tested yet)
OK, nice - well that is easy, indeed.

(Note: this code was very quickly stuck together; do not commit without changing/fixing/polishing.)
Put it to the queue once ready...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #23 on: December 17, 2012, 04:47:38 pm »
Put it to the queue once ready...
Okay; will do after I finish testing.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #24 on: December 17, 2012, 06:21:17 pm »
A couple of suggested tweaks:

Code
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 8685)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -1880,9 +1880,16 @@
     else
     {
         // commands-only target?
-        cbMessageBox(_("You can't \"run\" a commands-only target..."));
-        m_pProject->SetCurrentlyCompilingTarget(0);
-        return -1;
+        if (target->GetHostApplication().IsEmpty())
+        {
+            cbMessageBox(_("You must select a host application to \"run\" a commands-only target..."));
+            m_pProject->SetCurrentlyCompilingTarget(0);
+            return -1;
+        }
+        command << hostapStr << strSPACE;
+        command << target->GetExecutionParameters();
+        Manager::Get()->GetMacrosManager()->ReplaceMacros(command, target);
+        Manager::Get()->GetMacrosManager()->ReplaceEnvVars(command);
     }
 
     wxString script = command;
@@ -1903,12 +1910,12 @@
         cmd << command;
 
     Manager::Get()->GetLogManager()->Log(_("Checking for existence: ") + f.GetFullPath(), m_PageIndex);
-    if (!wxFileExists(f.GetFullPath()))
-    {
+    if ( (target->GetTargetType() != ttCommandsOnly) && !wxFileExists(f.GetFullPath()) )
+     {
         int ret = cbMessageBox(_("It seems that this project has not been built yet.\n"
-                                "Do you want to build it now?"),
-                                _("Information"),
-                                wxYES_NO | wxCANCEL | wxICON_QUESTION);
+                                 "Do you want to build it now?"),
+                               _("Information"),
+                               wxYES_NO | wxCANCEL | wxICON_QUESTION);
         switch (ret)
         {
             case wxID_YES:

Should also do something about the linker message and maybe remove (disable) the irrelevant build options tabs.
« Last Edit: December 17, 2012, 07:34:48 pm by dmoore »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: suggestion: add "Download" button into Compiler Framework"
« Reply #25 on: December 18, 2012, 01:25:44 pm »
@Alpha: awesome  8) thanks