Do I need Setup.hs file when creating Haskell projects? - cabal

I use stack new <name>, then hpack-convert and add dependencies into package.yaml in order to skip ceremony and start writing Haskell code.
Why is there's always a Setup.hs file? I don't use custom setups as far as I know. Will I need to include this file at some point?

I think it's just an old haskell convention that "Setup.hs" can be used to build the package, even for simple build types. Pretty sure it can be removed without having issues.

Related

Dependency Management in C with CMake

I have recently tried to make a few basic projects in C (using CMake), but one aspect I find very difficult is getting all the different things that I've been making to link together nicely. For example, I started off by making a data-structure library that has some of the basic data structures, along with functions to traverse them, etc., and a testing library that handles unit testing. In most new projects I make, I find that I need to include these two libraries, but I can't find an easy way to do it. I tried doing this using git submodule, and while that did work for the most part, whenever I updated any of the dependencies, updating the dependant seemed to be a nightmare. I've also had a look into the cmake package system; find_package, and related functions; but I can't seem to get that to work (at least when I want to install it in a custom directory, that is).
I was wondering if there is some sort of "standard" way that C programmers go about dealing with this, and what that may be. Is submodules the way to go? If so, is there a way I could do it cleanly, making sure that everything is always the right version?
Thanks in advance.

Synchronize single c header file between two projects

I have a radio chip (connected to an embedded processor) which I have written a library for. I want to develop the protocol to use with the rf chip on a PC (Ubuntu). In order to do so I have copied the header file of my library into a new folder, but created an entirely new implementation in a new c file and compile for the PC with gcc. This approach has worked better than expected and I'm able to prototype code that calls the rf lib on the PC and simply copy it right over to the real project with little or no changes.
I do have one small problem. Any changes I make in the the library's header file need to be manually copied between the two project folders. Not a big deal, but since this has worked so well, I can see doing things like this again in the future, and would like to link the API headers between the real and "emulated" environments when doing so. I have thought about using git submodules to do so, but I'm not fond of lots of folders in my projects especially if most of them only contain one or two files each. I could use the c preprocessor to swap in the right code at compile time, but that doesn't cover the changes in my Makefile to call the right compiler with the right fags.
I'm wondering if anyone else has ever done something similar, and what their approach was?
Thanks guys!
maybe you should create a "rflib" and treat it as an external library that you use within your embedded project.
develop on one side and update to the newest version on the other.
An obvious (but fairly hacky) solution is to use a symlink.
I think the best solution, since they will share so much code, would be to just merge the two projects and have two different makefile targets for the binaries.

how to modify the firebreath plugin's version number(such as 1.0.0.0->1.0.0.1)

if modify the following line
set(FBSTRING_PLUGIN_VERSION "1.0.0.0")
in file
firebreath\projects\{ProjectDir}\PluginConfig.cmake
then run "prepxxx.cmd" or rebuild the solution directly, it could modify the version correctly, but if "PluginConfig.cmake" be modified, the solution and project files will be recreated too, all of the configuration for the solution and the projects will be discarded. if this is a complicated solution, and you have to reconfig for all of these every time, it will make people maddening!
is there better way to do this?
I believe you asked this question on the firebreath-dev list; I hope you weren't expecting a different answer here, because I wrote FireBreath and I can pretty much guarantee that any other answer will be an ugly, ugly hack.
FireBreath uses CMake, and CMake is designed so that you regenerate your project and solution files on the fly. There is very very little that you can customize on the solution or project that you can't set up correctly with cmake. The correct fix for this is to figure out how to do the things you are currently doing by hand with your solutions and do them in the CMakeLists.txt and Win/projectDef.cmake files.
If you still refuse to accept this answer, the only other way would be to find all the places where FireBreath applies those properties and change them by hand in the build directories. A quick grep shows me that it is used to customize these files:
gen_templates/config.h
gen_templates/firebreathWin.rc
Mac/bundle_template/Info.plist
Several places in the WiX template
In the Chrome package manifest
And of course you'll need to do a bit more looking because it also gets split up and used as FB_VERSION_MAJOR, FB_VERSION_MINOR, FB_VERSION_PATCH, and FB_VERSION_BUILD
Any of these variables may be used in multiple places.
Of course, also note that if you ever update your firebreath codebase you're likely to end up triggering cmake again if there were any changes to the firebreath cmake files. As long as you don't care about ever getting bugfixes, security improvements, or about building on other machines, I suppose you could take this approach.
If I were you, I'd really think about just fixing your cmake files so you don't have to change the project by hand... every case I know of that someone has tried to ignore that advice has ended badly.

How to include multiple packages with one statement in Ada?

I wrote a library in Ada and I would like for the client to only need to include one package into their code. Something like:
with all_packages;
That will include all the packages useful for the client. I wrote the library with one package for each tagged type to keep things simple and easy to read.
How do I give the library user the possibility to include all packages with only one statement?
You can't.
You did well by encapsulating each tagged type in its own package, that's the approach recommended for object-oriented programming in Ada.
Client code then simply 'withs' just those packages it needs.

How do I merge/compare files ignoring order?

I have two properties files that are not the same and I need to find the differences. The second file is sorted by key.
Is there a tool that can help me with it? From what I've seen every merge tool cares very much about the order.
I've done it in bash on Linux by sorting both files and then merge them. If you are on Windows you could install Cygwin for running Linux programs.
However, I think you are best served by creating a small program to do it, probably takes you less time than learning to use Cygwin.
Edit: You could look at it as a small project to learn a new technology. I often use projects like these to learn things like Ruby or Python. Although it may not be accepted if it is at work.
Sort one or both files.
Then run "diff".

Resources