diff --git a/.github/workflows/test-jsock.yml b/.github/workflows/test-jsock.yml new file mode 100644 index 0000000..195c262 --- /dev/null +++ b/.github/workflows/test-jsock.yml @@ -0,0 +1,67 @@ +name: Test Maker with jsock + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "**" ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository with submodules + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y g++ make libncurses-dev + + - name: Setup jsock with convention-based build + run: | + # Copy Maker makefile + cp makefile test-projects/jsock/makefile + + # Create per-module makefiles (convention-based approach) + cat > test-projects/jsock/jsock/makefile <<'EOF' + moduleType = slib + moduleDeps = + moduleCompFlags = + moduleLinkFlags = + EOF + + cat > test-projects/jsock/demos/chat/client/makefile <<'EOF' + moduleType = exec + moduleDeps = jsock + moduleCompFlags = -I . + moduleLinkFlags = -l ncurses + EOF + + cat > test-projects/jsock/demos/chat/server/makefile <<'EOF' + moduleType = exec + moduleDeps = jsock + moduleCompFlags = -I . + moduleLinkFlags = -l ncurses + EOF + + - name: Build jsock library + working-directory: test-projects/jsock + run: make jsock + + - name: Build chat client + working-directory: test-projects/jsock + run: make demos/chat/client + + # Note: Skipping server build due to compilation error in jsock code + # (missing #include in ParsingEndpoint.cpp) + + - name: Verify build artifacts exist + run: | + ls -la test-projects/jsock/_build/ + test -f test-projects/jsock/_build/jsock.lib + test -f test-projects/jsock/_build/demos/chat/client.out + echo "All build artifacts verified successfully!" diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b6fa78b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "test-projects/jsock"] + path = test-projects/jsock + url = https://github.com/janderland/jsock.git diff --git a/makefile b/makefile index 7fbf717..bf329fc 100644 --- a/makefile +++ b/makefile @@ -12,18 +12,14 @@ # GLOBAL CONFIG ############### -# Path(s) to configuration file(s). -configFiles=config.mkr - - # Directory where all files generated by the build go. -buildDir=_build +buildDir ?= _build # C++ Compiler Executable # This executable is used to convert C++ source files into # C++ object files. -cxx=g++ +cxx ?= g++ # C++ Compiler Flags @@ -34,37 +30,44 @@ cxx=g++ # NOTE: Flags responsible for header-dependency information # are already included by this makefile. They shouldn't be # added here. -cxxFlags= -cxxFlagsComp= -cxxFlagsLink= +cxxFlags ?= +cxxFlagsComp ?= +cxxFlagsLink ?= + + +# Path to the ar utility. +ar ?= ar # Flags passed to the ar utility. -arFlags=rcs +arFlags ?= rcs + + +# Path to the rm utility. +rm ?=/bin/rm # File extensions for the input files -sourceExt=cpp +sourceExt ?= cpp # File extensions for the generated executables and # static libraries. -execExt=out -slibExt=lib +execExt ?= out +slibExt ?= lib # Set this variable to a non-empty string to turn off # verbose output. -verbose= +verbose ?= true # GLOBAL PROCESSING ################### -# Ensure all required global variables are defined. -requiredVars=buildDir cxx execExt slibExt -$(foreach v,$(requiredVars),$(if $($v),,$(error $v is required but not defined))) +# Let included makefiles know this is Maker. +isMaker=true # Empty the .SUFFIXES variable to turn off @@ -94,7 +97,7 @@ $1: cxxFlagsCompExtra = $3 $1: $2 @echo "Packaging $$@" mkdir -p $$(dir $$@) - ar $$(arFlags) $4 $$@ $$^ + $$(ar) $$(arFlags) $4 $$@ $$^ endef @@ -109,7 +112,7 @@ $1: cxxFlagsCompExtra = $3 $1: $2 @echo "Linking $$@" mkdir -p $$(dir $$@) - $$(cxx) $$(cxxFlags) $$(cxxFlagsLink) $4 $$^ -o $$@ + $$(cxx) $$(cxxFlags) $$(cxxFlagsLink) $$^ -o $$@ $4 endef @@ -126,11 +129,10 @@ endef # Define Run Rule # 1 - Rule Name # 2 - Executable -# 3 - Depedencies -runRule=$(eval $(call runRuleTempl,$1,$2,$3)) +runRule=$(eval $(call runRuleTempl,$1,$2)) define runRuleTempl .PHONY: $1 -$1: $2 $3 +$1: $2 @echo "Running $$<" $$< endef @@ -140,12 +142,7 @@ endef # LOGGING MACROS ################ -# Log - Normal -# 1 - Message -log=$(info $1) - - -# Log - Debug +# Log Debug Message # 1 - Message debug=$(if $(verbose),$(info $1)) @@ -154,35 +151,35 @@ debug=$(if $(verbose),$(info $1)) # METADATA MACROS ################# -# Check Path Exists -# 1 - Input path -checkPathExists=$(if $(shell test -d $1 && echo true),,$(error $1 isn't a directory)) +# Module Path +# 1 - Module Makefile Path +modulePath=$(patsubst %/,%,$(dir $1)) # Check Path For 'At' Symbol ('@' isn't allowed in Maker paths) -# 1 - Input path +# 1 - Module Path checkPathForAt=$(if $(findstring @,$1),$(error $1 contains the @ symbol)) # Runner Name -# 1 - Input path +# 1 - Module Path rname=run@$1 # Input Source Files -# 1 - Input path -sources=$(shell find $1 -iname *.$(sourceExt)) +# 1 - Module Path +sources=$(shell find $1 -iname '*.$(sourceExt)') # Output Object Files -# 1 - Input path +# 1 - Module Path objects=$(addprefix $(buildDir)/,$(patsubst %.cpp,%.obj,$(call sources,$1))) # Output File Path -# 1 - Input path +# 1 - Module Path # 2 - Type -file=$(buildDir)/$1.$(call fileExt,$2) +ofile=$(buildDir)/$1.$(call fileExt,$2) # Output File Extension @@ -218,7 +215,7 @@ Compile Flags : $4 Linker Flags : $5 Source Files : $(call sources,$1) Object Files : $(call objects,$1) -Output File : $(call file,$1,$2) +Output File : $(call ofile,$1,$2) endef @@ -228,13 +225,10 @@ endef # 3 - Dependencies # 4 - Compile Flags # 5 - Link/Package Flags -# 6 - Run Dependencies -module=$(eval $(call moduleTempl,$(strip $1),$(strip $2),$(strip $3),$(strip $4),$(strip $5),$(strip $6))) +module=$(eval $(call moduleTempl,$(strip $1),$(strip $2),$(strip $3),$(strip $4),$(strip $5))) define moduleTempl $(call debug,Defining module for $1) -$(call checkPathExists,$1) $(call checkPathForAt,$1) - $(call debug,$(call formatMetadata,$1,$2,$3,$4,$5)) $(call debug,) @@ -242,28 +236,31 @@ $(1)Type=$2 $(1)Deps=$3 $(1)CFlags=$4 $(1)LFlags=$5 -$(1)RunDeps=$6 targets+=$1 endef +# Parse Module Makefile +# 1 - Module Makefile +parseModule=$(eval $(call parseModuleTempl,$1)) +define parseModuleTempl +$(eval include $f) +$(call module,$(call modulePath,$f),$(moduleType),$(moduleDeps),$(moduleCompFlags),$(moduleLinkFlags)) +endef + + # Dependency Files # 1 - Dependency input paths -depFiles=$(foreach v,$1,$(call file,$v,$($(v)Type))) +depFiles=$(foreach v,$1,$(call ofile,$v,$($(v)Type))) # Define Module Rules # 1 - Input Path -rules=$(eval $(call rulesTempl,$1,$($(1)Type),$($(1)Deps),$($(1)CFlags),$($(1)LFlags),$($(1)RunDeps))) +rules=$(eval $(call rulesTempl,$1,$($(1)Type),$($(1)Deps),$($(1)CFlags),$($(1)LFlags))) define rulesTempl -# Define the file rule -$(call $(call fileRuleName,$2),$(call file,$1,$2),$(call objects,$1) $(call depFiles,$3),$4,$5) - -# Define the alias rule -$(call aliasRule,$1,$(call file,$1,$2)) - -# Define the run rule (only for executables) -$(if $(filter exec,$2),$(call runRule,$(call rname,$1),$(call file,$1,$2),$6)) +$(call $(call fileRuleName,$2),$(call ofile,$1,$2),$(call objects,$1) $(call depFiles,$3),$4,$5) +$(call aliasRule,$1,$(call ofile,$1,$2)) +$(if $(filter exec,$2),$(call runRule,$(call rname,$1),$(call ofile,$1,$2))) endef @@ -277,40 +274,14 @@ headerDepFiles=$(shell if [ -d $(buildDir) ]; then find $(buildDir) -iname *.dep -# PUBLIC MACROS -############### - -# Declare Module -# 0 - Type -# 1 - Input path -# 2 - Dependencies -# 3 - Compile Flags -# 4 - Link/Package Flags -moduleTypes=exec slib -$(foreach v,$(moduleTypes),$(eval $v=$$(call module,$$1,$$0,$$2,$$3,$$4))) - - - # LOAD METADATA ############### -# Parse Config File -# 1 - Config file path -parseConfig=$(call debug,Parsing $1)$(call debug,)\ - $(eval tempFile=$(shell mktemp))\ - $(shell perl -pe '$(parserCode)' < $1 > $(tempFile))\ - $(eval include $(tempFile)) -define parserCode -s/(?