Skip to content

Instantly share code, notes, and snippets.

int add(int x, int y);
for each header file:
  hash the file
  generate an include guard from the hash
  wrap the contents 
  output into a new header file
#pragma once
struct foo {
  int member;
};
struct foo {
int member;
};
#ifndef HEADER_HAS_BEEN_INCLUDED
#define HEADER_HAS_BEEN_INCLUDED
struct foo {
int member;
};
#endif
#ifndef HEADER_HAS_BEEN_INCLUDED
#define HEADER_HAS_BEEN_INCLUDED
#include "foo.hpp"
#include "foo.hpp"
#ifndef HEADER_HAS_BEEN_INCLUDED
#define HEADER_HAS_BEEN_INCLUDED
struct foo {
  int member;
};
#endif
$ buck build :mathutils
$ ls ./buck-out/gen/mathutils#header-mode-symlink-tree-with-header-map\,headers/mathutils/
add.hpp mathutils.hpp sub.hpp
cxx_library(
name = 'mathutils',
header_namespace = 'mathutils',
exported_headers = merge_dicts(subdir_glob([
('mathutils/include', '**/*.hpp'),
]), {
'mathutils.hpp': ':single-header',
}),
srcs = glob([
'mathutils/src/**/*.cpp',
def merge_dicts(x, y):
 z = x.copy()
  z.update(y)
  return z