<commit_before># the monad-linux superproject and lib directory
export MONAD=$(realpath $(CURDIR))
export PSLIB=$(MONAD)/lib

all: powershell-native powershell-managed

# managed code

powershell-managed:
	$(MAKE) -j -C src/monad-build
	$(MAKE) -j -C src/monad-build test

# native code

powershell-native: src/monad-native/Makefile
	$(MAKE) -j -C src/monad-native
	$(MAKE) -j -C src/monad-native test

src/monad-native/Makefile:
	cd src/monad-native && cmake .

# one-time setup

tools/nuget.exe:
	cd tools && wget 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe'

bootstrap: tools/nuget.exe
	mono $< restore -PackagesDirectory tools

# run targets

export POWERSHELL=env LD_LIBRARY_PATH=$(PSLIB) CORE_ROOT=$(MONAD)/src/monad-ext/coreclr/Runtime PWRSH_ROOT=$(PSLIB) PSMODULEPATH=$(PSLIB)/Modules $(MONAD)/bin/powershell
export POWERSHELL_SIMPLE=$(POWERSHELL) $(PSLIB)/powershell-simple.exe

demo:
	$(POWERSHELL_SIMPLE) '"a","b","c","a","a" | Select-Object -Unique'

shell:
	TEMP=/tmp $(POWERSHELL) lib/powershell-run.exe

# tests

test: test-pester

## TODO: fix this after refactoring bin/powershell
test-hashbang:
	PATH=$(PATH):$(PSLIB) src/3rdparty/hashbang/script.ps1

## Pester tests for PowerShell - results in pester-tests.xml
## - see https://github.com/pester/Pester
## - requires $TEMP to be set
## - we cd because some tests rely on the current working directory
PESTER=$(MONAD)/src/pester-tests
test-pester:
	$(POWERSHELL_SIMPLE) 'cd $(PESTER); $$env:TEMP="/tmp"; invoke-pester -OutputFile $(MONAD)/pester-tests.xml -OutputFormat NUnitXml'

## Pester self-tests
## - results in pester-self-tests.xml
test-pester-self:
	$(POWERSHELL_SIMPLE) 'cd $(PSLIB)/Modules/Pester/Functions; $$env:TEMP="/tmp"; invoke-pester -OutputFile $(MONAD)/pester-self-tests.xml -OutputFormat NUnitXml'

## tracing
## - use PAL_DBG_CHANNELS="+LOADER.TRACE" to enable CoreCLR tracing
## - use Set-PSDebug -Trace 2 to enable PowerShell tracing

# OMI
OMI=src/omi/Unix
OMI_FLAGS=--dev --enable-debug
$(OMI)/GNUmakefile:
	cd $(OMI) && ./configure $(OMI_FLAGS)

OMISERVER=$(OMI)/output/bin/omiserver
$(OMISERVER): $(OMI)/GNUmakefile
	$(MAKE) -j -C $(OMI)

## copy libpshost because OMI isn't configurable
MONAD_PROVIDER=src/monad-omi-provider
PSRP_OMI_PROVIDER=$(OMI)/output/lib/libpsrpomiprov.so
$(PSRP_OMI_PROVIDER): $(OMISERVER) powershell-native
	cp lib/libpshost.a $(OMI)/output/lib
	$(MAKE) -j -C $(MONAD_PROVIDER)

psrp: $(PSRP_OMI_PROVIDER)

## phony targets so that the recursive make is always invoked
.PHONY: $(OMISERVER) $(PSRP_OMI_PROVIDER)

# clean targets

clean: clean-monad
	-rm *-tests.xml

distclean: distclean-monad distclean-native distclean-omi clean
	-rm -rf tools/*
<commit_msg>Don't rm -rf tools on make distclean<commit_after># the monad-linux superproject and lib directory
export MONAD=$(realpath $(CURDIR))
export PSLIB=$(MONAD)/lib

all: powershell-native powershell-managed

# managed code

powershell-managed:
	$(MAKE) -j -C src/monad-build
	$(MAKE) -j -C src/monad-build test

# native code

powershell-native: src/monad-native/Makefile
	$(MAKE) -j -C src/monad-native
	$(MAKE) -j -C src/monad-native test

src/monad-native/Makefile:
	cd src/monad-native && cmake .

# one-time setup

tools/nuget.exe:
	cd tools && wget 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe'

bootstrap: tools/nuget.exe
	mono $< restore -PackagesDirectory tools

# run targets

export POWERSHELL=env LD_LIBRARY_PATH=$(PSLIB) CORE_ROOT=$(MONAD)/src/monad-ext/coreclr/Runtime PWRSH_ROOT=$(PSLIB) PSMODULEPATH=$(PSLIB)/Modules $(MONAD)/bin/powershell
export POWERSHELL_SIMPLE=$(POWERSHELL) $(PSLIB)/powershell-simple.exe

demo:
	$(POWERSHELL_SIMPLE) '"a","b","c","a","a" | Select-Object -Unique'

shell:
	TEMP=/tmp $(POWERSHELL) lib/powershell-run.exe

# tests

test: test-pester

## TODO: fix this after refactoring bin/powershell
test-hashbang:
	PATH=$(PATH):$(PSLIB) src/3rdparty/hashbang/script.ps1

## Pester tests for PowerShell - results in pester-tests.xml
## - see https://github.com/pester/Pester
## - requires $TEMP to be set
## - we cd because some tests rely on the current working directory
PESTER=$(MONAD)/src/pester-tests
test-pester:
	$(POWERSHELL_SIMPLE) 'cd $(PESTER); $$env:TEMP="/tmp"; invoke-pester -OutputFile $(MONAD)/pester-tests.xml -OutputFormat NUnitXml'

## Pester self-tests
## - results in pester-self-tests.xml
test-pester-self:
	$(POWERSHELL_SIMPLE) 'cd $(PSLIB)/Modules/Pester/Functions; $$env:TEMP="/tmp"; invoke-pester -OutputFile $(MONAD)/pester-self-tests.xml -OutputFormat NUnitXml'

## tracing
## - use PAL_DBG_CHANNELS="+LOADER.TRACE" to enable CoreCLR tracing
## - use Set-PSDebug -Trace 2 to enable PowerShell tracing

# OMI
OMI=src/omi/Unix
OMI_FLAGS=--dev --enable-debug
$(OMI)/GNUmakefile:
	cd $(OMI) && ./configure $(OMI_FLAGS)

OMISERVER=$(OMI)/output/bin/omiserver
$(OMISERVER): $(OMI)/GNUmakefile
	$(MAKE) -j -C $(OMI)

## copy libpshost because OMI isn't configurable
MONAD_PROVIDER=src/monad-omi-provider
PSRP_OMI_PROVIDER=$(OMI)/output/lib/libpsrpomiprov.so
$(PSRP_OMI_PROVIDER): $(OMISERVER) powershell-native
	cp lib/libpshost.a $(OMI)/output/lib
	$(MAKE) -j -C $(MONAD_PROVIDER)

psrp: $(PSRP_OMI_PROVIDER)

## phony targets so that the recursive make is always invoked
.PHONY: $(OMISERVER) $(PSRP_OMI_PROVIDER)

# clean targets

clean: clean-monad
	-rm *-tests.xml

distclean: distclean-monad distclean-native distclean-omi clean

{'fraction_non_alphanumeric': 0.15210954848260547, 'fraction_numerical': 0.001850481125092524, 'mean_word_length': 4.959206174200662, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5635515', 'n_tokens_mistral': 2103, 'n_tokens_neox': 2053, 'n_words': 441}