Change Eclipse Dynamic Variable to build a single c++ class - c++

I would like to change the dynamic variable ${selected_resource_loc} such that I get rid of the extension (and can add another one).
The purpose is to build the current selected file, but therefore I don't need the .cc-file in my command but the .o-file with the same name.
Detailed description:
I have a customized make command (lets say make) and would like to execute make selectedFileName.o, where the current selected file in eclipse is selectedFileName.cc. (I put the command as build command in project properties -> C/C++ Build.) With variable ${selected_resource_loc} in behaviour tab I get make selectedFileName.cc.

I solved my problem by writing a skript where I modify the ${selected_resource_loc} and included it via external tools in eclipse.

Related

Compile and execute cpp in xcode, and add additional execution instructions, Such as iconv command

Sorry, I'm new to Xcode and not very familiar with it, I use Xcode (command line tool project with external build system) to compile cpp files and automatically execute cpp unix executable files. After the program is compiled (command+R), I set the settings as shown in the screenshot below to automatically execute. Is there any way for me to execute also add additional commands?
Such as iconv.
The following line is what I ultimately want to execute.
./myFile argument1 | iconv -f big5
But my Xcode looks like it's executing only
./myFile argument1
really thanks
On the same place where you setup the build scheme, you can also add a post-build script.
Go to the left of the panel, and expand Build
Select Post-actions
Near the bottom center, click on + -> New Run Script Action
Add script like you would run them in terminal
Note the current directory will not be where the project is built
You can use ${TARGET_BUILD_DIR} macro for the build directory
Note, you want to make sure to select your current project at the Provide build settings from so it can import the correct path macros like TARGET_BUILD_DIR
A screenshot of adding a post-build script:
*Older versions of Xcode might have different GUI, but the idea should be about the same.
Sidenote, ⌘R is really for running the program within Xcode, consider using ⌘B.

How do I set up this visual studio (2015) custom build step (tool?). Basically I want a pre-preprocessor step that modifies header files (c++)

I want a run a build step that looks at a .h file, adds some code based on some external params, and hands the resulting file to the preprocessor.
I see the "Custom Build Step" in the project properties. It seems to need an output file. I just want to forward the results to the preprocessor.
It seems like the custom build step wants to do a 1-time process, not per-file or by file type.
The problem is that I don't know how to send my external executable the file currently being processed (eg, "HelloWorld.cpp"). $(InputName) and %(Filename) are blank and docs say it's deprecated. How do I send the filename to my external executable?
But even if I get that working, I don't want to set this per-file. I want all header files to go through this process.
Any ideas?
I've looked at:
https://msdn.microsoft.com/en-us/library/dd293663.aspx?f=255&MSPPError=-2147217396
https://msdn.microsoft.com/en-us/library/hefydhhy(v=vs.90).aspx
https://msdn.microsoft.com/en-us/library/ff770593(v=vs.140).aspx
working on a debug, x64 config on windows.
First of all, No, you cannot modify a file and pass along the results to the next stage (that I could see). I'd need some sort of Program Transformation System.
So I need an intermediate file. That file has to be added to the project, even if it gets overwritten by your code generator. I can associate c++ header files with a custom build tool, and they will all get called one-by-one in the stage of the build specified in the Custom Build Step. The custom build tool will modify the intermediate file(s), and all is well.
The VS 2015 name for the current file being processed is %(Filename). In older versions it has been $(ProjectName) and $(InputName).

Exporting cmake-gui options

