how to setup options for compiler

CodeLite installation/troubleshooting forum
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

how to setup options for compiler

Post by hbr_in »

Hi,

I would like to setup a different directory for build output. At present it always point to the workspace folder.

Also how to attach a custom makefile & CUSTOM Make command.

Regards
Gururaja
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: how to setup options for compiler

Post by eranif »

When using CodeLite internal makefile generator (i.e. not custom build), you can change it from:
Project context menu -> General -> IntermediateDirectory

- To setup a custome makefile:
Project context menu -> Custom Build

and enable there the 'Enable custom build'

Once enabled, set the build and clean commands (optionaly the single file build command).
build: make
clean: make clean
single file (if your makefile supports it): make $(CurrentFileFullPath)
http://www.codelite.org/LiteEditor/ProjectSettings
Eran
Make sure you have read the HOW TO POST thread
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

HI,

Thanks for the link. Sorry i couldnt find it b4.

OK here it is,

I have set working directory to a directory different than the directory where workspace & project files is saved.
Now Compilling & Building Works fine.

But still, i see that the output files are generated inside the project directory.

TIA

IS it possible to provide more info while building, cleaning, compiling. Like from which directory compilation/building/cleaning has started.

Regards
Gururaja
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: how to setup options for compiler

Post by eranif »

hbr_in wrote:But still, i see that the output files are generated inside the project directory.
Can u please post here the command u set in the 'Build Command' & 'Clean Command' ?

I suspect that it has nothing to do with CodeLite, but more of the way your compiler behaves. However, I need to see the commands you set in order to provide better assistance.

Eran
Make sure you have read the HOW TO POST thread
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

eranif wrote:
hbr_in wrote:But still, i see that the output files are generated inside the project directory.
Can u please post here the command u set in the 'Build Command' & 'Clean Command' ?

I suspect that it has nothing to do with CodeLite, but more of the way your compiler behaves. However, I need to see the commands you set in order to provide better assistance.

Eran
Working Directory - C:\prj\sd_fat\testing\bootloader\prj\Release
Build command - runmk C:\prj\sd_fat\testing\bootloader\prj\bootloader.prx
Clean Command - runmk -r C:\prj\sd_fat\testing\bootloader\prj\bootloader.prx
Single File Build Command - runcc -c +s -pcustCpu +Wccrunner,-Wundef,-Wall $(CurrentFileFullPath)


Both runmk & runcc commands create object fils inside <current_dir>\ccwork folder

My Codelite Workspace file is in
C:\users\hebbar\project\process\Tests\codelite\codelite_wrkspc\

My Project File is in
C:\users\hebbar\project\process\Tests\codelite\codelite_wrkspc\prj_bootloader

Object File are built inside
C:\users\hebbar\project\process\Tests\codelite\codelite_wrkspc\prj_bootloader\ccwork\

But they are supposed to be built inside
C:\prj\sd_fat\testing\bootloader\prj\Release\ccwork

Is it possible to provide more info while building, cleaning, compiling. Like from which directory compilation/building/cleaning has started.


Thanks for the Consideration.

Regards
Gururaja
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: how to setup options for compiler

Post by eranif »

hbr_in wrote:runmk C:\prj\sd_fat\testing\bootloader\prj\bootloader.prx
I am assuming that the .prx file are some sort of project files and the answer is probably is inside that scripts.

Using a custom build commands, tells codelite that the build is handled by the user, so codelite simply executes the command that your provided him with, and nothing more.
It has no control over location of the object files - it is part of the .prx file. If you want, you can try and post one of the files here, and maybe by looking at it, I might have an idea of how to change the location of the output files.

Btw, instead of hard-coding the path to the project, you might want to use one of these macros:

Code: Select all

$(WorkspacePath)
$(ProjectPath)
hbr_in wrote:Single File Build Command - runcc -c +s -pcustCpu +Wccrunner,-Wundef,-Wall $(CurrentFileFullPath)
By looking at this command, I belive you can define a new compiler to codelite and use it, instead of the custom build steps.

Eran
Make sure you have read the HOW TO POST thread
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

eranif wrote:
hbr_in wrote:runmk C:\prj\sd_fat\testing\bootloader\prj\bootloader.prx
I am assuming that the .prx file are some sort of project files and the answer is probably is inside that scripts.
This project File just contains details abt the files that is included and project settings i.e., warning level, debug mode, output format, map file generation and noting related to output directory. I have attached it below for your reference
eranif wrote: Using a custom build commands, tells codelite that the build is handled by the user, so codelite simply executes the command that your provided him with, and nothing more.
Yes this is true. But command needs to be executed in the working directory that is set. At present, this commands creates a directory called "ccwork" from anywhere it is executed. So, we need to 1st move to working directory & then execute the command. I tested it in DOS Command Prompt, by creating a dummy dir "c:\dummy" & executed this command. This created a new directory called "ccwork" inside "c:\dummy" & created the object files there.
eranif wrote: It has no control over location of the object files - it is part of the .prx file. If you want, you can try and post one of the files here, and maybe by looking at it, I might have an idea of how to change the location of the output files.

