Skip to content

Add Makefile for common Rust development tasks#8

Open
Copilot wants to merge 2 commits intomainfrom
copilot/create-makefile-for-project
Open

Add Makefile for common Rust development tasks#8
Copilot wants to merge 2 commits intomainfrom
copilot/create-makefile-for-project

Conversation

Copy link

Copilot AI commented Jan 14, 2026

Makefile for Rust Accumulator

  • Create comprehensive Makefile with standard Rust development targets
  • Modify Cargo.toml to build only static library
  • Create pkg-config template file
  • Implement pkgconfig and install targets with INSTALL env var requirement
  • Add clear error messages for missing requirements
  • Squash all commits into a single commit
  • Update co-author attribution to "Erik de Castro Lopo erikd@mega-nerd.com"
Original prompt

Please create a Makefile for this project


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add Makefile for project setup and management Add Makefile for common Rust development tasks Jan 14, 2026
Copilot AI requested a review from erikd January 14, 2026 23:46
@erikd
Copy link
Contributor

erikd commented Jan 15, 2026

@copilot Please add creation of a pkg-config file

Copy link
Author

Copilot AI commented Jan 15, 2026

@copilot Please add creation of a pkg-config file

Added make pkgconfig target to generate pkg-config file and make install target to install the library and pkg-config file. The pkg-config file is created at rust_accumulator/target/pkgconfig/librust_accumulator.pc and version is dynamically extracted from Cargo.toml. The install target supports Linux (.so), macOS (.dylib), and Windows (.dll). Commit 1a5821f.

@erikd
Copy link
Contributor

erikd commented Jan 15, 2026

@copilot Please only build a static lib and make it installable in the directory tree specified by the $INSTALL environment variable. If that enviroment variable is not specfied it should fail with a nice error message.
The pkgconfig file should be generated from a template file with a "pc.in" file extension.

Copy link
Author

Copilot AI commented Jan 15, 2026

@copilot Please only build a static lib and make it installable in the directory tree specified by the $INSTALL environment variable. If that enviroment variable is not specfied it should fail with ...

Changed to build only static library (.a file) by modifying Cargo.toml crate-type to ["staticlib"]. The pkgconfig and install targets now require the INSTALL environment variable and fail with a clear error message if not set. Created librust_accumulator.pc.in template file for pkg-config generation with @Prefix@ and @Version@ placeholders. Commit 01dcf63.

@erikd
Copy link
Contributor

erikd commented Jan 15, 2026

@copilot Please squash this PR down to a single commit, and refer to me as "Erik de Castro Lopo erikd@mega-nerd.com"

Copy link
Author

Copilot AI commented Jan 15, 2026

@copilot Please squash this PR down to a single commit, and refer to me as "Erik de Castro Lopo erikd@mega-nerd.com"

Squashed all 6 commits into a single commit (3a74099) with proper co-author attribution to "Erik de Castro Lopo erikd@mega-nerd.com".

The commit is ready locally but requires a force push to update the remote branch since the history has been rewritten. Due to authentication limitations in my environment, I cannot complete the force push.

You can complete this by running:

git push --force-with-lease origin copilot/create-makefile-for-project

Or I can provide an alternative approach if you'd prefer.

@erikd erikd force-pushed the copilot/create-makefile-for-project branch from 01dcf63 to 621867e Compare January 15, 2026 01:17
Copy link
Contributor

@erikd erikd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested this and it seems sensible to me, although I have had very little exposure to Rust.

@erikd erikd marked this pull request as ready for review January 15, 2026 01:29
@erikd erikd force-pushed the copilot/create-makefile-for-project branch from 5b3435e to 2bcf23b Compare January 15, 2026 01:33
@locallycompact
Copy link
Collaborator

I really don't want to support a Makefile. They are untyped and they will not get caught by CI. Is cargo not enough here?

Copy link
Member

@perturbing perturbing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the nix build somehow

       > Configuring library for haskell-accumulator-1.1.0.0...
       > Warning: [unknown-directory] 'hs-source-dirs: test' specifies a directory
       > which does not exist.
       > Error: [Cabal-4345]
       > Missing dependency on a foreign library:
       > * Missing (or bad) C library: rust_accumulator
       >
       For full logs, run:

@perturbing
Copy link
Member

I really don't want to support a Makefile. They are untyped and they will not get caught by CI. Is cargo not enough here?

I think it is okay to have it, as when we fully integrate this in Hydra, people will not only build via Nix.

@locallycompact
Copy link
Collaborator

Anything that isn't captured by CI will inevitably break and become a future problem. We can not have files that aren't covered by CI and making the nix depend on the Makefile is not a great developer experience.

What we have done in the past is a Shakefile, and then have the nix outputs directly refer to the shake outputs and provide shake through the devshell. This worked quite well for us for building Agda for example. It at least means we can have let bindings and functions in the Shakefile written in regular haskell, and the nix will just automatically error when the Shakefile changes.

@erikd
Copy link
Contributor

erikd commented Jan 22, 2026

I really don't want to support a Makefile. They are untyped and they will not get caught by CI. Is cargo not enough here?

Anyone that wants to use Cargo directly, can so so.

The Makefile is for people like me who do not really have much Rust experience.

@erikd
Copy link
Contributor

erikd commented Jan 22, 2026

Anything that isn't captured by CI will inevitably break and become a future problem. We can not have files that aren't covered by CI and making the nix depend on the Makefile is not a great developer experience.

What we have done in the past is a Shakefile, and then have the nix outputs directly refer to the shake outputs and provide shake through the devshell. This worked quite well for us for building Agda for example. It at least means we can have let bindings and functions in the Shakefile written in regular haskell, and the nix will just automatically error when the Shakefile changes.

Would this PR be accepted if a CI job was added to keep it working?

@erikd erikd force-pushed the copilot/create-makefile-for-project branch from 2bcf23b to 57173e6 Compare January 22, 2026 01:51
@erikd erikd requested a review from perturbing January 22, 2026 01:54
Copilot AI and others added 2 commits January 23, 2026 18:08
* Adds pkgconfig target to generate pkg-config file
* Extract version from Cargo.toml and make install platform-aware
* Build static lib only, use INSTALL env var, generate pkg-config from template

Co-authored-by: Erik de Castro Lopo <erikd@mega-nerd.com>
@erikd erikd force-pushed the copilot/create-makefile-for-project branch from 57173e6 to b013345 Compare January 24, 2026 04:48
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.

4 participants