Hot answers tagged

136

Normally you wouldn't just have a dedicated build machine, but also run a build server on that dedicated machine. A dedicated build machine merely offers the advantage of never blocking the work of a developer and deploying from a centralized machine. A build server offers much more. A build sever allows for CI (continuous integration), meaning that it ...


112

Automation. When you are developing, only in the most simple projects will the default "build" button do everything you need it to do; you may need to create WS out of APIs, generate docs, link with external resources, deploy the changes to a server, etc. Some IDEs allow you to customize the build process by adding extra steps or builders, but that only ...


107

In addition to Traubenfuchs' answer, you have hinted at another reason for a build machine in your question. Just because the software builds on your machine, it doesn't mean that it will build on anyone else's. You may be relying on some random files that just happen to be on your machine (and may not even be under version control). You may be relying on ...


95

I think you are approaching this problem from the wrong angle. Better let the generator place a clear and visible comment at the beginning of the C header file like // This file is autogenerated, don't change it manually, // any manual changes will get lost after next regeneration. then make generating the C file from the CSV file part of the build ...


70

There are a lot of technical reasons behind using multiple files when writing large complex systems. All of them are meaningless in the face of the best reason to use multiple files: Readability. When I write code that resides in one file I'm presenting what you need to understand to follow how this part of the system works. Every detail not in this file ...


54

To start with, this comment: ... having a branch implies an extra complexity and thus extra work ... is wholly false. I often hear it from people who aren't accustomed to branching, but it's still wrong. If you have many developers accumulating changes locally, their local changes constitute a de-facto branch of the main repository. When they finally ...


53

The main reason for having a dedicated build machine is to get consistent builds regardless of who is doing the build. Developer workstations are rarely (read: never) identical. It's hard to know that each build is using the same exact versions of dependencies and compilers etc. One of the worst problems with dev workstation builds is that developers can ...


49

Your build number won't be reset to 0, when minor and major versions increase, this violates sections 7 and 8 of the specs: Minor version Y (x.Y.z | x > 0) MUST be incremented if new, backwards compatible functionality is introduced to the public API. It MUST be incremented if any public API functionality is marked as deprecated. It MAY be incremented if ...


47

