summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-09-22 17:35:15 +0200
committerGitHub <noreply@github.com>2021-09-22 17:35:15 +0200
commit211edf5c7dbe196de62acf68a0ceff06823e2919 (patch)
tree67d0c8c798467d739674c437d514186d49cac624
parent4abf2d0c8d2b95be6d2c437db8040bc8af87c726 (diff)
parent1548e86d63ca9bbccf60bfdb9520cb7f7e158c24 (diff)
Merge pull request #19248 from vespa-engine/arnej/simplify-cpp-configgen
Arnej/simplify cpp configgen
-rw-r--r--configgen/src/main/java/com/yahoo/config/codegen/CppClassBuilder.java8
-rw-r--r--functions.cmake17
2 files changed, 10 insertions, 15 deletions
diff --git a/configgen/src/main/java/com/yahoo/config/codegen/CppClassBuilder.java b/configgen/src/main/java/com/yahoo/config/codegen/CppClassBuilder.java
index c2539b53b28..cc234ea51d7 100644
--- a/configgen/src/main/java/com/yahoo/config/codegen/CppClassBuilder.java
+++ b/configgen/src/main/java/com/yahoo/config/codegen/CppClassBuilder.java
@@ -98,8 +98,12 @@ public class CppClassBuilder implements ClassBuilder {
String newHeader = headerWriter.toString();
String newBody = bodyWriter.toString();
- File headerFile = new File(rootDir, relativePathUnderRoot + "/" + getFileName(root, "h"));
- File bodyFile = new File(rootDir, relativePathUnderRoot + "/" + getFileName(root, "cpp"));
+ String prefix = "";
+ if (relativePathUnderRoot != null) {
+ prefix = relativePathUnderRoot + "/";
+ }
+ File headerFile = new File(rootDir, prefix + getFileName(root, "h"));
+ File bodyFile = new File(rootDir, prefix + getFileName(root, "cpp"));
writeFile(headerFile, newHeader);
writeFile(bodyFile, newBody);
diff --git a/functions.cmake b/functions.cmake
index fe59cc3aaa9..3d192552be5 100644
--- a/functions.cmake
+++ b/functions.cmake
@@ -125,17 +125,13 @@ function(vespa_generate_config TARGET RELATIVE_CONFIG_DEF_PATH)
get_filename_component(CONFIG_NAME ${RELATIVE_CONFIG_DEF_PATH} NAME_WE)
endif()
- # configgen.jar takes the parent dir of the destination dir and the destination dirname as separate parameters
- # so it can produce the correct include statements within the generated .cpp-file (silent cry)
# Make config path an absolute_path
set(CONFIG_DEF_PATH ${CMAKE_CURRENT_LIST_DIR}/${RELATIVE_CONFIG_DEF_PATH})
- # Config destination is the
+ # Config destination is the current source directory (or parallel in build tree)
+ # configgen.jar takes the destination dirname as a property parameter
set(CONFIG_DEST_DIR ${CMAKE_CURRENT_BINARY_DIR})
- # Get parent of destination directory
- set(CONFIG_DEST_PARENT_DIR ${CONFIG_DEST_DIR}/..)
-
# Get destination dirname
get_filename_component(CONFIG_DEST_DIRNAME ${CMAKE_CURRENT_BINARY_DIR} NAME)
@@ -144,8 +140,8 @@ function(vespa_generate_config TARGET RELATIVE_CONFIG_DEF_PATH)
add_custom_command(
OUTPUT ${CONFIG_H_PATH} ${CONFIG_CPP_PATH}
- COMMAND java -Dconfig.spec=${CONFIG_DEF_PATH} -Dconfig.dest=${CONFIG_DEST_PARENT_DIR} -Dconfig.lang=cpp -Dconfig.subdir=${CONFIG_DEST_DIRNAME} -Dconfig.dumpTree=false -Xms64m -Xmx64m -jar ${PROJECT_SOURCE_DIR}/configgen/target/configgen.jar
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..
+ COMMAND java -Dconfig.spec=${CONFIG_DEF_PATH} -Dconfig.dest=${CONFIG_DEST_DIR} -Dconfig.lang=cpp -Dconfig.dumpTree=false -Xms64m -Xmx64m -jar ${PROJECT_SOURCE_DIR}/configgen/target/configgen.jar
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating cpp config for ${CONFIG_NAME} in ${CMAKE_CURRENT_SOURCE_DIR}"
MAIN_DEPENDENCY ${CONFIG_DEF_PATH}
)
@@ -157,11 +153,6 @@ function(vespa_generate_config TARGET RELATIVE_CONFIG_DEF_PATH)
# Add generated to sources for target
target_sources(${TARGET} PRIVATE ${CONFIG_H_PATH} ${CONFIG_CPP_PATH})
- # Needed to be able to do a #include <CONFIG_DEST_DIRNAME/config-<name>.h> for this target
- # This is used within the generated config-<name>.cpp
- # TODO: Should modify configgen to use #include <vespa/<modulename>/config-<name>.h> instead
- target_include_directories(${TARGET} PRIVATE ${CONFIG_DEST_PARENT_DIR})
-
# Needed to be able to do a #include <config-<name>.h> for this target
# This is used within some unit tests
target_include_directories(${TARGET} PRIVATE ${CONFIG_DEST_DIR})