User forums > Using Code::Blocks

Command line build and environment variables

(1/2) > >>

cacb:
I am using Nightly Build 7789 on WinXP at the moment

I have a C::B workspace with a few projects that builds nicely in the IDE. I would like to also be able to build from the command line. I am trying this:

$\> codeblocks.exe --rebuild --target=W32_Release --no-batch-window-close MyApp.workspace

It starts out ok by cleaning the projects (since I requested rebuild), but it later fails because of missing include directories. More specifically, it fails to resolve this search directory specification in one of the projects

$(CPDE_USR)\include

where CPDE_USR is an environment variable I have defined inside Code::Blocks using
Settings -> Environment -> Environment Variables

These variables are defined under the 'deafult' envvar set

How can I get C::B to use the definition of such environment variables when building from command line?

MortenMacFly:

--- Quote from: cacb on March 05, 2012, 11:30:39 am ---How can I get C::B to use the definition of such environment variables when building from command line?

--- End quote ---
First of all, make sure the plugin is actually active in batch build. Usually it is not.

Alternatively (if it shall really be an envvar), make it present in the shell you are executing C::B from, by setting it.

Alternatively (if you don't know) instead of using the envvars plugin you can safely also use the "custom variables" tab of the build settings of you project. In your case as you use an envvar for a path, this makes more sense IMHO, because you don't need to depend on the envvars plugin (sure you can, if you wish).

cacb:
Thank you, that answered my question

For the record, I now used
Settings -> Compiler and debugger -> Batch build
... and checked "Environment Variables" under 'plugins to load in batch-build mode'

Now it seems to build ok.

I was aware of the option to define the variable in the shell, but as a policy I want to keep the definition in once place, within Code::Blocks.

I see your point about "custom variables", but some of these definitions are shared between many projects and are also different on different machines. I could perhaps use global variables, but somehow I settled on the envirinment variables.

Follow up question1: I have tried to suppress the "Batch build" dialog that pops up (it is useful sometimes), but it seems to come always. Shouldn't --log-to-file suppress it and send the same output to file? I can't get it to work.

Follow up question 2: When I specify the workspace file, will all projects be built or just the one which is marked as 'active' ?

cacb:

--- Quote from: cacb on March 05, 2012, 12:46:56 pm ---Follow up question1: I have tried to suppress the "Batch build" dialog that pops up (it is useful sometimes), but it seems to come always. Shouldn't --log-to-file suppress it and send the same output to file? I can't get it to work.

Follow up question 2: When I specify the workspace file, will all projects be built or just the one which is marked as 'active' ?

--- End quote ---

I have looked at http://wiki.codeblocks.org/index.php?title=Code::Blocks_command_line_arguments
and experimented with the parameters. Apparently, there is no way to suppress the batch build dialog as far as I can tell. I think that means you cannot run batch buld from e.g. a crontab job undel linux, perhaps the same is true for scheduled tasks under Windows.

I have reproduced similar command line parameters from 2 other IDEs I have used, for comparison of possible missing command line parameters to C::B. It seems to me one omission in C::B is the ability to specify which workspace project should be built (or whole workspace). It is possible to specify a *.cbp instead of *.workspace files, but then it seems dependent projects are not built.


--- Quote from: MS Visual Studio 6.0 ---Usage:
  MSDEV [myprj.dsp|mywksp.dsw]  - load project/workspace
        [<filename>]            - load source file
        /?                      - display usage information
        /EX <macroname>         - execute a VBScript macro
        /OUT <filename>         - redirect command line output to a file
        /USEENV                 - ignore tools.options.directories settings
        /MAKE [<target>] [...]  - build specified target(s)
              [<project> - <platform> <configname>]
              [[<project>|ALL] - [DEBUG|RELEASE|ALL]]
              /CLEAN            - delete intermediate files but don't build
              /REBUILD          - clean and build
              /NORECURSE        - don't build dependent projects

--- End quote ---



--- Quote from: MS Visual Studio 2008 Express ---Command line builds:
devenv solutionfile.sln /build [ solutionconfig ] [ /project projectnameorfile [ /projectconfig name ] ]
Available command line switches:

/Log   Logs IDE activity to the specified file for troubleshooting.
/ResetSettings   Restores the IDE's default settings, optionally resets to
   the specified VSSettings file.
/SafeMode   Launches the IDE in safe mode loading minimal windows.


--- End quote ---

Jenna:
run codeblocks --help from a console to see the possible parameters.
You can specify a target with --target= .

The normal C::B does not work without a running xserver, but there is an experimental branch I started about a year (or so) ago, that is able to create a pure console-version of C::B.
It does not load any plugins, but the compiler-plugin, because all the plugins need an xserver (at the moment).

you can check out the sources via
--- Code: ---svn checkout https://svn.berlios.de/svnroot/repos/codeblocks/branches/codeblocks_console [path_to_local_repo]
--- End code ---
and then build the console-app-target, call src/update_con and run the app via output/run_con.sh .

output/run_con.sh --help shows the available parameters. You can copy the output folder to any place you want and run C::B for console through the run_con.sh-script.

The sources do not reflect the actual trunk, but should work.

I don't remember at the moment, whether variable expansion and global variables work or not, so you have to try it yourself.

If I find the time, I continue working on the branch.

Navigation

[0] Message Index

[#] Next page

Go to full version