This has come up on a few projects for me. The best solution I've had so far is to generate a version number like this: x.y.<number of commits>.r<git-hash> Typically, it's generated by our build system using a combination of some static file or tag to get the major revision numbers, git rev-list HEAD | wc -l (which was faster than using git ...


41

Don't commit the generated C header file at all. In fact, delete the current file (thanks @user1936), change the script to call the header file .g.h (thanks @davidbak), and add it to .gitignore, so it doesn't get committed accidentally (thanks @cmaster). Instead, commit the csv and python script, and add some custom step to generate the C header file at ...


34

Like code, a build script is executed by the computer. Computers are exceptionally good at following a set of instructions. In fact, (outside of self-modifying code), computers will execute the same sequence of instructions exactly the same way, given the same input. This delivers a level of consistency that, well, only a computer can match. By contrast, ...


33

Actually some people (of noticeable boost fame) are working hard to create and establish such a system called Ryppl. It is hard to establish such a System for C++, because it has no single player which can dictate it. --UPDATE: Unfortunately it is abandonned. On your second question, a normal package manager (besides not being cross platform) does not ...


33

The big difference is that CMake is a cross-platform meta-build system. A single CMake project can produce the usual Unix/Linux makefile, a Visual Studio project for Windows, an XCode project for Mac, and almost any other non-meta build system you might want to use or support. I wouldn't say using make directly or even manually editing makefiles is "...


27

The question falls into same category as why buildings are not build from one piece of rock but a bunch of bricks? Answer: easier to navigate than scroll through one huge file make recompile works only on files related to the change various parts of the program can be programmed by different people code from some files can be put into libraries for ...


23

The whole confusion stems from the different semantics that MS uses for "Build number" and especially "Revision". The terms just mean different things. Most people (myself included) use a semantic version numbering scheme where you just get a higher BUILD number whenever you have to make a new build for whatever reason. For us, a hotfix is considered just ...


21

Java is an imperative language, Ant, Maven, etc. are declarative languages: We could define the difference as follows: Imperative programming: telling the "machine" how to do something, and as a result what you want to happen will happen. Declarative programming: telling the "machine" what you would like to happen, and let the computer ...


21

Specific Tool for a Specific Purpose Verbosity General purpose languages are often too verbose. If I had to manage a build in Java, I'd be very depressed very quickly by the size of the beast. However, it could easily be manageable using a DSL written in Java. And to some extent that's how you can see Gradle (for Groovy) and Buildr (for Ruby). Difficulty ...


21

The other answers are fine, but something they're missing is actual technical limitations. For example, you can't actually save all of the code for my day-job application in one file - it's bigger than the file size limitations of common file systems. That sort of size also wreaks havoc with editors and compilers and linters since the syntax tree for that ...


19

The other answers quite correctly noted that you should automate the build, which means it isn't necessary to walk to another office. However, let me propose a certain number of steps you could take to improve your build process: Firstly, set up remote access to the build server! If you build manually by typing the command "make", this means you don't have ...


19

Couple of pointers. You should never expose stacktrace to users. Thats a security risk. You should also never expose exception messages to users, only for custom exceptions that you know can not contain sensitive information is ok to expose. You should never build your release candidate on a developer machine. You should use a build agent for this. The ...


17

I think that a problem with C and even more with C++ is that they are more heterogeneous languages: even though these languages are standardized there exist different compilers with different options or different sets of supported features. E.g., I remember posting a question about C++ on stack overflow with an example that was working perfectly on GCC / ...


17

Microsoft describes the purpose of each component of a .NET version number in their MSDN documentation for the Version class. Here is the relevant portion: major.minor[.build[.revision]] The components are used by convention as follows: Major: Assemblies with the same name but different major versions are not interchangeable. A higher version ...


17

First a disclaimer: I don't think this is a good idea. But here is one way to do it anyway: void check_file_time() { if (strcmp(__TIMESTAMP__, "Sun Feb 16 19:38:35 2020") != 0) { asm("do_not_modify_this_file\n"); } } This relies on a few GCC-specific tricks: Non-standard preprocessor macro __TIMESTAMP__ expands to the modification ...


16

... instead of getting an actual machine in our office to use, we're having to share a single machine with several other groups ... You say that like it's a bad thing. You now have a common build server that all of your builds - yours and the other teams' - are built through. Consistency of build? Check. ... the hassle of having to leave my office ...


15

We use git describe with version tags. The flow is basically: create tag for the version we're working on (e.g. v1.1.2) every build run git describe when we ship, use the tag name git describe provides the tag name, number of commits since the tag, and the hash of the tag. A sample tag looks like: v1.1.2-6-a3b27gae This has the benefit that developers ...


15

If all you ever want to do is <compiler> **/*.<extension>, build scripts serve little purpose (though one can argue that if you see a Makefile in the project you know you can build it with make). The thing is - non-trivial projects usually require more than that - at the very least, you'll usually need to add libraries and (as the project matures)...


14

These things are orthogonal: The build script is the mechanism that, upon invocation on freshly checked-out source tree, yields a complete build of required targets and dependencies. It could simply be 'make all' if you've got a makefile, or a suitable invocation of MSBuild, Ant, Maven or Scons. If you have a complex hierarchy of dependencies or related ...


14

developers... accumulate their changes locally... You can see the vicious cycle. It's vicious indeed. Accumulating changes locally is a big red flag indicating that something is severely rotten in dev process. It sort of trashes the whole purpose of having a version control system. As long as you want to stay away from changing the process or other people ...


13

If your program consists of a only a few files that can be built with a simple command line invoking the compiler, then make may be superfluous. However, in large projects you may have dozens of files that require complex compiler and linker options, then make or a similar tool becomes a necessity. Consider, if you have a project with 50 C++ source files, ...


Only top voted, non community-wiki answers of a minimum length are eligible