Code: Select all

<project name="Project" processor="custcpu">
    <file type="a" name="int_is.s" path="../working"/>
    <file type="c" name="timer.c" path="../working"/>
    <file type="c" name="uart.c" path="../working"/>
    <file type="c" name="interrupts.c" path="../working"/>
    <file type="c" name="main.c" path="../working"/>
    <active cfg="<None>"/>
    <option id="link.cfg" value="C:/prj/sd_fat/testing/bootloader/prj/custcpu.bcf"/>
    <option id="link.map.call" value="on"/>
    <option id="link.map.ref" value="on"/>
    <option id="cpp.wundef" value="on"/>
    <option id="assem.ass.wunreach" value="on"/>
    <option id="cc.warnlevel" value="high"/>
    <option id="project.disa" value="on"/>
    <option id="project.name" value="bootloader"/>
    <option id="project.type" value="exe"/>
</project>
eranif wrote:
hbr_in wrote:Single File Build Command - runcc -c +s -pcustCpu +Wccrunner,-Wundef,-Wall $(CurrentFileFullPath)
By looking at this command, I belive you can define a new compiler to codelite and use it, instead of the custom build steps
Yes i can use. But
1. Cl doent provide a working directory option for compiler to execute.
2. Compiler Switches cannot be added/changed/removed.


Is it possible to give example code for compiler warning pattern. since i am new to regex pattern, i am unable to add the regex pattern for the that my compiler gives. Its something like this

Code: Select all

Warning in "C:/Program Files/New_compiler/Processv/designs/process/lib/process_sfloat.h", line 50, column 37: value 2147483648 converted to type `int' cannot be represented whole, sign wrapped to -2147483648

TIA

Regards
Gururaja
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: how to setup options for compiler

Post by eranif »

hbr_in wrote:Yes this is true. But command needs to be executed in the working directory that is set. At present, this commands creates a directory called "ccwork" from anywhere it is executed. So, we need to 1st move to working directory & then execute the command. I tested it in DOS Command Prompt, by creating a dummy dir "c:\dummy" & executed this command. This created a new directory called "ccwork" inside "c:\dummy" & created the object files there.
They are - codelite first set the working directory and then executes the command provided in the 'Build Command'.

To prove my point, set the following commands:
Working Directory: C:\prj\sd_fat\testing\bootloader\prj\Release
Build Command: mkdir dummy_dir

on my machine, this creates the directory inside the working directory.

A possiblem failure cause:
Does this C:\prj\sd_fat\testing\bootloader\prj\Release exist? It MUST be exist in order for the 'set working directory' operation to succeed

HTH,
Eran
Make sure you have read the HOW TO POST thread
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

ok. I think i need to explain in detail.

My
1. project Files (*.c, *.s, *.h) are saved in C:\prj\sd_fat\testing\bootloader\working . Lets call it PRJ_WORK_DIR
2. Codelite Files related to project (prj_bootloader.mk, prj_bootloader.project) are in C:\users\hebbar\project\Tests\codelite\codelite_wrkspc\prj_bootloader . Lets call it CL_PRJ_FILES_DIR
3. I want my project output(object, map, list files etc to be built inside C:\prj\sd_fat\testing\bootloader\prj\release . Lets call it PRJ_OUT_DIR

All these folder exist. Including PRJ_OUT_DIR


1. I have set my compiler detilas in Settings -> Build Settings. Added new Compiler "cust_comp" . Added Compiler Name "runcc"
2. In Workspace tab - project "prj_bootloader" - right click -> Settings window
i have set
a. compiler - cust_comp
b. Output File field - blank
c. Intermediate Directory - release (it was ./release b4 but i used to get error. My compiler doesnt support ./)
d. command - ./$(ProjectName)
e. Working Directory - C:/prj/sd_fat/testing/bootloader/prj/ ( since i need files inside PRJ_OUT_DIR & CL adds (IntermediateDirectory) to (Working Directory) )
f. Configuration Type - Release
g. Compiler Tab -> Compiler Options - -Wundef -Wall

I have imported 1 folder & created 2 Virtual Directories inside it. So in workspace tab i have
codelite_wrkspc
|
|-prj_bootloader
|
|-working
|
|-headers
|
|-command.h
|-common.h
|-src
|
|-command.c
|-common.c


My Custom Compiler creates a directory called "ccwork" inside directory it is being called. while compiling it places all object files into this directory

Now according to what i believe,
When i click on common.c & select compile, the object files should be built inside PRJ_OUT_DIR/release

But, after select compile from right click context menu on common.c, i get

Building: "C:/cygwin/bin/make.EXE" -j 2 -f "prj_bootloader.mk" type=Release ./release/common.o
----------Building project:[ prj_bootloader - Release ] (Single File Build)----------
runcc -c "C:/prj/sd_fat/testing/bootloader/working/common.c" -Wundef -Wall -o ./release/common.o
Configuration: Release
Compiling "common.c"
..snip..
..snip..
Compilation finished successfully
----------Build Ended----------

And Files are created inside CL_PRJ_FILES_DIR/ccwork.

So now what to do.


I have few doubts/ need clarification for below

1. In the Coonfiguration Manager window, For Workspace Configuration, i get only "Debug, <New>, <Edit>" options. No Release Option. Do i need to set something to get Release as default Configuration Type for all projects


2. I found 3 Options for build/clean/rebuild as below
1. Build/Clean/Rebuild Wokspace -> in Context menu from Right Click on workspace
2. Build/Clean/Rebuild ->in Context menu from Right Click on project
3. Project only Build/Clean.

Why 3 options provided. Isnt the 2nd & 3rd the same. Isnt 1st & 2nd enough for all purpose. Since i havent seen such a situation, i would like to know where it is or will be used.

3. Why does Compile option appear for .h file Filetypes. I have created a virtual folder and moved all header files under this directory. Compile option appears for thes header files also. Interesting if i give compile command from right click on these header files, respective .c files are sent for compilation without checking if such files exist. If i right click on dummy.h header file & select compile command, dummy.c file is sent for compilation, & if dumy.c doesnt exist, it gives an error saying. and if dummy.c file exists, then compilation continues.

Code: Select all

Building: "C:/cygwin/bin/make.EXE"  -j 2 -f "prj_bootloader.mk" type=Release release/dummy.o
----------Building project:[ prj_bootloader - Release ] (Single File Build)----------
make: *** No rule to make target `release/dummy.o'.  Stop.
----------Build Ended----------
4. In Workspace tab - project "prj_bootloader" - right click -> Settings window, i changed IntermediateDirectory to point to "C:/prj/sd_fat/testing/bootloader/prj/Release". When i select compile from src file->right click context menu i get below error

