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

pass relative paths to the command line #4437

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 0 additions & 3 deletions jscomp/bsb/bsb_build_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ let include_dirs_by dirs fn =
(Ext_list.flat_map dirs (fun x -> ["-I"; Ext_filename.maybe_quote (fn x)]))


(* we use lazy $src_root_dir *)



(* It does several conversion:
First, it will convert unix path to windows backward on windows platform.
Expand Down
4 changes: 2 additions & 2 deletions jscomp/bsb/bsb_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ let rev_lib_bs_prefix p = rev_lib_bs // p

let ocaml_bin_install_prefix p = lib_ocaml // p

let lazy_src_root_dir = "$src_root_dir"
let proj_rel path = lazy_src_root_dir // path

let proj_rel path = rev_lib_bs // path

(** it may not be a bad idea to hard code the binary path
of bsb in configuration time
Expand Down
1 change: 0 additions & 1 deletion jscomp/bsb/bsb_ninja_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ let output_ninja_and_namespace_map
Bsb_ninja_targets.output_kvs
[|
Bsb_ninja_global_vars.g_pkg_flg, g_pkg_flg ;
Bsb_ninja_global_vars.src_root_dir, per_proj_dir (* TODO: need check its integrity -- allow relocate or not? *);
(* The path to [bsc.exe] independent of config *)
Bsb_ninja_global_vars.bsc, (Ext_filename.maybe_quote Bsb_global_paths.vendor_bsc);
(* The path to [bsb_heler.exe] *)
Expand Down
2 changes: 0 additions & 2 deletions jscomp/bsb/bsb_ninja_global_vars.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ let g_pkg_flg = "g_pkg_flg"

let bsc = "bsc"

let src_root_dir = "src_root_dir"
let bsdep = "bsdep"

let bsc_flags = "bsc_flags"
Expand All @@ -37,7 +36,6 @@ let ppx_flags = "ppx_flags"

let pp_flags = "pp_flags"


let g_dpkg_incls = "g_dpkg_incls"

let refmt = "refmt"
Expand Down
1 change: 1 addition & 0 deletions jscomp/core/bs_conditional_initial.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ let setup_env () =
Clflags.no_std_include := true;
Warnings.parse_options false Bsc_warnings.defaults_w;
Warnings.parse_options true Bsc_warnings.defaults_warn_error;
Location.absname := true;
Clflags.dump_location := false;
Clflags.compile_only := true;
Config.bs_only := true;
Expand Down
23 changes: 10 additions & 13 deletions jscomp/snapshot.ninja
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,45 @@ SNAP=../lib/$snapshot_path

build snapshot: phony $SNAP/whole_compiler.ml $SNAP/bsb_helper.ml $SNAP/bsb.ml $SNAP/bspp.ml $SNAP/unstable/all_ounit_tests.ml

build $SNAP/whole_compiler.ml: bspack | ./bin/bspack.exe
build $SNAP/whole_compiler.ml: bspack | ./bin/bspack.exe $LTO
flags = ${releaseMode} -bs-MD -module-alias Config=Config_whole_compiler -bs-exclude-I config -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I $OCAML_SRC_TYPING -I $OCAML_SRC_BYTECOMP -I $OCAML_SRC_DRIVER ${includes}
main = Js_main
post_process = && node $LTO $SNAP/whole_compiler.ml



build $SNAP/bsb_helper.ml: bspack | ./bin/bspack.exe
build $SNAP/bsb_helper.ml: bspack | ./bin/bspack.exe $LTO
flags = -bs-MD ${releaseMode} -I stubs -I common -I ext -I syntax -I depends -I bsb_helper -I main
main = Bsb_helper_main

build $SNAP/bsb.ml: bspack | ./bin/bspack.exe
build $SNAP/bsb.ml: bspack | ./bin/bspack.exe $LTO
flags = -D BS_MIN_LEX_DEPS=true -bs-MD ${releaseMode} -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I stubs -I common -I ext -I syntax -I depends -I bsb -I ext -I main
main = Bsb_main


build $SNAP/bspp.ml: bspack | ./bin/bspack.exe
build $SNAP/bspp.ml: bspack | ./bin/bspack.exe $LTO
flags = -D BS_MIN_LEX_DEPS=true ${releaseMode} -bs-MD -module-alias Config=Config_whole_compiler -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING?parser -I common -I ext -I syntax -I depends -I bspp -I core -I main
main = Bspp_main

build $SNAP/unstable/bsb_native.ml: bspack | ./bin/bspack.exe
build $SNAP/unstable/bsb_native.ml: bspack | ./bin/bspack.exe $LTO
flags = -D BS_MIN_LEX_DEPS=true -D BS_NATIVE=true -bs-MD ${releaseMode} -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I stubs -I common -I ext -I syntax -I depends -I bsb -I ext -I main
main = Bsb_main

build $SNAP/unstable/native_ppx.ml: bspack | ./bin/bspack.exe
build $SNAP/unstable/native_ppx.ml: bspack | ./bin/bspack.exe $LTO
flags = -module-alias Config=Config_whole_compiler -D BS_MIN_LEX_DEPS=true -D BS_NATIVE=true -bs-MD ${releaseMode} -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I stubs -I common -I ext -I syntax -I depends -I bsb -I ext -I core -I main
main = Native_ppx_main


build $SNAP/unstable/all_ounit_tests.ml: bspack | ./bin/bspack.exe
build $SNAP/unstable/all_ounit_tests.ml: bspack | ./bin/bspack.exe $LTO
flags = -bs-MD -I ounit -I ounit_tests -I stubs -I bsb -I bsb_helper -I common -I ext -I syntax -I depends -I bspp -I core -I main
main = Ounit_tests_main

build $SNAP/unstable/bspack.ml: bspack | ./bin/bspack.exe
build $SNAP/unstable/bspack.ml: bspack | ./bin/bspack.exe $LTO
flags = -bs-MD -module-alias Config=Config_whole_compiler -I $OCAML_SRC_PARSING -I $OCAML_SRC_UTILS -I stubs -I ext -I common -I depends -I core -I main -bs-main Bspack_main
main = Bspack_main

build $SNAP/unstable/js_compiler.ml: bspack | ./bin/bspack.exe
build $SNAP/unstable/js_compiler.ml: bspack | ./bin/bspack.exe $LTO
flags = -D BS_BROWSER=true -bs-MD -module-alias Config=Config_whole_compiler -bs-exclude-I config -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I $OCAML_SRC_TYPING -I $OCAML_SRC_BYTECOMP -I $OCAML_SRC_DRIVER -I stubs -I ext -I syntax -I depends -I common -I core -I super_errors -I bsb -I outcome_printer -I js_parser -I main
main = Jsoo_main

build $SNAP/unstable/js_refmt_compiler.ml: bspack | ./bin/bspack.exe
build $SNAP/unstable/js_refmt_compiler.ml: bspack | ./bin/bspack.exe $LTO
flags = -D BS_BROWSER=true -bs-MD -module-alias Config=Config_whole_compiler -bs-exclude-I config -I $OCAML_SRC_UTILS -I $OCAML_SRC_PARSING -I $OCAML_SRC_TYPING -I $OCAML_SRC_BYTECOMP -I $OCAML_SRC_DRIVER -I js_parser -I stubs -I ext -I syntax -I depends -I common -I core -I super_errors -I bsb -I outcome_printer -I js_parser -I main -I refmt
main = Jsoo_refmt_main

Expand Down
10 changes: 2 additions & 8 deletions lib/4.06.1/bsb.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5187,8 +5187,8 @@ let rev_lib_bs_prefix p = rev_lib_bs // p

let ocaml_bin_install_prefix p = lib_ocaml // p

let lazy_src_root_dir = "$src_root_dir"
let proj_rel path = lazy_src_root_dir // path

let proj_rel path = rev_lib_bs // path

(** it may not be a bad idea to hard code the binary path
of bsb in configuration time
Expand Down Expand Up @@ -9754,9 +9754,6 @@ let include_dirs_by dirs fn =
(Ext_list.flat_map dirs (fun x -> ["-I"; Ext_filename.maybe_quote (fn x)]))


(* we use lazy $src_root_dir *)



(* It does several conversion:
First, it will convert unix path to windows backward on windows platform.
Expand Down Expand Up @@ -12590,7 +12587,6 @@ let g_pkg_flg = "g_pkg_flg"

let bsc = "bsc"

let src_root_dir = "src_root_dir"
let bsdep = "bsdep"

let bsc_flags = "bsc_flags"
Expand All @@ -12599,7 +12595,6 @@ let ppx_flags = "ppx_flags"

let pp_flags = "pp_flags"


let g_dpkg_incls = "g_dpkg_incls"

let refmt = "refmt"
Expand Down Expand Up @@ -13688,7 +13683,6 @@ let output_ninja_and_namespace_map
Bsb_ninja_targets.output_kvs
[|
Bsb_ninja_global_vars.g_pkg_flg, g_pkg_flg ;
Bsb_ninja_global_vars.src_root_dir, per_proj_dir (* TODO: need check its integrity -- allow relocate or not? *);
(* The path to [bsc.exe] independent of config *)
Bsb_ninja_global_vars.bsc, (Ext_filename.maybe_quote Bsb_global_paths.vendor_bsc);
(* The path to [bsb_heler.exe] *)
Expand Down
2 changes: 1 addition & 1 deletion lib/4.06.1/refmt_main3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -161685,7 +161685,7 @@ let refmt_t =
$ heuristics_file
$ in_place
$ input

let () = Location.absname := true
let () =
match Term.eval ((Term.ret refmt_t), top_level_info) with
| `Error _ -> exit 1
Expand Down
10 changes: 2 additions & 8 deletions lib/4.06.1/unstable/bsb_native.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5193,8 +5193,8 @@ let rev_lib_bs_prefix p = rev_lib_bs // p

let ocaml_bin_install_prefix p = lib_ocaml // p

let lazy_src_root_dir = "$src_root_dir"
let proj_rel path = lazy_src_root_dir // path

let proj_rel path = rev_lib_bs // path

(** it may not be a bad idea to hard code the binary path
of bsb in configuration time
Expand Down Expand Up @@ -9760,9 +9760,6 @@ let include_dirs_by dirs fn =
(Ext_list.flat_map dirs (fun x -> ["-I"; Ext_filename.maybe_quote (fn x)]))


(* we use lazy $src_root_dir *)



(* It does several conversion:
First, it will convert unix path to windows backward on windows platform.
Expand Down Expand Up @@ -12739,7 +12736,6 @@ let g_pkg_flg = "g_pkg_flg"

let bsc = "bsc"

let src_root_dir = "src_root_dir"
let bsdep = "bsdep"

let bsc_flags = "bsc_flags"
Expand All @@ -12748,7 +12744,6 @@ let ppx_flags = "ppx_flags"

let pp_flags = "pp_flags"


let g_dpkg_incls = "g_dpkg_incls"

let refmt = "refmt"
Expand Down Expand Up @@ -13837,7 +13832,6 @@ let output_ninja_and_namespace_map
Bsb_ninja_targets.output_kvs
[|
Bsb_ninja_global_vars.g_pkg_flg, g_pkg_flg ;
Bsb_ninja_global_vars.src_root_dir, per_proj_dir (* TODO: need check its integrity -- allow relocate or not? *);
(* The path to [bsc.exe] independent of config *)
Bsb_ninja_global_vars.bsc, (Ext_filename.maybe_quote Bsb_global_paths.vendor_bsc);
(* The path to [bsb_heler.exe] *)
Expand Down
1 change: 1 addition & 0 deletions lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78368,6 +78368,7 @@ let setup_env () =
Clflags.no_std_include := true;
Warnings.parse_options false Bsc_warnings.defaults_w;
Warnings.parse_options true Bsc_warnings.defaults_warn_error;
Location.absname := true;
Clflags.dump_location := false;
Clflags.compile_only := true;
Config.bs_only := true;
Expand Down
1 change: 1 addition & 0 deletions lib/4.06.1/unstable/js_refmt_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78368,6 +78368,7 @@ let setup_env () =
Clflags.no_std_include := true;
Warnings.parse_options false Bsc_warnings.defaults_w;
Warnings.parse_options true Bsc_warnings.defaults_warn_error;
Location.absname := true;
Clflags.dump_location := false;
Clflags.compile_only := true;
Config.bs_only := true;
Expand Down
13 changes: 7 additions & 6 deletions lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4589,7 +4589,7 @@ let absolute_path s = (* This function could go into Filename *)
aux s

let show_filename file =
if !absname then absolute_path file else file
if true then absolute_path file else file

let print_filename ppf file =
Format.fprintf ppf "%s" (show_filename file)
Expand Down Expand Up @@ -361937,6 +361937,7 @@ let setup_env () =
Clflags.no_std_include := true;
Warnings.parse_options false Bsc_warnings.defaults_w;
Warnings.parse_options true Bsc_warnings.defaults_warn_error;
Location.absname := true;
Clflags.dump_location := false;
Clflags.compile_only := true;
Config.bs_only := true;
Expand Down Expand Up @@ -362623,7 +362624,7 @@ let read_one_param ppf position name v =
set "remove-unused-arguments" [ remove_unused_arguments ] v

| "inlining-report" ->
if !native_code then
if false then
set "inlining-report" [ inlining_report ] v

| "flambda-verbose" ->
Expand Down Expand Up @@ -362679,7 +362680,7 @@ let read_one_param ppf position name v =


| "cmo" | "cma" ->
if not !native_code then
if not false then
begin
match position with
| Before_link | Before_compile _ ->
Expand All @@ -362689,7 +362690,7 @@ let read_one_param ppf position name v =
end

| "cmx" | "cmxa" ->
if !native_code then
if false then
begin
match position with
| Before_link | Before_compile _ ->
Expand All @@ -362699,7 +362700,7 @@ let read_one_param ppf position name v =
end

| "pic" ->
if !native_code then
if false then
set "pic" [ pic_code ] v

| "can-discard" ->
Expand Down Expand Up @@ -362886,7 +362887,7 @@ let process_action
else if Filename.check_suffix name Config.ext_obj
|| Filename.check_suffix name Config.ext_lib then
ccobjs := name :: !ccobjs
else if not !native_code && Filename.check_suffix name Config.ext_dll then
else if not false && Filename.check_suffix name Config.ext_dll then
dllibs := name :: !dllibs
else
raise(Arg.Bad("don't know what to do with " ^ name))
Expand Down
23 changes: 19 additions & 4 deletions scripts/buckle_lto.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,29 @@ var pairs = [
["Clflags.unsafe_string", "false"],
["Clflags.record_event_when_debug", "false"],
["Clflags.no_std_include", "true"],
["no_std_include", "true"],
["Clflags.use_threads", "false"],
["Clflags.use_vmthreads", "false"],
["Clflags.no_implicit_current_dir", "true"],
["Clflags.strict_sequence", "true"],
["Clflags.strict_formats", "true"],
["Location.absname", "true"],
];

var regexp = RegExp(`${pairs.map((x) => "!" + x[0]).join("|")}`, "g");
var regexp = RegExp(
`${pairs
.map((x) => {
let result = [];
result.push("!" + x[0]);
let xs = x[0].split(".");
if (xs.length === 2 && xs[1]) {
result.push("!" + xs[1]);
}
return result;
})
.flat()
.join("|")}`,
"g"
);

/**
*
Expand All @@ -24,7 +38,8 @@ var regexp = RegExp(`${pairs.map((x) => "!" + x[0]).join("|")}`, "g");
function transform(s) {
return s.replace(regexp, (s) => {
for (let [k, v] of pairs) {
if (s.includes(k)) {
if (s.includes(k.split(".")[1])) {
// "bs_only" instead of "Clflags.bs_only"
return v;
}
}
Expand All @@ -33,7 +48,7 @@ function transform(s) {
}
// transform('!Config.bs_only && Clflags.native && !Clflags.native')
var file = process.argv[2];
console.log(`post processing file`, file);
console.log(`POST-PROCESSING-FILE:`, file);
fs.writeFileSync(
file,

Expand Down