Skip to content

Commit

Permalink
add diff targets
Browse files Browse the repository at this point in the history
  • Loading branch information
pskrbasu committed Jan 11, 2024
1 parent 77f4f61 commit b9f2f18
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ steampipe_postgres_fdw.h
build-*/
# intermediate files from clang
*.bc
# work directory created by the standalone fdw building
/work
58 changes: 49 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ install: build
standalone: validate_plugin prebuild.go
@echo "Building standalone FDW for plugin: $(plugin)"

# Create a new directory for the build process
mkdir -p render
# Remove existing work dir and create a new directory for the render process
rm -rf work && \
mkdir -p work

# Copy the entire source tree, excluding .git directory, into the new directory
rsync -a --exclude='.git' . render/ >/dev/null 2>&1
rsync -a --exclude='.git' . work/ >/dev/null 2>&1

# Change to the new directory to perform operations
cd render && \
cd work && \
go run generate/generator.go templates . $(plugin) $(plugin_github_url) && \
go mod tidy && \
$(MAKE) -C ./fdw clean && \
Expand All @@ -35,13 +36,51 @@ standalone: validate_plugin prebuild.go
# build-${PLATFORM} folder
rm -rf build-${PLATFORM} && \
mkdir -p build-${PLATFORM} && \
cp -a render/build-${PLATFORM}/* build-${PLATFORM}/
cp -a work/build-${PLATFORM}/* build-${PLATFORM}/

# Clean up the render directory
rm -rf render
# Note: The work directory will contain the full code tree with changes,
# binaries will be copied to build-${PLATFORM} folder

# Note: The render directory will contain the full code tree with changes,
# binaries will be copied to build-${PLATFORM}, and then render will be deleted
# render target
render: validate_plugin prebuild.go
@echo "Rendering code for plugin: $(plugin)"

# Remove existing work dir and create a new directory for the render process
rm -rf work && \
mkdir -p work

# Copy the entire source tree, excluding .git directory, into the new directory
rsync -a --exclude='.git' . work/ >/dev/null 2>&1

# Change to the new directory to perform operations
cd work && \
go run generate/generator.go templates . $(plugin) $(plugin_github_url) && \
go mod tidy

# Note: The work directory will contain the full code tree with rendered changes

# build_from_work target
build_from_work:
@if [ ! -d "work" ]; then \
echo "Error: 'work' directory does not exist. Please run the render target first." >&2; \
exit 1; \
fi
@echo "Building from work directory for plugin: $(plugin)"

# Change to the work directory to perform build operations
cd work && \
$(MAKE) -C ./fdw clean && \
$(MAKE) -C ./fdw go && \
$(MAKE) -C ./fdw && \
$(MAKE) -C ./fdw standalone

# Delete existing build-${PLATFORM} and copy the binaries to the actual
# build-${PLATFORM} folder
rm -rf build-${PLATFORM} && \
mkdir -p build-${PLATFORM} && \
cp -a work/build-${PLATFORM}/* build-${PLATFORM}/

# Note: This target builds from the 'work' directory and copies binaries to the build-${PLATFORM} folder

validate_plugin:
ifndef plugin
Expand Down Expand Up @@ -78,6 +117,7 @@ clean:
rm -f prebuild.go
rm -f steampipe_postgres_fdw.a
rm -f steampipe_postgres_fdw.h
rm -rf work

# Used to build the Darwin ARM binaries and upload to the github draft release.
# Usage: make release input="v1.7.2"
Expand Down

0 comments on commit b9f2f18

Please sign in to comment.