On Nov 10, 2004, at 2:41 PM, Andreas Grosam wrote:
On 10.11.2004, at 22:26, Chris Espinosa wrote:
On Nov 10, 2004, at 12:05 PM, Andreas Grosam wrote:
I am using a custom build script as part of the build process. How can I figure out the compiler invoked by the native build system? Or, which is the corresponding environment variable?
A very useful document is file:///Developer/ADC Reference Library/releasenotes/DeveloperTools/Xcode/XcodeBuildSettings.html
Many of these build settings are available as shell environment variables when your script is executed. Check the build log for a list, or to test, execute a script that includes the command 'set' and it will echo all the env variables and their current values.
To your specific question, you probably want the GCC_VERSION environment variable, which defaults to 3.3 in Xcode 1.5 projects.
Chris
The document file looks a bit outdated - or Xcode 1.5 just does not behave as stated. I used the command printenv for testing purposes in the script and it shows that GCC_VERSION is empty and USE_GCC2 and USE_GCC3 are not defined.
The build log looks like this:
PhaseScriptExecution "/Users/agrosam/Develop/Test Projects/C++Tool XCode 1.5/C++ Tool/build/C++ Tool.build/C++ Tool.build/Script-A1C385D9074288EA005B1D7C.sh"
setenv ACTION build
setenv APPLE_INTERNAL_DEVELOPER_DIR /AppleInternal/Developer
[snip]
setenv GCC_VERSION ""
[snip]
cd "/Users/agrosam/Develop/Test Projects/C++Tool XCode 1.5/C++ Tool"
/bin/sh -c "\"/Users/agrosam/Develop/Test Projects/C++Tool XCode 1.5/C++ Tool/build/C++ Tool.build/C++ Tool.build/Script-A1C385D9074288EA005B1D7C.sh\""
[ executes the script printenv ]
ACTION="">
APPLE_INTERNAL_DEVELOPER_DIR=/AppleInternal/Developer
[snip]
GCC_VERSION=
[snip]
Additionally, in the doc it states:
" By default USE_GCC3 is YES, indicating that gcc3 should be used for compiles. Setting USE_GCC2 to YES instead indicates that gcc2 should be used. When both settings are activated gcc3 is favored. If neither is selected then cc is called, no features specific to gcc3 are used, the compiler used defaults to gcc3, but can be modified using gcc_select."
Sounds a bit strange, probably this has not been updated since a long time.
On the console "gcc3 --version" reveals "gcc3 (GCC) 3.1 20021003 (prerelease)". However, this is NOT the compiler which will be invoked by the XCode build system. This is gcc-3.3. Please look at build log:
CompileC "build/C++ Tool.build/C++ Tool.build/Objects-normal/ppc/main.o" main.cpp normal ppc c++ com.apple.compilers.gcc.3_3
mkdir -p "/Users/agrosam/Develop/Test Projects/C++Tool XCode 1.5/C++ Tool/build/C++ Tool.build/C++ Tool.build/Objects-normal/ppc"
cd "/Users/agrosam/Develop/Test Projects/C++Tool XCode 1.5/C++ Tool"
/usr/bin/gcc-3.3
What i miss is just an environment variable - for instance CXX - which specifies the compiler which will be selected by CompileC.
a) You're correct; the document is outdated and it documents some JAM-based ("legacy target") settings that are not used in native targets. (Most importantly, you'd really want to use the CC setting, but it is neither defined nor passed to shell scripts).
b) If the project's current build style is using the default compiler, then the GCC_VERSION variable may be empty; in that case, your shell script can invoke gcc_select (with no arguments) to get the version of the default compiler.
Chris