@@ -538,9 +538,10 @@ static std::vector<File *> run_pre_make(OutputMode output_mode, const CompilerSe
538538 }
539539
540540 auto lib_header_dirs = collect_imported_headers ();
541- auto targets = output_mode == OutputMode::lib ? kphp_make_static_lib_target (obj_index, G->get_index (), lib_header_dirs, make)
542- : kphp_make_target (obj_index, G->get_index (), lib_header_dirs, make);
543- for (File * file : targets) {
541+ auto targets = vk::any_of_equal (output_mode, OutputMode::lib, OutputMode::k2_lib)
542+ ? kphp_make_static_lib_target (obj_index, G->get_index (), lib_header_dirs, make)
543+ : kphp_make_target (obj_index, G->get_index (), lib_header_dirs, make);
544+ for (File* file : targets) {
544545 response.push_back (file);
545546 }
546547
@@ -569,8 +570,7 @@ void run_make() {
569570 auto objs = run_pre_make (output_mode, settings, make_stats_file, make, obj_index, bin_file, obj_rt_index);
570571 stage::die_if_global_errors ();
571572
572- if (G->is_output_mode_lib ()) {
573- // todo:k2 think about kphp libraries
573+ if (G->is_output_mode_lib () || G->is_output_mode_k2_lib ()) {
574574 make.create_objs2static_lib_target (objs, &bin_file);
575575 } else if (G->is_output_mode_k2 ()) {
576576 make.create_objs2k2_component_target (objs, &bin_file);
@@ -584,8 +584,10 @@ void run_make() {
584584 }
585585 stage::die_if_global_errors ();
586586
587- const std::string build_stage{output_mode == OutputMode::lib ? " Compiling" : " Linking" };
588- stage::set_exit_code (output_mode == OutputMode::lib ? ExitCode::CPP_TO_OBJS_STAGE : ExitCode::OBJS_TO_BINARY_STAGE);
587+ const bool is_lib = vk::any_of_equal (output_mode, OutputMode::lib, OutputMode::k2_lib);
588+
589+ const std::string build_stage{is_lib ? " Compiling" : " Linking" };
590+ stage::set_exit_code (is_lib ? ExitCode::CPP_TO_OBJS_STAGE : ExitCode::OBJS_TO_BINARY_STAGE);
589591 AutoProfiler profiler{get_profiler (build_stage)};
590592
591593 bool ok = make.make_target (&bin_file, build_stage, settings.jobs_count .get ());
@@ -610,7 +612,7 @@ void run_make() {
610612 if (!settings.user_binary_path .get ().empty ()) {
611613 hard_link_or_copy (bin_file.path , settings.user_binary_path .get ());
612614 }
613- if (output_mode == OutputMode::lib) {
615+ if (vk::any_of_equal ( output_mode, OutputMode::lib, OutputMode::k2_lib) ) {
614616 copy_static_lib_to_out_dir (std::move (bin_file));
615617 }
616618}
0 commit comments