Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Rebuild self with xcodebuild #16

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
BUILD_DEPS: cmake libconfig++-dev libxxhash-dev libjemalloc-dev libtsl-hopscotch-map-dev pkg-config python3-jinja2
TEST_DEPS: bc bats clang node-d3 graphviz moreutils fakeroot
TEST_DEPS: bc bats clang node-d3 moreutils fakeroot
jobs:
build-on-ubuntu-lts:
needs: style-checks
Expand All @@ -32,7 +32,7 @@ jobs:
key: build-on-ubuntu-lts
- name: install-deps
run: |
sudo eatmydata apt-get -y install $BUILD_DEPS $TEST_DEPS doxygen lcov
sudo eatmydata apt-get -y install $BUILD_DEPS $TEST_DEPS doxygen graphviz lcov
- name: build-out-of-tree
run: |
mkdir build
Expand Down Expand Up @@ -353,10 +353,13 @@ jobs:
export XML_CATALOG_FILES=${HOMEBREW_PREFIX}/etc/xml/catalog
export PATH=${HOMEBREW_PREFIX}/opt/ccache/libexec:$PATH
export PYTHONPATH=$(ls -d ${HOMEBREW_PREFIX}/Cellar/jinja2-cli/*/libexec/lib/*/site-packages | tail -n1)
cmake -G Xcode -B build-xcode
cd build-xcode
xcodebuild

# build self with Xcode
for i in 1 2; do
rm -rf build-xcode
time firebuild cmake -G Xcode -B build-xcode
(cd build-xcode &&
time firebuild -o env_vars.pass_through+=\"PYTHONPATH\" -o env_vars.pass_through+=\"XML_CATALOG_FILES\" xcodebuild)
done
style-checks:
runs-on: ubuntu-22.04
outputs:
Expand Down
1 change: 0 additions & 1 deletion Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ brew "bats-core"
brew "cmake"
brew "coreutils"
brew "docbook-xsl"
brew "graphviz"
brew "hopscotch-map"
brew "jemalloc"
brew "jinja2-cli"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ For Ubuntu earlier than 21.04 (xxhash earlier than 0.8.0 or Valgrind earlier tha
Install the build dependencies:

sudo apt update
sudo apt install clang cmake bats bc graphviz libconfig++-dev node-d3 libxxhash-dev libjemalloc-dev libtsl-hopscotch-map-dev moreutils python3-jinja2 fakeroot
sudo apt install clang cmake bats bc libconfig++-dev node-d3 libxxhash-dev libjemalloc-dev libtsl-hopscotch-map-dev moreutils python3-jinja2 fakeroot

Build:

Expand Down
3 changes: 2 additions & 1 deletion bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ workflows:
make -C build-make -j$NPROC
make -C build-make -j$NPROC check
sudo make -C build-make install
tar --zstd -cf ${BITRISE_DEPLOY_DIR}/firebuild-$(git log -1 --format=%cd-%h --date=format:%Y-%m-%d).tar.zst /usr/local/bin/firebuild /usr/local/lib/libfirebuild.* /usr/local/etc/firebuild.conf /usr/local/share/firebuild
# build self with Xcode
for i in 1 2; do
rm -rf build-xcode
Expand All @@ -46,7 +47,7 @@ workflows:
meta:
bitrise.io:
stack: osx-xcode-edge
machine_type_id: g2-m1.4core
machine_type_id: g2.mac.medium
trigger_map:
- push_branch: master
workflow: primary
Expand Down
21 changes: 19 additions & 2 deletions data/build-report.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Firebuild build report</title>
<script type="text/javascript" src="d3.min.js"></script>
<script type="text/javascript" src="viz-standalone.js" id="viz-js"></script>
<script type="text/javascript" src="firebuild-process-tree.js"></script>
<style type="text/css">

Expand Down Expand Up @@ -159,10 +160,12 @@
<body>
<div id="body">
<div id="proc-tree"></div>
<embed src="firebuild-profile.svg" type="image/svg+xml"/>
<div id="call-graph"></div>
</div>
<script type="text/digraph" id="digraph">
</script>
<script type="text/javascript">

// build the process tree
var m = [30, 120, 30, 120],
w = 200 - m[1] - m[3],
h = 400 - m[0] - m[2],
Expand Down Expand Up @@ -487,6 +490,20 @@
}
}