I have a library with a bunch of different configuration options. We usually configure the build with cmake-gui and ticking a few checkboxes.
I want to automate this into a .sh script using just cmake.
e.g.
In GUI -> selects a bunch of different options
equivalent cmake command -> cmake -D CMAKE_XXX=X -D CMAKE_XXY=XXY [a bunch of options here] ..
How can I find the "equivalent" cmake command-line command to any arbitrary configuration I choose from the GUI?
The equivalent cmake command to cache a variable is explained here (-D option). Note that previous documentation was ambiguous, so take care of always checking the latest one.
Basically:
-D<var>:<type>=<value>
You have to specify also the type to have the variable cached in the same way as through your cmake-gui procedure. Note that variable definition is necessary only the first time: if not specified anymore, the cached value will be used.
cmake-gui generates CMakeVars.txt and CMakeCache.txt files in the build directory once you click "Configure" button. They cache all variables you configured through the GUI.
Had the same question ... and as you asked I looking up some of the options in the menu and found it. Menu Tools -> Show My Changes
Bringing up an Dialog with an edit field with content for command line options or cache file options.
yeah
p.s. I used cmake 3.11.1
just read file named like CMakeCache.txt (iirc) in the root of build directory and see variable names there
You can write a file containing all variables you want to set with set(<var_name> <value>) and pass this file to the CMake call via -C:
cmake -C <fileWithInitialValues> <pathToSrcDir>
Documentation:
https://cmake.org/cmake/help/v3.3/manual/cmake.1.html
This should would similar with cmake-gui and ccmake, but it is not a pure solution with the graphic interface.

RTC Where is the output properties file config in build definition 'Command Line' Tab and how to use 'Evvironment Variables'

I'm using RTC(Rational Team Concert) to build project. Coz there's a property file in my project which include code like this -
url=#COMMON_URL#
dir=#REPORT_DIR#
I need to replace these properties as real variable according to different envirenment when build, it seems I can do that by config 'Properties file' and 'Environment variables' in build definition 'Command Line' Tab. But I've tried several times, I cannot find the output file(Properties file contain all build definition) and don't know how to replace my file in project.
If someone is familiar with RTC, plase help me, thanks.
In Build definition there u can find the properties tab..there you can add your environment variables->save that build definition ->go to Build Fore tab->click on Synchronize Properties button (it will load your new env variable to server)->it will again modifies the build definition, but dont save it.
Those environment variables (defined in the properties tab of a build definition or a build request) should be passed along to the Build Engine associated with the Build Definition, and be present on the actual Build master itself (BuildForge, Hudson, Jenkins, ...) when said build will start.
That means your actual build script has the opportunity to modify your config file, replacing the placeholder #COMMON_URL# with the value derived from the environment variable $COMMON_URL.

Where to start for writing a shell script for copying elements into main app xcode4

I am looking for some documentation or tutorial for copying files from a given directory into the app created by xcode at build time, before it is run.
At first I have tried to copy files into the derived directory, hoping that everything resides in there would be automatically added to the app, but I was wrong.
So I am looking for a script because the original dir may change its name, second the script could be customized by another xcode 4 user with its src dir path etc.
The things is I don't know how to start, which language etc. I am quite confident with shell script, but maybe there's a better option.
Second, I am trying to figure out which command could add a file in the already built app.
thanks
That answer didn't really help - the BUILT_PRODUCT_DIR isn't where most stuff goes.
Ultimately, I found you just need to do:
Add the following to the very end of your script (or get your script to write directly to the output location):
cp ${DERIVED_FILE_DIR}/[YOUR OUTPUT FILES] ${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}
...but there's a lot of other things I tried. More thoughts and ideas here: http://red-glasses.com/index.php/tutorials/xcode4-a-script-that-creates-adds-files-to-your-project/
You want a Run Script or Copy Files build phase. Select your main project in the navigator, then select the app's target. Click the Build Phases tab. Click the Add Build Phase button at the bottom of the window and choose the appropriate phase.
By "appropriate" I mean if you really want to run a script, you'll use a Run Script build phase and use Xcode-provided environment variables like $BUILT_PRODUCT_DIR (see the documentation or hit build and examine the full output of an empty script in the build log) to figure out your target folder. If all you want to do is copy files (no real processing), the Copy Files build phase already knows how to locate the app bundle's proper folders depending on what you're copying (Resources, Frameworks, etc.).