[buck] deal with both ways buck can report infer-deps.txt

Reviewed By: jvillard

Differential Revision: D27466220

fbshipit-source-id: e497a2928
master
Martin Trojer 4 years ago committed by Facebook GitHub Bot
parent aae741419c
commit 8a234f1e9f

@ -43,15 +43,18 @@ let run_buck_build prog buck_build_args =
let process_buck_line acc line =
L.debug Capture Verbose "BUCK OUT: %s@." line ;
match String.lsplit2 ~on:' ' line with
| Some (_, target_path) ->
let filename =
ResultsDirEntryName.get_path
~results_dir:(Config.project_root ^/ target_path)
CaptureDependencies
in
if PolyVariantEqual.(Sys.file_exists filename = `Yes) then filename :: acc else acc
| Some (_, infer_deps_path) ->
let full_path = Config.project_root ^/ infer_deps_path in
let dirname = Filename.dirname full_path in
let get_path results_dir = ResultsDirEntryName.get_path ~results_dir CaptureDependencies in
(* Buck can either give the full path to infer-deps.txt ... *)
if PolyVariantEqual.(Sys.file_exists (get_path dirname) = `Yes) then get_path dirname :: acc
(* ... or a folder which contains infer-deps.txt *)
else if PolyVariantEqual.(Sys.file_exists (get_path full_path) = `Yes) then
get_path full_path :: acc
else acc
| _ ->
L.internal_error "Couldn't parse buck target output: %s" line ;
L.internal_error "Couldn't parse buck target output: %s@\n" line ;
acc
in
List.fold lines ~init:[] ~f:process_buck_line

@ -24,12 +24,12 @@ differences.exp.test: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST)
$(call silent_on_success,Running Buck flavors capture a first time,\
$(INFER_BIN) $(INFER_OPTIONS) capture --buck-clang --results-dir $(CURDIR)/infer-out -- \
$(BUCK) build --no-cache $(BUCK_TARGET) && \
find buck-out/gen/src/infer-out-* -type f | xargs cat | $(SHASUM) > capture_hash-1.sha)
find buck-out/gen/src -path "*infer-out*" -type f | sort | xargs cat | $(SHASUM) > capture_hash-1.sha)
$(QUIET)$(BUCK) clean && \
$(call silent_on_success,Running Buck flavors capture a second time,\
$(INFER_BIN) $(INFER_OPTIONS) capture --buck-clang --results-dir $(CURDIR)/infer-out -- \
$(BUCK) build --no-cache $(BUCK_TARGET) && \
find buck-out/gen/src/infer-out-* -type f | xargs cat | $(SHASUM) > capture_hash-2.sha)
find buck-out/gen/src -path "*infer-out*" -type f | sort | xargs cat | $(SHASUM) > capture_hash-2.sha)
$(QUIET)$(call silent_on_success,Computing difference,\
diff capture_hash-1.sha capture_hash-2.sha && \
echo "capture is deterministic" > $@ || \
@ -50,4 +50,4 @@ replace: differences.exp.test
.PHONY: clean
clean:
$(QUIET)$(REMOVE_DIR) infer-out $(OBJECTS) $(CLEAN_EXTRA)
$(QUIET)$(REMOVE_DIR) infer-out differences.exp.test $(OBJECTS) $(CLEAN_EXTRA)

Loading…
Cancel
Save