Skip to content

Commit

Permalink
Update license, makefiles + read files from uri
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Aug 10, 2024
1 parent fcdee20 commit aa03b1c
Show file tree
Hide file tree
Showing 12 changed files with 785 additions and 48 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

34 changes: 22 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ PROXY?=
BLUE=\033[0;34m
NC=\033[0m # No Color

help:
.PHONY: help
help: LICENSE
@echo "This project has a number of recipes that are delegated to other Makefiles. The following jobs are available with no prefix"
@echo " $(BLUE)clean$(NC)"
@echo " $(BLUE)html$(NC)"
Expand Down Expand Up @@ -36,34 +37,43 @@ help:
@echo "The following jobs are available under the rs_ prefix"
@$(MAKE) rs_help $(MFLAGS) --no-print-directory


html dirhtml singlehtml epub latex:
.PHONY: html dirhtml singlehtml epub latex
html dirhtml singlehtml epub latex: LICENSE
@$(MAKE) docs_$@ $(MFLAGS)

clean: cs_clean cp_clean c_clean ja_clean js_clean py_clean rs_clean docs_clean
.PHONY: clean
clean: LICENSE cs_clean cp_clean c_clean ja_clean js_clean py_clean rs_clean docs_clean

cs_%:
.PHONY: cs_%
cs_%: LICENSE
@cd csharp && $(MAKE) $* $(MFLAGS)

cp_%:
.PHONY: cp_%
cp_%: LICENSE
@cd cplusplus && $(MAKE) $* $(MFLAGS)

c_%:
.PHONY: c_%
c_%: LICENSE
@cd c && $(MAKE) $* $(MFLAGS)

docs_%:
.PHONY: docs_%
docs_%: LICENSE
@cd docs && $(MAKE) $* $(MFLAGS)

ja_%:
.PHONY: ja_%
ja_%: LICENSE
@cd java && $(MAKE) $* $(MFLAGS)

js_%:
.PHONY: js_%
js_%: LICENSE
@cd javascript && $(MAKE) $* $(MFLAGS)

py_%:
.PHONY: py_%
py_%: LICENSE
@cd python && $(MAKE) $* $(MFLAGS)

rs_%:
.PHONY: rs_%
rs_%: LICENSE
@cd rust && $(MAKE) $* $(MFLAGS)

%:
Expand Down
19 changes: 14 additions & 5 deletions c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PROXY_ARG=
endif
endif

.PHONY: help
help:
@echo " $(BLUE)test$(NC) run through all tests in sequence. Utilizes the Python test runner infrastructure"
@echo " $(BLUE)test_*$(NC) run through all tests in parallel with the given number of threads. Use auto to allow the test runner to determine it. Utilizes the Python test runner infrastructure"
Expand All @@ -22,34 +23,42 @@ help:
@echo " $(BLUE)native$(NC) build a test binary utilizing the Unity test framework"
@echo " $(BLUE)clean$(NC) clean up any stray files"

test_%: submodules dependencies
.PHONY: test_%
test_%: ../LICENSE submodules dependencies
cd ../python; $(MAKE) dependencies $(MFLAGS)
$(PY) -m pytest -dvl -n$* test_euler.py --cov

test: submodules dependencies
.PHONY: test
test: ../LICENSE submodules dependencies
$(PY) -m pytest -vl --benchmark-sort=fullname --benchmark-group-by=fullfunc --benchmark-verbose test_euler.py --cov

.PHONY: submodules
submodules:
git submodule init
git submodule update

.PHONY: dependencies
dependencies: submodules
$(PIP) install -r requirements.txt -r ../python/requirements.txt $(USER_FLAG) $(PROXY_ARG)

.PHONY: lint
lint:
if test -z "$(clang-tidy src/p0000_template.c -warnings-as-errors=* 2>&1 | grep "Unknown command line argument")"; then \
clang-tidy src/*.c -warnings-as-errors=-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling; \
else \
clang-tidy src/*.c; \
fi

native: submodules
.PHONY: native
native: ../LICENSE submodules
$(CC) test.c Unity/src/unity.c -O2 -lm -lc -Wall -Werror -march=native -flto -DAMD_COMPILER=0

.PHONY: clean
clean:
rm -r build ./{*,*/*}{.pyc,__pycache__,.mypy_cache} || echo

wasm: submodules
.PHONY: wasm
wasm: ../LICENSE submodules
wget https://github.com/jedisct1/libclang_rt.builtins-wasm32.a -O wasm32.a
mkdir -p build
clang -DUNITY_END --target=wasm32-unknown-wasi --sysroot /tmp/wasi-libc -nostartfiles -Wl,--import-memory -Wl,--no-entry -Wl,--export-all -o build/c.wasm test.c
clang -DUNITY_END --target=wasm32-unknown-wasi --sysroot /tmp/wasi-libc -nostartfiles -Wl,--import-memory -Wl,--no-entry -Wl,--export-all -o build/c.wasm test.c
14 changes: 11 additions & 3 deletions cplusplus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,44 @@ PROXY_ARG=
endif
endif

.PHONY: help
help:
@echo " $(BLUE)test$(NC) run through all tests in sequence. Utilizes the Python test runner infrastructure"
@echo " $(BLUE)test_*$(NC) run through all tests in parallel with the given number of threads. Use auto to allow the test runner to determine it. Utilizes the Python test runner infrastructure"
@echo " $(BLUE)dependencies$(NC) initialize submodules and install any Python dependencies"
@echo " $(BLUE)lint$(NC) run clang-tidy across each of the .cpp and .h files"
@echo " $(BLUE)clean$(NC) clean up any stray files"

test_%: dependencies
.PHONY: test_%
test_%: ../LICENSE dependencies
cd ../python; $(MAKE) dependencies $(MFLAGS)
$(PY) -m pytest -dvl -n$* test_euler.py --cov

test: dependencies
.PHONY: test
test: ../LICENSE dependencies
$(PY) -m pytest -vl --benchmark-sort=fullname --benchmark-group-by=fullfunc --benchmark-verbose test_euler.py --cov

.PHONY: submodules
submodules:
git submodule init
git submodule update

.PHONY: dependencies
dependencies:
$(PIP) install -r requirements.txt -r ../python/requirements.txt $(USER_FLAG) $(PROXY_ARG)

.PHONY: lint
lint:
if test -z "$(clang-tidy src/p0000_template.cpp -warnings-as-errors=* 2>&1 | grep "Unknown command line argument")"; then \
clang-tidy src/*.cpp -warnings-as-errors=-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling; \
else \
clang-tidy src/*.cpp; \
fi

native: submodules
.PHONY: native
native: ../LICENSE submodules
$(CXX) test.cpp Unity/src/unity.c -O2 -lm -Wall -Werror -std=c++11 -march=native -flto -DAMD_COMPILER=0 -Wno-deprecated

.PHONY: clean
clean:
rm -r build ./{*,*/*}{.pyc,__pycache__,.mypy_cache} || echo
10 changes: 8 additions & 2 deletions csharp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,35 @@ else
cov_args=
endif

