I have directories structure like,
|
|
------------------------------------
| |
directory 1 directory 2
| |
------------- -------------
| | | |
directory 1.1 directory 1.2 Makefile directory 2.1
|
file.c
In above hierarchy, How to compile file.c using Makefile(resides in directory 2)?
Related
I'm exploring ways to improve code module integration and have found interest in using named soft links as opposed to include directories, mainly because that allows the integrator to set a directory name of any imported module to something guaranteed not to collide with the module built or any of its imported modules, as well as keeping imported modules from accidently intercepting eachother. However I'm not sure how to actually accomplish this in a makefile.
Here is the directory hierarchy and expected links:
+---proj1
| +---inc
| | head.h
| |
| \---src
| code.c
|
+---proj2
| +---inc
| | head.h
| |
| \---src
| code.c
|
\---proj3
| Makefile
|
\---src
| code.c
| head.h
|
+---A --> ../../proj1/inc
| head.h
|
\---B --> ../../proj2/inc
head.h
In proj3/src/code.c i would have:
#include "head.h"
#include "A/head.h"
#include "B/head.h"
I think I need some way to run ln -s for each {directory,name} tuple prior to compiling the source, putting the link in the same directory as the source being compiled. Parsing INC=dir1 dir2 is simple enough, but how to represent and run ln -s for each pair/tuple in such a list? Or, if having a whole command in each element (ln -s dir1 localname), how to exec all of them?
Other suggestions would be deeply appreciated.
Something like this?
linkdirs := A B
dir_A := ../proj1/src
dir_B := ../proj2/src
.PHONY: all symlinks
all: symlinks hello
symlinks:
$(eval $(patsubst %,ln -fs $$(dir_%) % &&,$(linkdirs)) true
I have a DirectX11 project with CMake on Windows.
The project contains (at least) three sub-projects - one is for the core 3D engine library - a common asset directory which contains all the binary data used by the test or sample apps that builds on top of the engine.
./
+-- src/
| +-- api/
| +-- CmakeLists.txt
+-- tests/
| +-- assets/
| | +-- shaders/
| | | +-- 1.hlsl
| | | +-- 2.hlsl
| | | ...
| | +-- images/
| | | ...
| | +-- models/
| | | ...
| | +-- CmakeLists.txt
| +-- sampleApp1/
| | +-- CmakeLists.txt
| | ...
| +-- sampleApp2
| | +-- CmakeLists.txt
| | +-- ...
| | ...
| +-- CmakeLists.txt
+-- CmakeLists.txt
The asset files are just being copied in relative to the test projects binary dir (${CMAKE_CURRENT_BINARY_DIR}) to make them available in relative to their work directory (../assets).
I have hlsl shader files in assets as well. When such files are being added to the project with CMake, VS will treat them as compilable source - obviously - which I wish to avoid, because I want such files to be edited with the IDE and just copy them to the binary folder and use the engine to compile, rather than let VS to do it.
I have tried to set as header file, like another source files that I wish to avoid building, but it seems that something sets them as shader file and overrides this for some reason.
Here is my setup I'm attempting with:
cmake_minimum_required (VERSION 2.6)
project (Project)
subdirs(assets)
In the asset folder I have the following:
file(GLOB_RECURSE FILES *.*)
add_custom_target(assets SOURCES ${FILES})
set_target_properties(assets PROPERTIES FOLDER tests)
# copy static sources
foreach(_source IN ITEMS ${FILES})
# this does not work for some reason
set_source_files_properties(${_source} PROPERTIES HEADER_FILE_ONLY TRUE)
if (IS_ABSOLUTE "${_source}")
file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
else()
set(source_rel "${_source}")
endif()
get_filename_component(_source_path "${_source_rel}" PATH)
get_filename_component(_source_name "${_source_rel}" NAME)
set(dst_path "${CMAKE_CURRENT_BINARY_DIR}/${_source_path}")
file(MAKE_DIRECTORY ${dst_path})
# -- win32 only
if (WIN32)
string(REPLACE "/" "\\" _source "${_source}")
string(REPLACE "/" "\\" _dest "${dst_path}/${_source_name}")
else()
message("win32 required")
endif(WIN32)
add_custom_command(
TARGET assets
COMMAND copy ${_source} ${_dest}
DEPENDS ${_source}
)
endforeach()
I have tried the following method described in this answer, but didn't succeed.
In CMake HLSL is handled as a source extra, and HEADER_FILE_ONLY doesn't apply here, as you discovered.
You can override this default behaviour by using VS_TOOL_OVERRIDE:
set_source_files_properties(my_shader.hlsl PROPERTIES VS_TOOL_OVERRIDE "None")
See cmVisualStudio10TargetGenerator::WriteExtraSource in CMake source code.
I can't seem to find any documentation on the purpose for the folder structure created for failed tests in the TestResults folder for MS Tests.
The structure is:
TestResults
|
|
---- Deploy_[UserName] YYYY-MM-DD hh:mm:ss
|
|
|---- In
| |
| |
| ---- [MachineName]
|
|
---- Out
I understand what the Out folder is, but what are the In and the MachineName folders for?
I am trying to extract a file from tar using the following command:
tar xzfv mysql-connector-java-5.1.29.tar.gz mysql-connector-java-5.1.29-bin.jar
However tar command is unable to find mysql-connector-java-5.1.29-bin.jar even though it seems to be present. The folder structure which I get when extracting the tar file is:
The jar is present at http://cdn.mysql.com/Downloads/Connector-J/mysql-connector-java-5.1.29.tar.gz.
|-- mysql-connector-java-5.1.29
| |-- CHANGES
| |-- COPYING
| |-- README
| |-- README.txt
| |-- build.xml
| |-- docs
| | |-- README.txt
| | |-- connector-j.html
| | `-- connector-j.pdf
| |-- mysql-connector-java-5.1.29-bin.jar
| `-- src
| |-- com
| | `-- mysql
| | `-- jdbc
I have not included the complete structure for brevity. But it can be seen that mysql-connector-java-5.1.29-bin.jar is present. I am unable to figure out the issue here.
First, try to list the files in the tar.
tar tvf mysql-connector-java-5.1.29.tar.gz
Then you can find that your file is located inside a directory in the tar
mysql-connector-java-5.1.29/mysql-connector-java-5.1.29-bin.jar
So to extract that file, you should use
tar zxvf mysql-connector-java-5.1.29.tar.gz mysql-connector-java-5.1.29/mysql-connector-java-5.1.29-bin.jar
I am trying to write a script (preferably in bash) to flatten a java projet directory structure prepending the path to the file. Example:
| src
| org
| apache
| file2.java
| file1.java
would result in:
| src
| org|apache|file2.java
| org|file1.java
The script should be recursive since the directory could have many subfolders.
cd src
for i in $(find . - name '*.java') ; do
echo cp \"$i\" $(echo "$i" | tr / _)
done
if it looks good(might barf if filenames contains spaces), pipe the result to sh