Commit 83d30c2f authored by Kenton Varda's avatar Kenton Varda

Improve makefiles to the point that make distcheck works.

parent ea54158d
../LICENSE
\ No newline at end of file
......@@ -4,15 +4,11 @@ ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = foreign
AM_CXXFLAGS = -I$(srcdir)/src
AM_CXXFLAGS = -I$(srcdir)/src -I$(builddir)/src
EXTRA_DIST = \
README.txt \
INSTALL.txt \
COPYING.txt \
CONTRIBUTORS.txt \
CHANGES.txt \
$(capnpc_inputs) \
LICENSE.txt \
$(test_capnpc_inputs)
CLEANFILES = $(capnpc_outputs) $(test_capnpc_outputs) capnpc_middleman test_capnpc_middleman
......@@ -46,31 +42,31 @@ maintainer-clean-local:
# unexpectedly overwritten! We need to cancel the implicit rule by declaring an explicit one.
#
# I want the hours of my life back that I spent figuring this out.
$(capnpc_inputs) $(test_capnpc_inputs):
:
%.capnp:
@:
capnpc_inputs = \
# Implicit rules for invoking capnpc.
%.capnp.h: %.capnp
$(CAPNPC) --src-prefix=$(srcdir) -oc++ $^
%.capnp.c++: %.capnp.h
@:
public_capnpc_inputs = \
src/capnp/c++.capnp \
src/capnp/schema.capnp
capnpc_inputs = $(public_capnpc_inputs)
capnpc_outputs = \
src/capnp/c++.capnp.c++ \
src/capnp/c++.capnp.h \
src/capnp/schema.capnp.c++ \
src/capnp/schema.capnp.h
capnpc_middleman: $(capnpc_inputs)
$(CAPNPC) -oc++ $(capnpc_inputs)
touch capnpc_middleman
$(capnpc_outputs): capnpc_middleman
includecapnpdir = $(includedir)/capnp
includekjdir = $(includedir)/kj
dist_includecapnp_DATA = \
src/capnp/c++.capnp \
src/capnp/schema.capnp
dist_includecapnp_DATA = $(public_capnpc_inputs)
includekj_HEADERS = \
src/kj/common.h \
......@@ -148,12 +144,6 @@ test_capnpc_outputs = \
src/capnp/test-import.capnp.c++ \
src/capnp/test-import.capnp.h
test_capnpc_middleman: $(test_capnpc_inputs)
$(CAPNPC) -oc++ $(test_capnpc_inputs)
touch test_capnpc_middleman
$(test_capnpc_outputs): test_capnpc_middleman
BUILT_SOURCES = $(test_capnpc_outputs) $(capnpc_outputs)
check_PROGRAMS = capnp-test
......
Cap'n Proto - Insanely Fast Data Serialization Format
Copyright 2013 Kenton Varda
http://kentonv.github.com/capnproto/
This package contains the C++ runtime implementation of Cap'n Proto.
Cap'n Proto is an insanely fast data interchange format and capability-based
RPC system. Think JSON, except binary. Or think of Google's Protocol Buffers
(http://protobuf.googlecode.com), except faster. In fact, in benchmarks,
Cap'n Proto is INFINITY TIMES faster than Protocol Buffers.
Full installation instructions and other documentation are maintained on the
Cap'n Proto web site:
http://kentonv.github.io/capnproto/install.html
......@@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "test-import.capnp.h"
#include <capnp/test-import.capnp.h>
#include "message.h"
#include <kj/debug.h>
#include <gtest/gtest.h>
......
......@@ -24,7 +24,7 @@
#ifndef CAPNP_SCHEMA_H_
#define CAPNP_SCHEMA_H_
#include "schema.capnp.h"
#include <capnp/schema.capnp.h>
namespace capnp {
......
......@@ -22,7 +22,6 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "serialize-packed.h"
#include "test.capnp.h"
#include <kj/debug.h>
#include <gtest/gtest.h>
#include <string>
......
......@@ -23,7 +23,6 @@
#include "serialize.h"
#include <kj/debug.h>
#include "test.capnp.h"
#include <gtest/gtest.h>
#include <string>
#include <stdlib.h>
......
......@@ -24,7 +24,7 @@
#ifndef CAPNP_TEST_UTIL_H_
#define CAPNP_TEST_UTIL_H_
#include "test.capnp.h"
#include <capnp/test.capnp.h>
#include <iostream>
#include "blob.h"
#include "dynamic.h"
......
......@@ -47,7 +47,7 @@ import qualified Data.Map as Map
import qualified Data.ByteString.Lazy.Char8 as LZ
import Data.ByteString(unpack, pack, hPut)
import Data.Word(Word64, Word8)
import Data.Maybe(fromMaybe, catMaybes)
import Data.Maybe(fromMaybe, catMaybes, mapMaybe)
import Data.Function(on)
import Semantics
import WireFormat(encodeSchema)
......@@ -61,6 +61,7 @@ generatorFns = Map.fromList [ ("c++", generateCxx) ]
data Opt = SearchPathOpt FilePath
| OutputOpt String GeneratorFn FilePath
| SrcPrefixOpt String
| VerboseOpt
| HelpOpt
| GenIdOpt
......@@ -70,11 +71,16 @@ main = do
let optionDescs =
[ Option "I" ["import-path"] (ReqArg SearchPathOpt "DIR")
"Search DIR for absolute imports."
, Option "" ["src-prefix"] (ReqArg SrcPrefixOpt "PREFIX")
"Prefix directory to strip off of source\n\
\file names before generating output file\n\
\names."
, Option "o" ["output"] (ReqArg parseOutputArg "LANG[:DIR]")
("Generate output for language LANG\n\
\to directory DIR (default: current\n\
\directory). LANG may be any of:\n\
\ " ++ unwords (Map.keys generatorFns))
\ " ++ unwords (Map.keys generatorFns) ++ "\n\
\or a plugin name.")
, Option "v" ["verbose"] (NoArg VerboseOpt) "Write information about parsed files."
, Option "i" ["generate-id"] (NoArg GenIdOpt) "Generate a new unique ID."
, Option "h" ["help"] (NoArg HelpOpt) "Print usage info and exit."
......@@ -114,6 +120,11 @@ main = do
-- these hard-coded default paths.
let searchPath = ["/usr/local/include", "/usr/include"] ++
[dir | SearchPathOpt dir <- options]
srcPrefixes = [addTrailingSlash prefix | SrcPrefixOpt prefix <- options]
addTrailingSlash path =
if not (null path) && last path /= '/'
then path ++ "/"
else path
let verifyDirectoryExists dir = do
exists <- doesDirectoryExist dir
......@@ -143,7 +154,7 @@ main = do
\be easy enough to grep, right?"
exitFailure)
mapM_ (doOutput requestedFiles schema schemaMap) outputs
mapM_ (doOutput requestedFiles srcPrefixes schema schemaMap) outputs
when failed exitFailure
......@@ -293,9 +304,12 @@ handleFile isVerbose searchPath filename = do
Right _ -> return Nothing
Left desc -> return $ Just desc
doOutput requestedFiles schema schemaMap output = do
doOutput requestedFiles srcPrefixes schema schemaMap output = do
let write dir (name, content) = do
let outFilename = dir ++ "/" ++ name
let strippedOptions = mapMaybe (flip List.stripPrefix name) srcPrefixes
stripped = if null strippedOptions then name else
List.minimumBy (compare `on` length) strippedOptions
outFilename = dir ++ "/" ++ stripped
createDirectoryIfMissing True $ takeDirectory outFilename
LZ.writeFile outFilename content
generate (generatorFn, dir) = do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment