{"id":15537,"library":"bare-make","title":"bare-make","description":"bare-make is an opinionated build system generator designed to simplify the CMake workflow by enforcing a consistent build environment. It leverages CMake to generate build files specifically for Ninja, utilizing Clang as the compiler toolchain across all supported operating systems. This approach ensures highly reliable and reproducible compilation processes by standardizing the build system and compiler. While it imposes these specific tools, it remains fully compatible with standard CMake, allowing developers to easily \"eject\" to a plain CMake flow if needed. The current stable version is 1.7.2, and it appears to follow an active release cadence tied to its parent organization's projects. Its primary differentiators include its programmatic JavaScript API for build automation and its strong focus on build consistency through fixed toolchains, making it ideal for projects requiring strict build guarantees.","status":"active","version":"1.7.2","language":"javascript","source_language":"en","source_url":"https://github.com/holepunchto/bare-make","tags":["javascript","typescript"],"install":[{"cmd":"npm install bare-make","lang":"bash","label":"npm"},{"cmd":"yarn add bare-make","lang":"bash","label":"yarn"},{"cmd":"pnpm add bare-make","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for internal process management and stdio redirection.","package":"bare-pipe","optional":false}],"imports":[{"note":"The primary API is exposed as a default export object containing all build functions. Avoid named imports for functions like `generate` or `build` directly from the package root.","wrong":"import { generate, build } from 'bare-make';","symbol":"make","correct":"import make from 'bare-make';"},{"note":"CommonJS import for Node.js environments, as shown in the package README. This is fully supported.","symbol":"make (CJS)","correct":"const make = require('bare-make');"},{"note":"Import types explicitly for use in TypeScript projects to ensure correct type checking without bundling issues. Using `import` without `type` for interfaces can lead to runtime errors or unnecessary code in some environments.","wrong":"import { GenerateOptions } from 'bare-make';","symbol":"GenerateOptions","correct":"import type { GenerateOptions } from 'bare-make';"}],"quickstart":{"code":"import make from 'bare-make';\nimport path from 'path';\nimport os from 'os';\n\nasync function runBuildProcess() {\n  // Define your project's root, build directory, and install prefix\n  const projectRoot = process.cwd(); // Or specify a different path\n  const buildDir = path.join(projectRoot, 'build-bare-make');\n  const installPrefix = path.join(projectRoot, 'dist-prebuilds');\n\n  console.log(`Starting bare-make build process in: ${projectRoot}`);\n\n  try {\n    console.log('\\n--- Generating build system ---');\n    // Generate build files for Ninja using Clang, enabling debug symbols\n    await make.generate({\n      source: projectRoot,\n      build: buildDir,\n      platform: os.platform(),\n      arch: os.arch(),\n      debug: true, // Configure a debug build\n      verbose: true, // Enable verbose output for generation\n      stdio: 'inherit' // Stream output directly to console\n    });\n    console.log(`Build system successfully generated in: ${buildDir}`);\n\n    console.log('\\n--- Building project ---');\n    // Build all targets in parallel\n    await make.build({\n      build: buildDir,\n      target: 'all', // Build all targets defined in CMakeLists.txt\n      parallel: os.cpus().length, // Use all available CPU cores\n      verbose: true,\n      stdio: 'inherit'\n    });\n    console.log('Project built successfully.');\n\n    console.log('\\n--- Installing artifacts ---');\n    // Install built artifacts to a specified prefix\n    await make.install({\n      build: buildDir,\n      prefix: installPrefix,\n      verbose: true,\n      stdio: 'inherit'\n    });\n    console.log(`Artifacts installed to: ${installPrefix}`);\n\n    console.log('\\n--- Running tests (if enabled) ---');\n    // Run CTest tests if enabled in CMakeLists.txt\n    await make.test({\n      build: buildDir,\n      timeout: 60, // Max 60 seconds per test\n      parallel: os.cpus().length,\n      verbose: true,\n      stdio: 'inherit'\n    });\n    console.log('Tests completed.');\n\n  } catch (error) {\n    console.error('\\nBuild process failed:', error.message);\n    process.exit(1);\n  }\n}\n\nrunBuildProcess();","lang":"typescript","description":"Demonstrates the full programmatic workflow of generating, building, installing, and testing a CMake project using bare-make's API, including verbose output and parallel execution."},"warnings":[{"fix":"Ensure your project's CMake configuration is compatible with Clang and Ninja. If specific toolchains are non-negotiable, consider using CMake directly without `bare-make` or using its 'eject' capability.","message":"bare-make explicitly enforces the use of Ninja as the build system generator and Clang as the compiler toolchain. Projects expecting to use other compilers (e.g., GCC, MSVC) or alternative build systems (e.g., Makefiles, Visual Studio) will need to adapt their `CMakeLists.txt` or use plain CMake directly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Before using `bare-make`, ensure that CMake (version 3.15+ recommended), Ninja, and Clang are correctly installed on your development and CI/CD systems and are accessible via the system's PATH environment variable.","message":"bare-make relies on CMake, Ninja, and Clang being pre-installed and discoverable in the system's PATH. It does not bundle or automatically install these fundamental underlying tools itself.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure 'bare-pipe' is installed alongside 'bare-make' in your project. Check for any version compatibility requirements if encountering process-related issues, especially those related to standard I/O redirection or child process management.","message":"The package lists 'bare-pipe' as a peer dependency (`\"bare-pipe\": \"*\"`). While not a direct runtime dependency that `npm install` would automatically fetch, it is crucial for `bare-make`'s internal process management and might require explicit installation by the user (`npm install bare-pipe`).","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"First, verify that CMake, Ninja, and Clang are installed and added to your system's PATH. If they are, enable verbose output (`verbose: true` in options, `stdio: 'inherit'`) to see the exact command output and diagnose `CMakeLists.txt` errors.","cause":"Underlying build tools (CMake, Ninja, or Clang) are either not found in the system's PATH, or there's a fundamental configuration error within your CMake project's `CMakeLists.txt`.","error":"Error: Command failed with exit code 1: cmake ... (or ninja ... or clang ...)"},{"fix":"Adjust the `source` option to correctly point to the root directory of your CMake project where the primary `CMakeLists.txt` file is located. This is typically the directory containing your project's top-level build definition.","cause":"The `source` option provided to `make.generate()` or via the CLI points to a directory that does not contain a `CMakeLists.txt` file, which is the required entry point for a valid CMake project.","error":"Error: Source directory '...' does not contain a CMakeLists.txt file."},{"fix":"Review your `CMakeLists.txt` files to identify the correct target names. Use `cmake --build <build-dir> --target help` from the command line to list available targets if you are unsure.","cause":"The specified `target` in `make.build()` (or via the `--target` CLI flag) does not exist in your CMake project. Common targets include 'all', 'install', or names of executables/libraries you define.","error":"Error: Target '...' not found"}],"ecosystem":"npm"}