Comments (1)
Ok, so there's two separate things here I'd like to talk about:
The first is that the core idea is not that you should write makefiles, etc. with YCM-Gen in mind - it's that you should just write good, portable makefiles and YCM-Gen will just work. Actually, all portable means for us is that you haven't hardcoded the path to the compiler. That is, you should be using $(CC)
and $(CXX)
instead of the name of the compiler.
The second is that the large projects aren't there as examples of how a build system should be written. They're there to demonstrate that YCM-Gen works with 'real' projects, with all their painful complexity and ugly hacks.
That being said, it probably is worthwhile to include an example, so here's the Makefile from a simple C program I wrote a little while ago as reference, which I consider to be fairly concise:
CFLAGS=-g -std=gnu99 -Wall -Wno-parentheses
all: main.o base_station.o sensor_node.o
$(CC) $(CFLAGS) $^ -o simulate_wsn
clean:
rm -rf *.o simulate_wsn
main.c
, base_station.c
, etc. are the source files. (Header files do not need to be included.) Because their respective object files are dependencies of all
, make will generate implicit targets for them of the form:
$(CC) $(CFLAGS) foo.c -o foo.o
We then have a single explicitly defined rule for the all
target, which links those object files together to generate the binary. ($^
contains all the dependencies of the current target. i.e. the object file names). The clean target is needed as YCM-Gen uses it to erase any state left behind, but you'll normally want to include that anyway out of convenience.
It's worth noting that you can ignore pretty much all of what I said, because only two things really matter:
- there should be
all
andclean
targets - all invocations of the C compiler use
$(CC)
instead ofgcc
, etc. (Use$(CXX)
for C++.)
Now, if for some reason you need to use a specific / non-default compiler for a given project, you can define the CC
variable (in a similar fashion to the CFLAGS
variable), but you will then need to pass --make-flags=-e
to YCM-Gen so that it will be overridden.
Let me know if I've left anything out. :)
from ycm-generator.
Related Issues (20)
- unwanted flag "c++" in the flags HOT 1
- Possible to support alternative compiler for cross compiler such as ARM, POWERPC ? HOT 1
- Stucked on Linux kernel of version 4.9-rc8
- 'CC=gcc-7' inside Makefile does not work , while 'CC=gcc' does. (ERROR: no commands ... ) HOT 1
- meson/ninja generator creates incorrect include paths HOT 1
- How to set external library dir
- ERROR: No commands were logged to the build logs HOT 1
- test for generating configuration file for linux kernel is slow HOT 1
- ERROR: Unknown build system HOT 4
- Compatible with Conan HOT 2
- E464: Ambiguous use of user-defined command: Plug 'rdnetto/YCM-Generator' , { 'branch': 'stable'} HOT 1
- Package not found via config_gen HOT 4
- ld in fake-toolchain must work properly HOT 2
- ESP32 IDF and YCM-Generator not working well together HOT 5
- Does YCM-Generator support transform compile_commands.json to .color_coded
- Does this plugin support python 3?
- The template file for .ycm_extra_conf.py should be changed for clangd changed
- .vimrc imap <C-n> <Down>, when type "return 0;", then "<C-n> cant use anymore HOT 1
- Missing verb in README.md
- Doesn't seem to work with Kbuild (Linux Kernel build system)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ycm-generator.