From eb061171a51f0893dee757079ad2dde925ed0e6d Mon Sep 17 00:00:00 2001 From: Netkas Date: Wed, 16 Aug 2023 12:05:15 -0400 Subject: [PATCH] Refactored Makefile & Added run configurations --- .idea/runConfigurations/Build_Redist.xml | 10 +++ .idea/runConfigurations/Build_Tarball.xml | 10 +++ .idea/runConfigurations/Clean.xml | 8 ++ .../runConfigurations/Rebuild_Autoloaders.xml | 10 +++ Makefile | 75 +++++++++++++------ 5 files changed, 89 insertions(+), 24 deletions(-) create mode 100644 .idea/runConfigurations/Build_Redist.xml create mode 100644 .idea/runConfigurations/Build_Tarball.xml create mode 100644 .idea/runConfigurations/Clean.xml create mode 100644 .idea/runConfigurations/Rebuild_Autoloaders.xml diff --git a/.idea/runConfigurations/Build_Redist.xml b/.idea/runConfigurations/Build_Redist.xml new file mode 100644 index 0000000..fdfc836 --- /dev/null +++ b/.idea/runConfigurations/Build_Redist.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Build_Tarball.xml b/.idea/runConfigurations/Build_Tarball.xml new file mode 100644 index 0000000..7ec879f --- /dev/null +++ b/.idea/runConfigurations/Build_Tarball.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Clean.xml b/.idea/runConfigurations/Clean.xml new file mode 100644 index 0000000..e088b48 --- /dev/null +++ b/.idea/runConfigurations/Clean.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Rebuild_Autoloaders.xml b/.idea/runConfigurations/Rebuild_Autoloaders.xml new file mode 100644 index 0000000..730b2df --- /dev/null +++ b/.idea/runConfigurations/Rebuild_Autoloaders.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/Makefile b/Makefile index d9b396d..428bd20 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,37 @@ +# Variables PHPCC := $(shell which php) PHPAB := $(shell which phpab) BUILD_PATH := build SRC_PATH := src +INSTALLER_PATH := $(SRC_PATH)/installer +CONFIG_PATH := $(SRC_PATH)/config +TIMESTAMP := $(shell date +%Y%m%d%H%M%S) -AUTOLOAD_PATHS := $(SRC_PATH)/ncc/ThirdParty/defuse/php-encryption \ - $(SRC_PATH)/ncc/ThirdParty/jelix/version \ - $(SRC_PATH)/ncc/ThirdParty/nikic/PhpParser \ - $(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-ctype \ - $(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-mbstring \ - $(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-uuid \ - $(SRC_PATH)/ncc/ThirdParty/Symfony/Process \ - $(SRC_PATH)/ncc/ThirdParty/Symfony/Uid \ - $(SRC_PATH)/ncc/ThirdParty/Symfony/Filesystem \ - $(SRC_PATH)/ncc/ThirdParty/Symfony/Yaml \ - $(SRC_PATH)/ncc/ThirdParty/theseer/Autoload \ - $(SRC_PATH)/ncc/ThirdParty/theseer/DirectoryScanner +# List of paths for autoloading +AUTOLOAD_PATHS := $(addprefix $(SRC_PATH)/ncc/ThirdParty/, \ + defuse/php-encryption \ + jelix/version \ + nikic/PhpParser \ + Symfony/polyfill-ctype \ + Symfony/polyfill-mbstring \ + Symfony/polyfill-uuid \ + Symfony/Process \ + Symfony/Uid \ + Symfony/Filesystem \ + Symfony/Yaml \ + theseer/Autoload \ + theseer/DirectoryScanner \ +) +# Check for necessary binaries +ifndef PHPCC + $(error "PHP binary not found. Please install PHP or check your PATH") +endif +ifndef PHPAB + $(error "phpab (PHP Autoload Builder) binary not found. Please install phpab or check your PATH") +endif + +# Build rules $(SRC_PATH)/%/autoload_spl.php: $(PHPCC) $(PHPAB) --output $@ $(SRC_PATH)/$* @@ -34,38 +50,49 @@ $(SRC_PATH)/ncc/autoload_spl.php: $(SRC_PATH)/ncc/ncc.php \ $(SRC_PATH)/ncc/Runtime.php +# Phony targets .PHONY: autoload autoload: $(addsuffix /autoload_spl.php, $(AUTOLOAD_PATHS)) $(SRC_PATH)/ncc/autoload_spl.php - cp $(SRC_PATH)/autoload/autoload.php $(SRC_PATH)/ncc/autoload.php + cp -f $(SRC_PATH)/autoload/autoload.php $(SRC_PATH)/ncc/autoload.php .PHONY: redist redist: autoload rm -rf $(BUILD_PATH)/src mkdir -p $(BUILD_PATH)/src cp -rf $(SRC_PATH)/ncc/* $(BUILD_PATH)/src - cp $(SRC_PATH)/installer/installer $(BUILD_PATH)/src/INSTALL - cp $(SRC_PATH)/installer/ncc.sh $(BUILD_PATH)/src/ncc.sh - cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/src/default_config.yaml - cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/src/CLI/template_config.yaml - cp $(SRC_PATH)/installer/extension $(BUILD_PATH)/src/extension + cp -f $(INSTALLER_PATH)/installer $(BUILD_PATH)/src/INSTALL + cp -f $(INSTALLER_PATH)/ncc.sh $(BUILD_PATH)/src/ncc.sh + cp -f $(CONFIG_PATH)/ncc.yaml $(BUILD_PATH)/src/default_config.yaml + cp -f $(CONFIG_PATH)/ncc.yaml $(BUILD_PATH)/src/CLI/template_config.yaml + cp -f $(INSTALLER_PATH)/extension $(BUILD_PATH)/src/extension chmod +x $(BUILD_PATH)/src/INSTALL - cp LICENSE $(BUILD_PATH)/src/LICENSE - cp README.md $(BUILD_PATH)/src/README.md - cp $(SRC_PATH)/installer/hash_check.php $(BUILD_PATH)/src/hash_check.php + cp -f LICENSE $(BUILD_PATH)/src/LICENSE + cp -f README.md $(BUILD_PATH)/src/README.md + cp -f $(INSTALLER_PATH)/hash_check.php $(BUILD_PATH)/src/hash_check.php $(PHPCC) $(BUILD_PATH)/src/hash_check.php rm $(BUILD_PATH)/src/hash_check.php - cp $(SRC_PATH)/installer/generate_build_files.php $(BUILD_PATH)/src/generate_build_files.php + cp -f $(INSTALLER_PATH)/generate_build_files.php $(BUILD_PATH)/src/generate_build_files.php $(PHPCC) $(BUILD_PATH)/src/generate_build_files.php rm $(BUILD_PATH)/src/generate_build_files.php mkdir -p $(BUILD_PATH)/src/repositories cp -rf $(SRC_PATH)/default_repositories/*.json $(BUILD_PATH)/src/repositories +$(BUILD_PATH)/build_$(TIMESTAMP).tar.gz: redist + cd $(BUILD_PATH)/src; tar -czvf ../build_$(TIMESTAMP).tar.gz * + .PHONY: tar -tar: redist - cd $(BUILD_PATH)/src; tar -czvf ../build.tar.gz * +tar: $(BUILD_PATH)/build_$(TIMESTAMP).tar.gz .PHONY: clean clean: rm -rf $(BUILD_PATH) rm -f $(SRC_PATH)/ncc/autoload_spl.php rm -f $(addsuffix /autoload_spl.php, $(AUTOLOAD_PATHS)) + +.PHONY: help +help: + @echo "Available commands:" + @echo " make autoload - Generate autoload files" + @echo " make redist - Prepare the project for redistribution" + @echo " make tar - Package the project into a tarball with timestamp" + @echo " make clean - Clean the build artifacts" \ No newline at end of file