-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
83 lines (69 loc) · 2.07 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright 2012 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
DART_VERSION := $(shell dart --version 2>&1)
MACOS_ARCH :=
LINUX_ARCH :=
ifneq ($(findstring 32,$(lastword $(DART_VERSION))),)
MACOS_ARCH = i386
LINUX_ARCH = 32
else ifneq ($(findstring 64,$(lastword $(DART_VERSION))),)
MACOS_ARCH = x86_64
LINUX_ARCH = 64
else
$(error Unsupported architecture in $(DART_VERSION))
endif
PLATFORM := $(shell uname -s)
G++_OPTIONS :=
GCC_OPTIONS :=
ifeq ($(PLATFORM),Darwin)
G++_OPTIONS = -arch $(MACOS_ARCH)
GCC_OPTIONS = -Wl,-install_name,libdart_sqlite.dylib,-undefined,dynamic_lookup -o lib/src/libdart_sqlite.dylib
else ifeq ($(PLATFORM),Linux)
G++_OPTIONS = -m$(LINUX_ARCH)
GCC_OPTIONS = -Wl,-soname,libdart_sqlite.so -o lib/src/libdart_sqlite.so
else
$(error Unsupported platform $(PLATFORM))
endif
DART_FILES := \
example/*.dart \
lib/*.dart \
lib/src/*.dart \
test/*.dart \
tool/*.dart
.PHONY: *
all: build
check-dart-sdk:
ifndef DART_SDK
$(error The DART_SDK environment variable must be set!)
endif
build: check-dart-sdk
mkdir -p out
g++ -fPIC -I $(DART_SDK)/include -c lib/src/dart_sqlite.cc $(G++_OPTIONS) -o out/dart_sqlite.o
gcc -shared $(GCC_OPTIONS) out/dart_sqlite.o -lsqlite3
test: check-dart-sdk build
$(DART_SDK)/bin/pub run test
example: check-dart-sdk build
$(DART_SDK)/bin/dart example/statements.dart
analyze: check-dart-sdk
$(DART_SDK)/bin/dartanalyzer --fatal-lints --fatal-hints --fatal-warnings $(DART_FILES)
docs:
ifeq ($(shell which dartdoc),)
$(error Dartdoc needs to be installed first!)
endif
dartdoc
format: check-dart-sdk
$(DART_SDK)/bin/dartfmt -w $(DART_FILES)
dart_files:
@echo $(DART_FILES)
clean:
rm -rf out
find . -name *.so -o -name *.dylib | xargs rm
help:
@echo "Targets:"
@echo " build Build the library"
@echo " test Run the unit tests"
@echo " example Run the examples"
@echo " analyze Run the Dart analyzer"
@echo " docs Generate the documentation"
@echo " format Format all Dart files"