Are multiple document roots to serve the same path possible? - apache

Is it possible to have a directory structure on an Apache server similar to this:
└── www
├── root1
│   └── doc1.html
└── root2
└── doc2.html
such that doc1.html and doc2.html are both served on the same path?
(e.g. http://localhost/doc1.html and http://localhost/doc2.html both result in successful requests?)

Do it with aliasing. See httpd.apache.org/docs/2.2/mod/mod_alias.html#alias

Related

Library linking not working when CMake single build

using CMake I want to build in each directory A, B, and C.
The project structure is as follows:
.
├── A
│   ├── CMakeLists.txt
│   └── src
│   └── a.cpp
├── B
│   ├── CMakeLists.txt
│   └── src
│   └── b.cpp
├── common
│   ├── CMakeLists.txt
│   ├── include
│   │   ├── common.h
│   └── src
│   └── common.cpp
└── C
├── CMakeLists.txt
└── src
└── c.cpp
Create a library in the Common directory and install the created library.
common/CmakeLists.txt :
set(COMMON_LIB_NAME CommonTemp)
set(SRC_CODE
${CMAKE_CURRENT_SOURCE_DIR}/include/common.h
${CMAKE_CURRENT_SOURCE_DIR}/src/common.cpp
)
add_library (${COMMON_LIB_NAME} SHARED ${SRC_CODE})
install(TARGETS ${COMMON_LIB_NAME} DESTINATION ~/tempDir/lib)
I want to link the generated library to directory A.
a.cpp requires common.h.
A/CMakeLists.txt:
ADD_EXECUTABLE(ServiceA src/a.cpp)
target_include_directories (
ServiceA PUBLIC
include
)
target_sources (
ServiceA PRIVATE
src/a.cpp
)
target_link_libraries(
ServiceA PUBLIC
${COMMON_LIB_NAME} #### Location considered to be a problem
)
install(TARGETS ServiceA DESTINATION ~/tempDir/bin/A)
An error message occurs saying that common.h cannot be included.
My guess is that the ${COMMON_LIB_NAME} variable is defined in CMakeLists.txt in another directory, so it is expected that it cannot be linked.
But even if I put CommonTemp , the value of the variable, it says that common.h cannot be found.
How can I link library links even if I build CMake individually in each directory?
In common/CmakeLists.txt.
You need to include the headers in target_include_directores.
target_include_directories(
${COMMON_LIB_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
No need to mention it in add_library
In A/CMakeLists.txt. Include path is not correct.
target_include_directories(
ServiceA PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/<path to common>/include
)
For linking the library you have to mention the correct library path otherwise it will fail
target_link_libraries(
ServiceA PUBLIC
${COMMON_LIB_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/<path to tempDir>/lib
)

combine to outputs of diffrent rules in Snakemake

I would like to use snakemake to first merge some files and than later process other files based on that merge. (Less abstract: I want to combine control IGG bam files of two different sets and than use those to perform peakcalling on other files.
In a minimal example, the folder structure would look like this.
├── data
│   ├── toBeMerged
│   │   ├── singleA
│   │   ├── singleB
│   │   ├── singleC
│   │   └── singleD
│   └── toBeProcessed
│   ├── NotProcess1
│   ├── NotProcess2
│   ├── NotProcess3
│   ├── NotProcess4
│   └── NotProcess5
├── merge.cfg
├── output
│   ├── mergeAB_merge
│   ├── mergeCD_merge
│   ├── NotProcess1_processed
│   ├── NotProcess2_processed
│   ├── NotProcess3_processed
│   ├── NotProcess4_processed
│   └── NotProcess5_processed
├── process.cfg
└── Snakefile
Which files are combined and which are processed are defined in two config files.
merge.cfg
singlePath controlName
data/toBeMerged/singleA output/controlAB
data/toBeMerged/singleB output/controlAB
data/toBeMerged/singleC output/controlCD
data/toBeMerged/singleD output/controlCD
and process.cfg
controlName inName
output/controlAB data/toBeProcessed/NotProcess1
output/controlAB data/toBeProcessed/NotProcess2
output/controlCD data/toBeProcessed/NotProcess3
output/controlCD data/toBeProcessed/NotProcess4
output/controlAB data/toBeProcessed/NotProcess5
I am currently stuck with a snakefile like this, which itself does not work and gives me the error that both rules are ambiguous. And even if I would get it to work, I suspect, that this not the "correct" way, since the process rule, should have {mergeName} as input to build its dag. But this does not work, since then I would need two wildcarts in one rule.
import pandas as pd
cfgMerge = pd.read_table("merge.cfg").set_index("controlName", drop=False)
cfgProc= pd.read_table("process.cfg").set_index("inName", drop=False)
rule all:
input:
expand('{mergeName}', mergeName= cfgMerge.controlName),
expand('{rawName}_processed', rawName= cfgProc.inName)
rule merge:
input:
lambda wc: cfgMerge[cfgMerge.controlName == wc.mergeName].singlePath
output:
"{mergeName}"
shell:
"cat {input} > {output}"
rule process:
input:
inMerge=lambda wc: cfgProc[cfgProc.inName == wc.rawName].controlName.iloc[0],
Name=lambda wc: cfgProc[cfgProc.inName == wc.rawName].inName.iloc[0]
output:
'{rawName}_processed'
shell:
"cat {input.inMerge} {input.Name} > {output}"
I guess the key problem is how to use the output of a rule as the input for another one, when it does not depend on the same wildcard, or includes other another wildcard.
For future reference:
The problem did not seem to be the "using the output of a rule as the input for another one, when it does not depend on the same wildcard, or includes other another wildcard."
It seems that the input for rule all and the output for the other two rules where ambiguous. The simple solution is to put every output in a different directory and it worked (see below).
import pandas as pd
cfgMerge = pd.read_table("merge.cfg").set_index("controlName", drop=False)
cfgProc= pd.read_table("process.cfg").set_index("inName", drop=False)
#ruleorder: merge > process
rule all:
input:
expand('output/bam/{rawName}_processed', rawName= cfgProc.inName),
expand('output/control/{controlNameSnake}', controlNameSnake= cfgMerge.controlName.unique())
rule merge:
input:
lambda wc: cfgMerge[cfgMerge.controlName == wc.controlNameSnake].singlePath.unique()
output:
'output/control/{controlNameSnake}'
shell:
'echo {input} > {output}'
rule process:
input:
in1="data/toBeProcessed/{rawName}",
in2=lambda wc: "output/control/"+"".join(cfgProc[cfgProc.inName == wc.rawName].controlName.unique())
output:
'output/bam/{rawName}_processed'
shell:
'echo {input} > {output}'

How to use modules from another directory? [duplicate]

This question already has answers here:
How to include files from same directory in a module using Cargo/Rust?
(3 answers)
How do I import from a sibling module?
(1 answer)
Why can't I import module from different file in same directory? [duplicate]
(2 answers)
Closed 3 years ago.
I have a Rust project with the structure:
.
├── Cargo.lock
├── Cargo.toml
├── src
│   ├── routes
│   │   ├── mod.rs
│   │   ├── router_get.rs
│   │   └── router_post.rs
│   ├── main.rs
│   └── server.rs
I need to use the routes module in server.rs, but when I am trying to compile it, it gives me an error:
error[E0432]: unresolved import `super::routes`
--> src/server.rs:10:5
|
10 | use super::routes;
| ^^^^^^^^^^ no `routes` in the root
When I try use routes in main.rs with mod routes, everything is ok. But I need to use it in server.rs.
routes/mod.rs
pub mod router_get;
pub mod router_post;
In your main.rs you've to load the module first.
mod routes;
fn main() {
}
In your server.rs just use
use crate::routes;

What does FindPackageHandleStandardArgs do exactly?

I am trying to write a Find Module for a package that I have installed. But I am having trouble understanding the CMake functions.
Here is a snippet of my code.
find_package(PkgConfig)
pkg_check_modules(PC_zcm QUIET zcm)
find_path(zcm_INCLUDE_DIR
NAMES zcm.h
PATHS $ENV{PATH}
)
mark_as_advanced(zcm_FOUND zcm_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(zcm DEFAULT_MSG
REQUIRED_VARS zcm_INCLUDE_DIR
)
find_path() is able to find my zcm_INCLUDE_DIR just fine: /usr/bin/zcm/usr/local/include
But find_package_handle_standard_args() gives
-- Could NOT find zcm (missing: REQUIRED_VARS)
My directory tree looks like this:
└── zcm
├── eventlog.h
├── json
│   ├── json-forwards.h
│   └── json.h
├── message_tracker.hpp
├── tools
│   ├── IndexerPlugin.hpp
│   └── TranscoderPlugin.hpp
├── transport
│   └── generic_serial_transport.h
├── transport.h
├── transport_register.hpp
├── transport_registrar.h
├── url.h
├── util
│   └── Filter.hpp
├── zcm-cpp-impl.hpp
├── zcm-cpp.hpp
├── zcm.h
└── zcm_coretypes.h
My understanding is find_package_handle_standard_args() attempts to find the package at the path, which sounds like it would be straightforward as the path is already determined.
As for REQUIRED_VARS the docs just say "Specify the variables which are required for this package." Which doesn't tell much for a noobie like me.
Description of find_package_handle_standard_args notes about two signatures of given function, one signature accepts DEFAULT_MSG option and another one accepts REQUIRED_VARS option.
You are trying to mix these signatures, and this is wrong.
Proper usage of the first signature:
# Everything after DEFAULT_MSG is treated as required variable.
find_package_handle_standard_args(zcm DEFAULT_MSG
zcm_INCLUDE_DIR
)
Proper usage of the second signature:
# By default, the standard error message is used.
find_package_handle_standard_args(zcm REQUIRED_VARS
zcm_INCLUDE_DIR
)

How to add include_directory in simple CMake Project

I have CMake project whose directory structure is as follows:
├── build
├── CMakeLists.txt
├── src
│   ├── CMakeLists.txt
│   ├── headers
│   │   └── utility.h
│   └── main.cpp
└── tests
├── CMakeLists.txt
├── testfeature_a
│   ├── CMakeLists.txt
│   └── test_me.cpp
└── test_main.cpp
In test_me.cpp I wanted to include utility.h as I wanted to test functions defined there. So I did #include "headers/utility.h" and in testfeature_a CMakeLists.txt I did this:
file(GLOB SRCS *.cpp)
ADD_EXECUTABLE(testfeature_a ${SRCS})
include_directories(src/headers)
TARGET_LINK_LIBRARIES(
testfeature_a
libgtest
libgmock
)
add_test(NAME testfeature_a
COMMAND testfeature_a)
But the make fails with the error message fatal error: headers/utility.h: No such file or directory.
How can I include the headers directory in test_me.cpp
Your path in include_directories() may be incorrect. Here are two things that you could check
The file seems to be the CMakeLists.txt in tests-folder so you need to go up one folder before you can go to src-folder, i.e. include_directories(../src/headers).
You repeat the headers-folder in the #include "headers/utility.h" when you have already specified it in include_directories(src/headers). Either use #include "utility.h" in cpp-file or include_directories(src) in CMakeLists.txt.
Other option is that you don't need to specify the headers-folder in the CMakeLists.txt at all. You can simply use #include "path/to/your/file.h without any other configuration.
For debugging your path in the CMakeLists.txt you can call message-function, e.g. message(${your_path}), so it's printed when executed and you can check if it's correct.
In addition you can use CMake built-in variables such as CMAKE_CURRENT_SOURCE_DIR and CMAKE_SOURCE_DIR, e.g. include_directories(${CMAKE_SOURCE_DIR}/src/headers)