Allow all source files to be modified in configure_make when using configure_in_place = True (#856)
This commit is contained in:
parent
2f9965077f
commit
e24d9cecfe
|
@ -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"],
|
||||
)
|
|
@ -0,0 +1,5 @@
|
|||
filegroup(
|
||||
name = "simple_srcs",
|
||||
srcs = glob(["**"]),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -0,0 +1,11 @@
|
|||
simple: $(OUTPUT)
|
||||
|
||||
$(OUTPUT): ./src/simple.c
|
||||
$(CC) $(CPPFLAGS) -o $(OBJECT) -c ./src/simple.c -I./include -I.
|
||||
$(AR) $(LDFLAGS)
|
||||
|
||||
install: $(OUTPUT)
|
||||
mkdir -p simple
|
||||
mkdir -p simple/lib
|
||||
cp $(OUTPUT) ./simple/lib/$(OUTPUT)
|
||||
cp -r ./include ./simple
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# (Using perl here for replacement to avoid difference in in-place
|
||||
# arguments on macOS sed)
|
||||
|
||||
perl -i -pe 's/42/0/' src/simple.c
|
||||
|
||||
echo "CC = $CC" > Makefile
|
||||
echo "LDFLAGS = $LDFLAGS" >> Makefile
|
||||
if [[ "$(uname)" == *"NT"* ]]; then
|
||||
echo "AR = ${AR}" >> Makefile
|
||||
echo "OBJECT = simple.obj" >> Makefile
|
||||
echo "OUTPUT = simple.lib" >> Makefile
|
||||
|
||||
ESCAPED_CPPFLAGS="$(echo ${CFLAGS} | sed 's@\\@/@g')"
|
||||
ESCAPED_LDFLAGS="$(echo ${LDFLAGS} | sed 's@\\@/@g')"
|
||||
echo "CPPFLAGS = /c ${ESCAPED_CPPFLAGS}" >> Makefile
|
||||
echo "LDFLAGS = \$(OBJECT) ${ESCAPED_LDFLAGS} /OUT:\$(OUTPUT)" >> Makefile
|
||||
else
|
||||
echo "AR = \"ar\"" >> Makefile
|
||||
echo "OBJECT = simple.o" >> Makefile
|
||||
echo "OUTPUT = simple.a" >> Makefile
|
||||
echo "CPPFLAGS = ${CFLAGS}" >> Makefile
|
||||
echo "LDFLAGS = rcs \$(OUTPUT) \$(OBJECT)" >> Makefile
|
||||
fi
|
||||
cat Makefile.in >> Makefile
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef SIMPLE_H_
|
||||
#define SIMPLE_H_ (1)
|
||||
|
||||
int simpleFun(void);
|
||||
|
||||
#endif // SIMPLE_H_
|
|
@ -0,0 +1,5 @@
|
|||
#include "simple.h"
|
||||
|
||||
int simpleFun(void) {
|
||||
return 42;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
#include "simple.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return simpleFun();
|
||||
}
|
|
@ -33,7 +33,7 @@ def create_configure_script(
|
|||
root_path = "$$EXT_BUILD_ROOT$$/{}".format(root)
|
||||
configure_path = "{}/{}".format(root_path, configure_command)
|
||||
if configure_in_place:
|
||||
script.append("##symlink_contents_to_dir## $$EXT_BUILD_ROOT$$/{} $$BUILD_TMPDIR$$".format(root))
|
||||
script.append("##copy_dir_contents_to_dir## $$EXT_BUILD_ROOT$$/{} $$BUILD_TMPDIR$$".format(root))
|
||||
root_path = "$$BUILD_TMPDIR$$"
|
||||
configure_path = "{}/{}".format(root_path, configure_command)
|
||||
|
||||
|
|
Loading…
Reference in New Issue