.PHONY: help
help:
@echo " $(BLUE)test$(NC) run through all tests in sequence. Utilizes the Xunit framework"
@echo " $(BLUE)test_*$(NC) run through all tests in parallel with the given number of threads. Use auto to allow the test runner to determine it. Utilizes the Xunit framework"
@echo " $(BLUE)dependencies$(NC) runs dotnet restore"
@echo " $(BLUE)lint$(NC) runs dotnet format --verify-no-changes"
@echo " $(BLUE)clean$(NC) clean up any stray files"

.PHONY: clean
clean:
dotnet clean || rm ./*/{bin,obj,TestResults} || echo

test:
.PHONY: test
test: ../LICENSE
ifneq ($(NOT_TERMUX),0)
dotnet test --nologo $(cov_args)
endif

test_%:
.PHONY: test_%
test_%: ../LICENSE
$(MAKE) test $(MFLAGS)

.PHONY: dependencies
dependencies:
ifneq ($(NOT_TERMUX),0)
dotnet restore
endif

.PHONY: lint
lint:
ifneq ($(NOT_TERMUX),0)
dotnet format --verify-no-changes
Expand Down
10 changes: 6 additions & 4 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ endif
endif

# Put it first so that "make" without argument is like "make help".
.PHONY: help
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

.PHONY: clean
clean:
rm -r _build _static/test-*.html _static/dist || echo

.PHONY: dependencies
dependencies:
$(PIP) install -r requirements.txt -r ../c/requirements.txt -r ../python/requirements.txt --upgrade $(USER_FLAG) $(PROXY_ARG)
npm install -g jsdoc
Expand Down Expand Up @@ -65,10 +66,11 @@ _static/test-rs.html:
cp ../rust/dist/bundle-rs.js _static/dist/bundle-rs.js
cat _static/dist/test-js.html | sed s#_static/bundle-js.js#_static/bundle-rs.js > _static/test-rs.html

html: _static/dist/bundle.js _static/dist/python.tar.gz
.PHONY: html
html: ../LICENSE _static/dist/bundle.js _static/dist/python.tar.gz
$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%:
%: ../LICENSE
$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15 changes: 8 additions & 7 deletions java/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ MVN?=mvn
BLUE=\033[0;34m
NC=\033[0m # No Color

.PHONY: help
help:
@echo " $(BLUE)test$(NC) run through all tests in sequence"
@echo " $(BLUE)test_*$(NC) run through all tests in parallel with the given number of threads. Use auto to allow the test runner to determine it"
@echo " $(BLUE)dependencies$(NC) grabs all dependencies through maven"
@echo " $(BLUE)clean$(NC) clean up any stray files"
@echo " $(BLUE)lint$(NC) Run the maven formatter"

.PHONY: clean
clean:
$(MVN) clean || echo

dependencies:
$(MVN) install -B

test: dependencies
.PHONY: test
test: ../LICENSE
$(MVN) -e test -Dtest.single

test_auto: dependencies
test_auto: ../LICENSE
$(MVN) -e test -T 1C

test_%: dependencies
.PHONY: test_%
test_%: ../LICENSE
$(MVN) -e test -T $*

.PHONY: lint
lint:
$(MVN) formatter:format
11 changes: 10 additions & 1 deletion java/src/main/java/euler/lib/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Utilities {

private static Path getDataPath(String name) throws IOException {
Path classPath = Paths.get(Utilities.class.getProtectionDomain().getCodeSource().getLocation().getPath());
try {
URI classUri = Utilities.class.getProtectionDomain().getCodeSource().getLocation().toURI();
Path classPath = Paths.get(classUri);
// Path classPath = Paths.get(Utilities.class.getProtectionDomain().getCodeSource().getLocation().getPath());
Path classDir = classPath.getParent();
Path filePath = classDir.getParent().getParent().resolve("_data").resolve(name);
return filePath;
}
catch (URISyntaxException e) {
throw new IOException("Invalid syntax in class path");
}
}

public static byte[] getDataFileBytes(String name) throws IOException {
Expand Down
18 changes: 14 additions & 4 deletions javascript/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ endif
BLUE=\033[0;34m
NC=\033[0m # No Color

.PHONY: help
help:
@echo " $(BLUE)test$(NC) run through all tests in sequence. Utilizes the Mocha test runner"
@echo " $(BLUE)test_*$(NC) run through all tests in parallel with the given number of threads. Use auto to allow the test runner to determine it. Utilizes the Mocha test runner"
Expand All @@ -20,26 +21,31 @@ help:
@echo " $(BLUE)webpack$(NC) Packages these tests for use in browsers"
@echo " $(BLUE)clean$(NC) clean up any stray files"

test: dependencies
.PHONY: test
test: ../LICENSE dependencies
$(MOCHA) euler.test.js

test_auto: dependencies
$(MOCHA) --parallel euler.test.js

test_%: dependencies
.PHONY: test_%
test_%: ../LICENSE dependencies
$(MOCHA) --parallel -j $* euler.test.js

.PHONY: bun_dependencies
bun_dependencies:
if ! command -v bun; then npm -g install bun; fi
bun install

bun_test: bun_dependencies
.PHONY: bun_test
bun_test: ../LICENSE bun_dependencies
ifeq ($(COV),true)
bun test --coverage --coverage-reporter lcov
else
bun test
endif

.PHONY: dependencies
ifneq ($(HAS_NPM),0)
ifeq ($(OS),Windows_NT) # if no NPM and Windows
dependencies:
Expand All @@ -63,19 +69,23 @@ else # has NPM
dependencies: _dependencies
endif

.PHONY: _dependencies
_dependencies:
ifeq ($(COV),true)
npm install -g istanbul
endif
npm install --include=dev

.PHONY: lint
lint: dependencies
npx eslint *.js src/*.js src/lib/*.js --ignore-pattern "dist/*"

.PHONY: clean
clean:
rm -r node_modules dist src/lib/fallbacks || echo

webpack: dependencies
.PHONY: webpack
webpack: ../LICENSE dependencies
mkdir -p src/lib/fallbacks
for f in ../_data/*; do \
bf=$$(echo $$f | sed "s/.*\///"); \
Expand Down
2 changes: 1 addition & 1 deletion javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Olivia Appleton",
"license": "ISC",
"license": "GPLv3",
"dependencies": {
"chai": "^4.3.6",
"istanbul": "^0.4.5",
Expand Down
Loading

0 comments on commit aa03b1c

Please sign in to comment.