</script>
<script type="text/javascript">
// generate the call graph
try {
Viz.instance().then(function(viz) {
digraph = document.getElementById("digraph").textContent;
var svg = viz.renderSVGElement(digraph);
document.getElementById("call-graph").appendChild(svg);
});
} catch (e) {
document.getElementById("call-graph").textContent =
"Error while generating the call graph, maybe failed to download "
+ document.getElementById("viz-js").getAttribute("src") + "?";
}
</script>
<div id="pop_up_div" style="display:none;">
<div id="pop_up_div_inner">
Expand Down
4 changes: 1 addition & 3 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Build-Depends: bats,
fakeroot <!nocheck>,
gcc (>= 4:10) | gcc-10,
g++ (>= 4:10) | g++-10,
graphviz,
libconfig++-dev,
libjemalloc-dev,
libtsl-hopscotch-map-dev,
Expand All @@ -32,8 +31,7 @@ Depends: ${shlibs:Depends},
${glibc:Depends},
libfirebuild0 (= ${binary:Version})
Pre-Depends: debconf | debconf-2.0
Suggests: graphviz,
node-d3
Suggests: node-d3
Description: Automatic build accelerator cache
It works by caching the outputs of executed commands and replaying the
results when the same commands are executed with the same parameters
Expand Down
46 changes: 14 additions & 32 deletions src/firebuild/report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,13 @@ static ssize_t sendfile_full(int out_fd, int in_fd) {
* TODO(rbalint) error handling
*/
void Report::write(const std::string &html_filename, const std::string &datadir) {
const char dot_filename[] = "firebuild-profile.dot";
const char svg_filename[] = "firebuild-profile.svg";
// FIXME Use a search path, according to the locations in various popular distributions
const std::string d3_datadir = "/usr/share/nodejs/d3/dist";
const char d3_filename[] = "d3.min.js";
const char tree_filename[] = "firebuild-process-tree.js";
const char viz_js_filename[] = "viz-standalone.js";
const char digraph_script[] = "id=\"digraph";
const char html_orig_filename[] = "build-report.html";
const std::string dot_cmd = "dot";

FILE* src_file = fopen((datadir + "/" + html_orig_filename).c_str(), "r");
if (src_file == NULL) {
Expand All @@ -493,26 +492,6 @@ void Report::write(const std::string &html_filename, const std::string &datadir)
std::string dir = dirname(html_filename_tmp);
delete[] html_filename_tmp;

/* export profile */
{
FILE* dot = fopen((dir + "/" + dot_filename).c_str(), "w");
if (dot == NULL) {
fb_perror("fopen");
fb_error("Failed to open dot file for writing profile graph.");
}
export_profile2dot(dot);
fclose(dot);
}

auto system_cmd =
dot_cmd + " -Tsvg " + dir + "/" + dot_filename
+ " | sed 's/viewBox=\\\"[^\\\"]*\\\" //' > " + dir + "/" + svg_filename;
if (system(system_cmd.c_str()) != 0) {
fb_perror("system");
fb_error("Failed to generate profile graph with the following command: "
+ system_cmd);
}

FILE* dst_file = fopen(html_filename.c_str(), "w");
int ret = dst_file == NULL ? -1 : 0;
while ((ret != -1)) {
Expand All @@ -531,19 +510,25 @@ void Report::write(const std::string &html_filename, const std::string &datadir)
int d3 = open((d3_datadir + "/" + d3_filename).c_str(), O_RDONLY);
if (d3 == -1) {
/* File is not available locally, use the online version. */
fprintf(dst_file, "<script type=\"text/javascript\" "
fprintf(dst_file, " <script type=\"text/javascript\" "
"src=\"https://firebuild.com/d3.v5.min.js\"></script>\n");
fflush(dst_file);
} else {
fprintf(dst_file, "<script type=\"text/javascript\">\n");
fprintf(dst_file, " <script type=\"text/javascript\">\n");
fflush(dst_file);
ret = sendfile_full(fileno(dst_file), d3);
fsync(fileno(dst_file));
fprintf(dst_file, " </script>\n");
close(d3);
}
} else if (strstr(line, viz_js_filename) != NULL) {
// TODO(rbalint) check for local availability
/* File is not available locally, use the online version. */
fprintf(dst_file, " <script type=\"text/javascript\" "
"src=\"https://firebuild.com/viz-standalone.js\" id=\"viz-js\"></script>\n");
fflush(dst_file);
} else if (strstr(line, tree_filename) != NULL) {
fprintf(dst_file, "<script type=\"text/javascript\">\n");
fprintf(dst_file, " <script type=\"text/javascript\">\n");
tsl::hopscotch_set<const FileName*> used_files_set;
tsl::hopscotch_set<const std::vector<std::string>*, string_vector_ptr_hash,
string_vector_ptr_eq> used_envs_set;
Expand All @@ -552,12 +537,9 @@ void Report::write(const std::string &html_filename, const std::string &datadir)
fprint_collected_envs(dst_file, used_envs_set);
export2js(proc_tree, dst_file);
fprintf(dst_file, " </script>\n");
} else if (strstr(line, svg_filename) != NULL) {
int svg = open((dir + "/" + svg_filename).c_str(), O_RDONLY);
fflush(dst_file);
ret = sendfile_full(fileno(dst_file), svg);
fsync(fileno(dst_file));
close(svg);
} else if (strstr(line, digraph_script) != NULL) {
fprintf(dst_file, "%s", line);
export_profile2dot(dst_file);
} else {
fprintf(dst_file, "%s", line);
}
Expand Down
12 changes: 12 additions & 0 deletions src/interceptor/tpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ case {{ func }}: {
bool success = false;

/* Beforework */
### if target == "darwin"
bool interception_recursion_depth_changed = false;
if (i_am_intercepting && FB_THREAD_LOCAL(interception_recursion_depth) > 0) {
FB_THREAD_LOCAL(interception_recursion_depth)--;
interception_recursion_depth_changed = true;
}
### endif
### block before
### if before_lines
### for item in before_lines
Expand Down Expand Up @@ -336,6 +343,11 @@ case {{ func }}: {
### endfor
### endif
### endblock after
### if target == "darwin"
if (interception_recursion_depth_changed) {
FB_THREAD_LOCAL(interception_recursion_depth)++;
}
### endif

### if global_lock == 'after'
{{ grab_lock_if_needed('i_am_intercepting') }}
Expand Down
Loading