I'm working on a project which has a SQLite database, built by running "sqlite3 [db filename] < [schema filename]" from the Terminal on Mac OS X. I'd like to learn more about the projects system in Xcode, and ideally get it to run this Terminal command automatically when I build the project, additionally copying the created database into the output directory of the C++ project. I've been able to do similar things with Visual Studio before, and I get the impression from the options presented that I can do the same thing in Xcode.
I've added an external build target with the database schema files inside it (so they get source controlled too) and at first it was running with errors that too many arguments were being passed. However, I put single quotes around the arguments and now it runs. But I don't see any output. The file is not generated in the directory I set and I can't find it anywhere else. I was wondering if it took the single quotes as a single argument to sqlite3, but I can't find anything named that either.
I keep finding tutorials such as this one: http://b2cloud.com.au/how-to-guides/precompilation-run-script-in-xcode-4 but it appears that Xcode has changed since they were written and I'm having no luck on 5.0.1. I can't seem to get it to run shell scripts, (hopeful for a workaround) can't find the output of what appear to be successfully run commands, and cannot add Aggregate/External Build Tool projects to the dependencies of my code project, so even if I had it working, it would not rebuild the database with the source code.
I'm more after an outline of the best way to do this in 5.0.1, because I suspect my entire approach may be wrong here.
Thank you for your time.
Related
At the company I'm currently working for, several IDEs are being used (they develop firmware for different embedded platforms).
All their C projects use a Makefile, so we decided to also add rules to their default Makefile to run static code analysis tools.
One of the IDEs they use is Eclipse.
Here we have added additional targets to the Make Target view, that triggers the lint target from the Makefile, for example.
Since we use multiple IDEs we can tell the tools called by the Makefile to generate specific output for the IDE being used.
For Eclipse we do this by adjusting the Build Command and adding something like IDE_ENV=eclipse to the end.
This works just fine.
Recently one of the engineers mentioned that it would be really helpful if he could run the tools, as defined in the Makefile, for a single file.
So, I updated the Makefile and it now accepts a variable SOURCE_FILE with the path of the file that needs to be checked.
In Eclipse I tried adding SOURCE_FILE=${selected_resource_loc} and just SOURCE_FILE=${resource_loc}, but these variable do not seem to work when running a Make Target.
I also tried to use $(selected_resource_loc) and $(resource_loc) directly in the Makefile, but without any luck.
Can somebody tell me how I can pass the current selected file to Make when running a target from the Make Target view?
Some Eclipse special variables can be not recognized in a build configuration. Instead of running build procedure try to use External Tools Configuration.
Similar problem was described here: Custom command for Eclipse on current file .
I'm currently running a variant of Eclipse known as WindRiver, which is designed for embedded systems programming using C++ (specifically, I'm part of my high school's FIRST Robotics team).
I'm able to successfully compile and build the project from within Eclipse (Project > Build Project) but I'm looking for ways to automate this process by compiling by using the command line.
The project already contains a makefile and everything, so ideally I want to be able to just run that without making any manual changes. I pastebin'd the makefile in case its relevant.
Does anybody know where I can find more information on compiling C++ programs from the command line for either Eclipse or WindRiver or on running makefiles on Windows? I tried looking at "How to run a makefile in Windows?" but following the first answer didn't work (it gave a syntax error for the makefile).
I'm currently using a Windows 8 laptop. As best as I can tell, the current varient of WindRiver I'm using is based on Eclipse version 3.3.1.
You will need a make utility, I believe your WindRiver / Eclipse setup would come with "gnumake" (probably called either make or gmake). You'd nee dto set up the command line path to lead to the compiler and the make executable. Unfortunately, this is not a great answer, as I can't give you exact links to the make and compiler locations (it would of course also depend on where you installed things). I just thought I'd lead you somewhat on the right path, since the question has been up for a little while and no one jumped at it.
Thanks to Mat Petersson's answer, I was able to identify everything I needed and create a batch file that could compile the file for me:
#echo off
setlocal
set PATH=%PATH%;C:\WindRiver\gnu\3.4.4-vxworks-6.3\x86-win32\bin;C:\WindRiver\utilities-1.0\x86-win32\bin;C:\WindRiver\setup\x86-win32\bin
set WIND_BASE=C:\WindRiver\vxworks-6.3
cd My_Project\PPC603gnu
make --no-print-directory BUILD_SPEC=PPC603gnu DEBUG_MODE=1 TRACE=1
I'm used to building my source in an IDE and having good feedback in the environment. Currently however I'm writing source code in notepad++, ftp'ing it to another machine with specific environment settings, and then building it there and reading the Makefile output to see that it all checks out. After that, I scp the built executable to the actual device to test it.
I'm curious if there are environments that can simplify this. I suppose I could write a script that ftp's changed files and then runs a command through ssh to build them. But I'd like an environment that will parse the makefile output and give me an build report like in most IDE's. I'm not sure how specific this problem is, or if a lot of embedded systems have similar set ups.
Ideally I suppose I would have a machine with the correct build environment, but that isn't the case :/
I tend to put the file transfer, remote make invocation and whatever else is necessary into some script (having a one-click build is important anyway) and then set that as the build command in my editor. I happen to use Sublime Text 2, which works fine with the error messages I get from building C++ code via make; personally, I don't find editors not supporting this kind of workflow worth using. There are lots of editors which do.
Oh, and I'd try replacing the ftp with rsync over ssh. It's probably faster, definitely easier to automate, and safer.
I have an Eclipse-CDT workspace with 8 projects in it. 3 of those projects use an External Tool (builder) to run a Python script that generates a header file prior to building the rest of the code. (Debian Lenny/ Eclipse 3.2)
When I build, the script may or may not run. It seems totally random. After failing I can just restart the build and the script might run, without changing anything.
I configured the builder once in Project|External Tools|External Tools and then imported it into the three projects. Since it runs sometimes the path and working dir must be correct. I have it set to refresh only the project, and to run after Cleans and on Manual builds.
I'm using find to ensure the output is not being created somewhere else and to delete the output after each test.
What could be causing this?
I'm using VC++ and want to write a script that can scan my source-code and at some places where it sees a text like "abc" then extract characters of that text and generate a selective piece of code like ones below at build time:
first example of a piece of code :
Func1(a);
Func2(b);
Func3(c);
second example of a piece of code:
{'a','b','c'}
I want to incorporate the script into build process as somebody has told me it is possible but don't know how, please tell how.
In the project properties of Visual Studio, you will have the option "Pre-Build Event" and "Post-Build Event".
At these configurations you can input programs that should be executed before and after your build. You can use project variables to identify your solution folder, project folder, binary, etc. If you are using a recent version of Visual Studio, there is a button below the text box that give you access to those variables.
Make sure that whatever you call at this configuration would be executed from the shell environment (cmd), otherwise you will receive a build error. Scripts will probably required that you input a call to the interpreter and pass the file as a parameter.
For example, let's say I need to run a Python script before I build my code. I would configure the Pre-Build Event as:
c:\python\python myscript.py
One good advice is to use DOS Batch files (.bat) to wrap around whatever you need to run and add those to your build events. There are plenty of tutorials over the net on how to create bat files, and they are fairly simple.