Skip to content

Allow custom C++/Java compiler executable (#21) - #24

Open
HamzaHassanain wants to merge 1 commit into
masterfrom
feat/custom-compiler
Open

HamzaHassanain wants to merge 1 commit into
masterfrom
feat/custom-compiler

Conversation

@HamzaHassanain

Copy link
Copy Markdown
Owner

Summary

Closes #21.

The C++ compiler executable was hardcoded to g++ in compileCPP. It is now resolved in this order:

  1. POLYMAN_CXX environment variable
  2. compiler.cpp in Config.json
  3. g++

The same applies to Java: POLYMAN_JAVAC, then compiler.javac, then javac.

An optional compiler.flags array appends extra flags to every C++ compile, so g++-15 with -std=c++23 works without touching the system default compiler.

{
  "compiler": {
    "cpp": "g++-15",
    "flags": ["-O2", "-std=c++23"]
  }
}
POLYMAN_CXX=clang++ polyman verify

The block is local only and never sent to Polygon (Polygon uses sourceType). Executables are shell-quoted so absolute paths with spaces work.

Changes

  • src/helpers/utils.ts: resolveCppCompiler, resolveCppFlags, resolveJavaCompiler; compileCPP/compileJava use them.
  • src/types.d.ts: new CompilerConfig type and optional compiler field on ConfigFile.
  • Docs: template/instructions/config.md, GUIDE.md, README.md.
  • Tests: tests/helpers/utils.test.ts covers default, config, env precedence, blank/malformed values, flags passthrough, and quoting.

Verification

  • npm run build, npm run lint, npm run format:check, npm test (779 tests) all pass.
  • Smoke-tested POLYMAN_CXX pointing at a wrapper script against dist/; the wrapper was invoked and the binary ran.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GpqwzMj4fWWDcyfAT6WWq9

The C++ compiler was hardcoded to g++. Resolve it from POLYMAN_CXX, then
an optional `compiler.cpp` field in Config.json, then g++. Same for
javac via POLYMAN_JAVAC / `compiler.javac`. `compiler.flags` appends
extra flags to every C++ compile. Executables are shell-quoted so paths
with spaces work.

Closes #21

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GpqwzMj4fWWDcyfAT6WWq9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow custom compiler executable

1 participant