Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generate_catalog_edc_code triggered on every build #717

Merged
merged 2 commits into from
Jun 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions production/schemas/system/catalog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,42 @@
# Set the project name.
project(catalog_schema)

# We name the library edc_catalog_discard because we create
# an edc_catalog library inside the catalog sub directory.
process_schema_internal(DATABASE_NAME catalog
LIB_NAME edc_catalog_discard
string(RANDOM GAIAC_CATALOG_INSTANCE_NAME)

# We use a custom command to generate catalog EDC code because process_schema_internal()
# creates dependencies on the generated code which would causes this target to be automatically
# called.
add_custom_command(
COMMENT "Generating EDC code for database catalog..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in my local branch. The fix will come in the next PR.

OUTPUT ${GAIA_GENERATED_CODE}/catalog/gaia_catalog.cpp
OUTPUT ${GAIA_GENERATED_CODE}/catalog/gaia_catalog.h
OUTPUT ${GAIA_GENERATED_CODE}/catalog/catalog_generated.h
COMMAND ${GAIA_PROD_BUILD}/catalog/gaiac/gaiac
-t ${GAIA_PROD_BUILD}/db/core
-o ${GAIA_GENERATED_CODE}/catalog
-d catalog
-n ${GAIAC_CATALOG_INSTANCE_NAME}
-g
)

# Instead of using edc_catalog as a static library to link against the project targets, we copy the source code into
# the gaia source tree and compile it as a normal cpp file. There are 2 reasons for this:
# We copy the catalog EDC code into the gaia source tree and compile it as a normal cpp file.
# There are 2 reasons for this:
# 1. We don't want the catalog EDC API to change and possibly break on every modification to the catalog code.
# 2. We use the catalog generated code to "observe" the changes in the EDC generation logic.
#
# This is a standalone command and is not automatically run as part of the build. To run it you can:
# This is a standalone command and is not automatically run as part of the build. To run it you can use either of these
# commands:
# cmake --build build_folder --target generate_catalog_edc_code
add_custom_command(
COMMENT "Copying generated EDC code for catalog into Gaia source tree..."
OUTPUT ${GAIA_REPO}/catalog/src/gaia_catalog.cpp
OUTPUT ${GAIA_REPO}/inc/gaia_internal/catalog/gaia_catalog.h
OUTPUT ${GAIA_REPO}/inc/gaia_internal/catalog/catalog_generated.h
COMMAND cp ${GAIA_GENERATED_CODE}/catalog/gaia_catalog.cpp ${GAIA_REPO}/production/catalog/src/
COMMAND cp ${GAIA_GENERATED_CODE}/catalog/gaia_catalog.h ${GAIA_REPO}/production/inc/gaia_internal/catalog/
COMMAND cp ${GAIA_GENERATED_CODE}/catalog/catalog_generated.h ${GAIA_REPO}/production/inc/gaia_internal/catalog/
DEPENDS edc_catalog_discard
# make generate_catalog_edc_code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems rather redundant.

add_custom_target(generate_catalog_edc_code
COMMENT "Copying generated EDC code for catalog into Gaia source tree..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation got messed up here too. Is your editor set incorrectly for make files?

DEPENDS ${GAIA_GENERATED_CODE}/catalog/gaia_catalog.cpp
DEPENDS ${GAIA_GENERATED_CODE}/catalog/gaia_catalog.h
DEPENDS ${GAIA_GENERATED_CODE}/catalog/catalog_generated.h
COMMAND cp ${GAIA_GENERATED_CODE}/catalog/gaia_catalog.cpp ${GAIA_REPO}/production/catalog/src/
COMMAND cp ${GAIA_GENERATED_CODE}/catalog/gaia_catalog.h ${GAIA_REPO}/production/inc/gaia_internal/catalog/
COMMAND cp ${GAIA_GENERATED_CODE}/catalog/catalog_generated.h ${GAIA_REPO}/production/inc/gaia_internal/catalog/
)

add_custom_target(generate_catalog_edc_code ALL
DEPENDS ${GAIA_REPO}/catalog/src/gaia_catalog.cpp
DEPENDS ${GAIA_REPO}/inc/gaia_internal/catalog/gaia_catalog.h
DEPENDS ${GAIA_REPO}/inc/gaia_internal/catalog/catalog_generated.h
)
set_target_properties(generate_catalog_edc_code PROPERTIES
EXCLUDE_FROM_ALL true)