-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial WORKSPACE and BUILD file that generates parse source
This is adapting from a BUILD file I had that lived along side sqlite3 source, hence swaths of commented out targets. The use of SRC_PREFIX throughout to deal with the source archive's root dir will be unnecessary after a `root_directory` attributed is added to the `new_http_archive` repository rule. See bazelbuild/bazel#221
- Loading branch information
1 parent
4c08b74
commit 9ca906b
Showing
2 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
SRC_PREFIX = "sqlite-src-3081101" | ||
|
||
cc_binary( | ||
name = "lemon", | ||
srcs = ["%s/tool/lemon.c" % SRC_PREFIX], | ||
) | ||
|
||
COMPILER_OPTS = [ | ||
"-DNDEBUG=1", | ||
"-DHAVE_FDATASYNC=1", | ||
] | ||
|
||
genrule( | ||
name = "generate_parse_source", | ||
tools = [":lemon"], | ||
outs = ["%s/src/parse.c" % SRC_PREFIX, "%s/src/parse.h" % SRC_PREFIX], | ||
srcs = [ | ||
"%s/src/parse.y" % SRC_PREFIX, | ||
"%s/src/lempar.c" % SRC_PREFIX, | ||
"%s/addopcodes.awk" % SRC_PREFIX, | ||
], | ||
cmd = ("TMPDIR=$$(mktemp -d) && mkdir -p $(@D)/%s/src &&" % (SRC_PREFIX,) + | ||
"cp $(location :lemon) $(location :%s/src/lempar.c) " % (SRC_PREFIX,) + | ||
"$(location :%s/src/parse.y) $$TMPDIR/ &&" % (SRC_PREFIX,) + | ||
"(cd $$TMPDIR && ./lemon parse.y) && " + | ||
"cp $$TMPDIR/parse.c $(location :%s/src/parse.c) &&" % (SRC_PREFIX,) + | ||
"awk -f $(location :%s/addopcodes.awk) $$TMPDIR/parse.h " % (SRC_PREFIX,) + | ||
"> $(location :%s/src/parse.h) &&" % (SRC_PREFIX,) + | ||
"rm -rf $$TMPDIR" | ||
) | ||
) | ||
|
||
#genrule( | ||
# name = "generate_sqlite3.h", | ||
# srcs = [ | ||
# "src/sqlite.h.in", | ||
# "manifest.uuid", | ||
# "VERSION", | ||
# "ext/rtree/sqlite3rtree.h", | ||
# "tool/mksqlite3h.tcl" | ||
# ], | ||
# outs = ["src/sqlite3.h"], | ||
# cmd = "tclsh $(location tool/mksqlite3h.tcl) . > $(GENDIR)/src/sqlite3.h", | ||
#) | ||
|
||
cc_binary( | ||
name = "mkkeywordhash", | ||
srcs = ["tool/mkkeywordhash.c"] | ||
) | ||
|
||
#genrule( | ||
# name = "generate_keywordhash.h", | ||
# tools = [":mkkeywordhash"], | ||
# outs = ["src/keywordhash.h"], | ||
# cmd = "$(location :mkkeywordhash) > $(GENDIR)/src/keywordhash.h", | ||
#) | ||
|
||
#genrule( | ||
# name = "generate_opcodes_source", | ||
# outs = [ | ||
# "src/opcodes.c", | ||
# "src/opcodes.h", | ||
# ], | ||
# srcs = [ | ||
# "src/parse.h", | ||
# "src/vdbe.c", | ||
# "mkopcodeh.awk", | ||
# "mkopcodec.awk", | ||
# ], | ||
# cmd = "cat $(location src/parse.h) $(location src/vdbe.c) |" + | ||
# " awk -f $(location mkopcodeh.awk) > $(location src/opcodes.h) &&" + | ||
# " awk -f $(location mkopcodec.awk) $(location src/opcodes.h) >" + | ||
# " $(location src/opcodes.c)", | ||
#) | ||
# | ||
#cc_library( | ||
# name = "sqlite3", | ||
# hdrs = ["src/sqlite3.h"], | ||
# srcs = glob( | ||
# ["**/*.c", "**/*.h"], | ||
# #["src/*.h", "src/*.c, ext/**/*.c", "ext/**/*.h"], | ||
# exclude = [ | ||
# "autoconf/**", | ||
# "ext/fts1/**", | ||
# "ext/fts2/**", | ||
# "ext/misc/**", | ||
# "src/lempar.c", | ||
# "src/tclsqlite.c", | ||
# "src/sqlite3ext.h", | ||
# "**/*test*.c", | ||
# "test/**", | ||
# "**/tool/**", | ||
# ]) + [ | ||
# "src/keywordhash.h", | ||
# "src/sqlite3.h", | ||
# "src/parse.c", | ||
# "src/parse.h", | ||
# "src/opcodes.c", | ||
# "src/opcodes.h"], | ||
# includes = ["src/"], | ||
# copts = ["-DSQLITE_CORE"] + COMPILER_OPTS, | ||
#) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
new_http_archive( | ||
name = "sqlite3-src", | ||
url = "https://www.sqlite.org/2015/sqlite-src-3081101.zip", | ||
sha256 = "261ad454663f66fda6101b278bb7b3931cf01884deefbf4ea6b152f83a624662", | ||
build_file = "BUILD.sqlite3", | ||
) | ||
|
||
bind( | ||
name = "sqlite3", | ||
actual = "@sqlite3-src//:sqlite3", | ||
) |