Author Topic: The script function 'SetObjectOutput' can't work.  (Read 2677 times)

Offline Chun Jiu

  • Multiple posting newcomer
  • *
  • Posts: 43
  • My Girlfriend
    • EasilyGCC
The script function 'SetObjectOutput' can't work.
« on: June 03, 2015, 07:05:01 pm »
Hi all,

I set the output directory of the obj file in the build script without the entry into force. But in the 'project/target options' dialog, you can see it has been modified. Only when the OK of the dialog is clicked, the next build will use the correct directory (obj\Release\i686). If you click the Cancel, the directory is still incorrect (obj\Release\x64). This "obj\Release\x64" directory is manually configured before.

The SetOutputFilename function is work.



My script :

local prj = GetProjectManager().GetActiveProject();
local tar = prj.GetCurrentlyCompilingTarget();
local arch = tar.GetVar(_T("arch")); // arch=i686
...
tar.AddBuildScript(ReplaceMacros(_T("$(CODEBLOCKS)") + _T("/../../scripts/build/target.script")));
tar.SetObjectOutput(_T("obj/") + tar.GetTitle() + _T("/") + arch);
tar.SetOutputFilename(_T("bin/") + tar.GetTitle() + _T("/") + arch + _T("/") + tar.SuggestOutputFilename());

prj.SetModified(true);

build log:
...
mingw32-g++.exe -Wall -pipe -mthreads -O2 -s -mtune=i686 -std=gnu++11 -D__WXMSW__ -DwxUSE_UNICODE -DWXUSINGDLL -D__GNUWIN32__ -DWX_PRECOMP -include wx_pch.h -Winvalid-pch -iquoteobj\Release\i686 -Iobj\Release\i686 -I. -IC:\Tools\EasilyGCC\toolbox\CodeBlocks-64\..\..\include\wxWidgets\3_0 -IC:\Tools\EasilyGCC\toolbox\CodeBlocks-64\..\..\lib\wxWidgets\3_0\dll_i686\mswu -c D:\KuaiPan\Live_Document\03-ThinkPad-T500\CodeBlocks_Project\CollectKeysWithThread\WorkCode.cpp -o obj\Release\x64\WorkCode.o
mingw32-g++.exe -LC:\Tools\EasilyGCC\toolbox\CodeBlocks-64\..\..\lib\wxWidgets\3_0\dll_i686 -o bin\Release\i686\CollectKeysWithThread.exe obj\Release\x64\CollectKeysWithThreadApp.o obj\Release\x64\CollectKeysWithThreadMain.o obj\Release\x64\CollectTextKeysThread.o obj\Release\x64\Contrast_keys.o obj\Release\x64\GlobalDefinition.o obj\Release\x64\ReadTextFileThread.o obj\Release\x64\ThreadTask.o obj\Release\x64\WorkCode.o  obj\Release\x64\resource.res  -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -lwxexpat -lwxjpeg -lwxmswu -lwxmswu_gl -lwxpng -lwxregexu -lwxscintilla -lwxtiff -lwxzlib -mwindows

--------------------
Windows 7 64bit
TDM-GCC-32 + TDM-GCC-64
Code::Blocks svn10309 64bit with wxWidgets 2.8.12

   
« Last Edit: June 04, 2015, 04:45:21 am by Chun Jiu »
I love my girlfriend like c++!    :-)

http://pan.baidu.com/s/1feNwU
easilygcc is a gmail's email.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11939
    • Travis build status
Re: The script function 'SetObjectOutput' can't work.
« Reply #1 on: June 05, 2015, 10:22:59 pm »
I'm not sure I understand. Can you please post the exact steps needed to reproduce the problem?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Chun Jiu

  • Multiple posting newcomer
  • *
  • Posts: 43
  • My Girlfriend
    • EasilyGCC
Re: The script function 'SetObjectOutput' can't work.
« Reply #2 on: June 06, 2015, 04:39:12 am »
I'm not sure I understand. Can you please post the exact steps needed to reproduce the problem?

I use two sets of compilers, and three different architectures library(x86, i686, x64). So, I hope that each object files compiled in accordance with different architectures can be placed in a different directory..

When I do it by manually everything is correct(use 'Project/targets options' dialog to modify the objs directory). But do it with a script always invalid.

My steps are as follows:
========================
1. Write a script, use the 'SetObjectOutput' function modify the objs output directory, and 'SetOutputFilename' function modify the target output directory.
2. In the 'Project/targets options' dialog , add the script to the project (rather than the target), click ok button.
3. Build the target...

The output of compiler logging be seen from the 'build log' window, objs output directory does not change. So, the 'SetObjectOutput' function modifies the objs directory is invalid. At the same time, the 'SetOutputFilename' function modifies the target output directory is correct.

I suspect that the command-line generator missing the update for objs output directory.
I love my girlfriend like c++!    :-)

http://pan.baidu.com/s/1feNwU
easilygcc is a gmail's email.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11939
    • Travis build status
Re: The script function 'SetObjectOutput' can't work.
« Reply #3 on: June 06, 2015, 09:30:40 am »
Hm, why are you using a script for this?
C::B supports automatic variable expansion.
I think you can use them just fine.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Chun Jiu

  • Multiple posting newcomer
  • *
  • Posts: 43
  • My Girlfriend
    • EasilyGCC
Re: The script function 'SetObjectOutput' can't work.
« Reply #4 on: June 06, 2015, 12:24:55 pm »
Hm, why are you using a script for this?
C::B supports automatic variable expansion.
I think you can use them just fine.

Thanks for your advice.

I was concerned that if the variable is empty, the output filename becomes: bin\Debug\\target.exe.

But I forgot that it did not affect 'obj\Debug\$(arch)'.

Solve the problem.

Thank you very much!  ;D
I love my girlfriend like c++!    :-)

http://pan.baidu.com/s/1feNwU
easilygcc is a gmail's email.