-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
61 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,18 @@ | ||
load("@rules_cc//cc:defs.bzl", "cc_test") | ||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make") | ||
|
||
configure_make( | ||
name = "simple", | ||
configure_in_place = True, | ||
lib_source = "//configure_modify_input_source/simple_lib:simple_srcs", | ||
targets = [ | ||
"simple", | ||
"install", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "test", | ||
srcs = ["testSimple.c"], | ||
deps = [":simple"], | ||
) |
5 changes: 5 additions & 0 deletions
5
examples/configure_modify_input_source/simple_lib/BUILD.bazel
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,5 @@ | ||
filegroup( | ||
name = "simple_srcs", | ||
srcs = glob(["**"]), | ||
visibility = ["//visibility:public"], | ||
) |
7 changes: 7 additions & 0 deletions
7
examples/configure_modify_input_source/simple_lib/Makefile.in
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,7 @@ | ||
simple: ./src/simple.c | ||
$(CC) $(CPPFLAGS) $(LDFLAGS) -o simple.a -c ./src/simple.c -I./include -I. | ||
install: | ||
mkdir -p simple | ||
mkdir -p simple/lib | ||
cp simple.a ./simple/lib/simple.a | ||
cp -r ./include ./simple |
15 changes: 15 additions & 0 deletions
15
examples/configure_modify_input_source/simple_lib/configure
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,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Slightly contrived example of a tool | ||
# that resolves the symlinks to the real file | ||
# and attempts to modify it | ||
# (Using perl here for replacement to avoid difference in in-place | ||
# arguments on macOS sed) | ||
# Note that perl -i would just replace the symlink | ||
# if used directly | ||
|
||
perl -i -pe 's/42/0/' $(readlink src/simple.c) | ||
echo "CC = $CC" > Makefile | ||
echo "CPPFLAGS = $CPPFLAGS" >> Makefile | ||
echo "LDFLAGS = $LDFLAGS" >> Makefile | ||
cat Makefile.in >> Makefile |
6 changes: 6 additions & 0 deletions
6
examples/configure_modify_input_source/simple_lib/include/simple.h
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,6 @@ | ||
#ifndef SIMPLE_H_ | ||
#define SIMPLE_H_ (1) | ||
|
||
int simpleFun(void); | ||
|
||
#endif // SIMPLE_H_ |
5 changes: 5 additions & 0 deletions
5
examples/configure_modify_input_source/simple_lib/src/simple.c
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,5 @@ | ||
#include "simple.h" | ||
|
||
int simpleFun(void) { | ||
return 42; | ||
} |
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,5 @@ | ||
#include "simple.h" | ||
|
||
int main(int argc, char **argv) { | ||
return simpleFun(); | ||
} |