Building: "C:/cygwin/bin/make.EXE" -j 2 -f "prj_bootloader.mk" type=Release C:/prj/sd_fat/testing/bootloader/prj/Release/common.o
----------Building project:[ prj_bootloader - Release ] (Single File Build)----------
prj_bootloader.mk:60: *** target pattern contains no `%'. Stop.
----------Build Ended----------


TIA

Truely thanks for ur patience/time in explaining/clarifying things to me.

Regards
Gururaja
hbr_in
CodeLite Expert
Posts: 113
Joined: Fri Jul 11, 2008 9:12 am
Contact:

Re: how to setup options for compiler

Post by hbr_in »

Oh i think i found the "maybe" bug.

I edited the prj_bootloader.mk as below

from

Code: Select all

$(IntermediateDirectory)/common$(ObjectSuffix): ../../../../../../../../prj/sd_fat/testing/bootloader/working/common.c
	$(CompilerName) $(SourceSwitch) "C:/prj/sd_fat/testing/bootloader/working/common.c" $(CmpOptions)   $(ObjectSwitch)$(IntermediateDirectory)/common$(ObjectSuffix) $(IncludePath)
to

Code: Select all

$(IntermediateDirectory)/common$(ObjectSuffix): ../../../../../../../../prj/sd_fat/testing/bootloader/working/common.c
	pwd
	$(CompilerName) $(SourceSwitch) "C:/prj/sd_fat/testing/bootloader/working/common.c" $(CmpOptions)   $(ObjectSwitch)$(IntermediateDirectory)/common$(ObjectSuffix) $(IncludePath)
I have cygwin installed on my system and so pwd shows current directory path

Now the output is

Code: Select all

Building: "C:/cygwin/bin/make.EXE"  -j 2 -f "prj_bootloader.mk" type=Release release/common.o
----------Building project:[ prj_bootloader - Release ] (Single File Build)----------
pwd
/ecos-c/users/hebbar/project/Tests/codelite/codelite_wrkspc/prj_bootloader
runcc -c  "C:/prj/sd_fat/testing/bootloader/working/common.c"  -Wundef -Wall    -o release/common.o 
Configuration: Release
Compiling "common.c"
..snip..
..snip..
Hope this would help you

Regards
Guruaja
Post Reply