Refactored Makefile & Added run configurations

This commit is contained in:
Netkas 2023-08-16 12:05:15 -04:00
parent e576b3b4c0
commit eb061171a5
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
5 changed files with 89 additions and 24 deletions

10
.idea/runConfigurations/Build_Redist.xml generated Normal file
View file

@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build Redist" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
<makefile filename="$PROJECT_DIR$/Makefile" target="redist" workingDirectory="" arguments="">
<envs />
</makefile>
<method v="2">
<option name="RunConfigurationTask" enabled="true" run_configuration_name="Clean" run_configuration_type="MAKEFILE_TARGET_RUN_CONFIGURATION" />
</method>
</configuration>
</component>

View file

@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build Tarball" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
<makefile filename="$PROJECT_DIR$/Makefile" target="tar" workingDirectory="" arguments="">
<envs />
</makefile>
<method v="2">
<option name="RunConfigurationTask" enabled="true" run_configuration_name="Clean" run_configuration_type="MAKEFILE_TARGET_RUN_CONFIGURATION" />
</method>
</configuration>
</component>

8
.idea/runConfigurations/Clean.xml generated Normal file
View file

@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Clean" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile" activateToolWindowBeforeRun="false">
<makefile filename="$PROJECT_DIR$/Makefile" target="clean" workingDirectory="" arguments="">
<envs />
</makefile>
<method v="2" />
</configuration>
</component>

View file

@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Rebuild Autoloaders" type="MAKEFILE_TARGET_RUN_CONFIGURATION" factoryName="Makefile">
<makefile filename="$PROJECT_DIR$/Makefile" target="autoload" workingDirectory="" arguments="">
<envs />
</makefile>
<method v="2">
<option name="RunConfigurationTask" enabled="true" run_configuration_name="Clean" run_configuration_type="MAKEFILE_TARGET_RUN_CONFIGURATION" />
</method>
</configuration>
</component>

View file

@ -1,21 +1,37 @@
# Variables
PHPCC := $(shell which php) PHPCC := $(shell which php)
PHPAB := $(shell which phpab) PHPAB := $(shell which phpab)
BUILD_PATH := build BUILD_PATH := build
SRC_PATH := src 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 \ # List of paths for autoloading
$(SRC_PATH)/ncc/ThirdParty/jelix/version \ AUTOLOAD_PATHS := $(addprefix $(SRC_PATH)/ncc/ThirdParty/, \
$(SRC_PATH)/ncc/ThirdParty/nikic/PhpParser \ defuse/php-encryption \
$(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-ctype \ jelix/version \
$(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-mbstring \ nikic/PhpParser \
$(SRC_PATH)/ncc/ThirdParty/Symfony/polyfill-uuid \ Symfony/polyfill-ctype \
$(SRC_PATH)/ncc/ThirdParty/Symfony/Process \ Symfony/polyfill-mbstring \
$(SRC_PATH)/ncc/ThirdParty/Symfony/Uid \ Symfony/polyfill-uuid \
$(SRC_PATH)/ncc/ThirdParty/Symfony/Filesystem \ Symfony/Process \
$(SRC_PATH)/ncc/ThirdParty/Symfony/Yaml \ Symfony/Uid \
$(SRC_PATH)/ncc/ThirdParty/theseer/Autoload \ Symfony/Filesystem \
$(SRC_PATH)/ncc/ThirdParty/theseer/DirectoryScanner 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: $(SRC_PATH)/%/autoload_spl.php:
$(PHPCC) $(PHPAB) --output $@ $(SRC_PATH)/$* $(PHPCC) $(PHPAB) --output $@ $(SRC_PATH)/$*
@ -34,38 +50,49 @@ $(SRC_PATH)/ncc/autoload_spl.php:
$(SRC_PATH)/ncc/ncc.php \ $(SRC_PATH)/ncc/ncc.php \
$(SRC_PATH)/ncc/Runtime.php $(SRC_PATH)/ncc/Runtime.php
# Phony targets
.PHONY: autoload .PHONY: autoload
autoload: $(addsuffix /autoload_spl.php, $(AUTOLOAD_PATHS)) $(SRC_PATH)/ncc/autoload_spl.php 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 .PHONY: redist
redist: autoload redist: autoload
rm -rf $(BUILD_PATH)/src rm -rf $(BUILD_PATH)/src
mkdir -p $(BUILD_PATH)/src mkdir -p $(BUILD_PATH)/src
cp -rf $(SRC_PATH)/ncc/* $(BUILD_PATH)/src cp -rf $(SRC_PATH)/ncc/* $(BUILD_PATH)/src
cp $(SRC_PATH)/installer/installer $(BUILD_PATH)/src/INSTALL cp -f $(INSTALLER_PATH)/installer $(BUILD_PATH)/src/INSTALL
cp $(SRC_PATH)/installer/ncc.sh $(BUILD_PATH)/src/ncc.sh cp -f $(INSTALLER_PATH)/ncc.sh $(BUILD_PATH)/src/ncc.sh
cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/src/default_config.yaml cp -f $(CONFIG_PATH)/ncc.yaml $(BUILD_PATH)/src/default_config.yaml
cp $(SRC_PATH)/config/ncc.yaml $(BUILD_PATH)/src/CLI/template_config.yaml cp -f $(CONFIG_PATH)/ncc.yaml $(BUILD_PATH)/src/CLI/template_config.yaml
cp $(SRC_PATH)/installer/extension $(BUILD_PATH)/src/extension cp -f $(INSTALLER_PATH)/extension $(BUILD_PATH)/src/extension
chmod +x $(BUILD_PATH)/src/INSTALL chmod +x $(BUILD_PATH)/src/INSTALL
cp LICENSE $(BUILD_PATH)/src/LICENSE cp -f LICENSE $(BUILD_PATH)/src/LICENSE
cp README.md $(BUILD_PATH)/src/README.md cp -f README.md $(BUILD_PATH)/src/README.md
cp $(SRC_PATH)/installer/hash_check.php $(BUILD_PATH)/src/hash_check.php cp -f $(INSTALLER_PATH)/hash_check.php $(BUILD_PATH)/src/hash_check.php
$(PHPCC) $(BUILD_PATH)/src/hash_check.php $(PHPCC) $(BUILD_PATH)/src/hash_check.php
rm $(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 $(PHPCC) $(BUILD_PATH)/src/generate_build_files.php
rm $(BUILD_PATH)/src/generate_build_files.php rm $(BUILD_PATH)/src/generate_build_files.php
mkdir -p $(BUILD_PATH)/src/repositories mkdir -p $(BUILD_PATH)/src/repositories
cp -rf $(SRC_PATH)/default_repositories/*.json $(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 .PHONY: tar
tar: redist tar: $(BUILD_PATH)/build_$(TIMESTAMP).tar.gz
cd $(BUILD_PATH)/src; tar -czvf ../build.tar.gz *
.PHONY: clean .PHONY: clean
clean: clean:
rm -rf $(BUILD_PATH) rm -rf $(BUILD_PATH)
rm -f $(SRC_PATH)/ncc/autoload_spl.php rm -f $(SRC_PATH)/ncc/autoload_spl.php
rm -f $(addsuffix /autoload_spl.php, $(AUTOLOAD_PATHS)) 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"