Skip to content

Commit

Permalink
add libraries specified as a file to a binary prerequisites
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed May 22, 2024
1 parent fdc974a commit a428420
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
8 changes: 7 additions & 1 deletion src/prorab.mk
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,12 @@ $(.RECIPEPREFIX)$(a)rm -rf $(prorab_this_obj_dir)
$(eval prorab_ldflags := $(this_ldflags) $(prorab_private_ldflags))
$(eval prorab_ldlibs := $(this_ldlibs))

# Find libraries specified as a path to a static or shared library file.
# These will be added as dependencies of the final binary being built.
$(eval prorab_private_dep_libs := $(filter %.a,$(prorab_ldlibs)) $(filter %$(dot_so),$(prorab_ldlibs)))
$(eval prorab_private_dep_libs := $(foreach deplib,$(prorab_private_dep_libs),$(if $(filter /%,$(deplib)),$(deplib),$(d)$(deplib))) )
$(eval prorab_private_dep_libs := $(abspath $(prorab_private_dep_libs)))

$(eval prorab_ldargs_file := $(prorab_this_obj_dir)ldargs.txt)

$(call prorab-private-args-file-rules, $(prorab_ldargs_file),$(this_cc) $(prorab_ldflags) $(prorab_ldlibs))
Expand All @@ -862,7 +868,7 @@ $(.RECIPEPREFIX)$(a)rm -rf $(prorab_this_obj_dir)
# this is needed to avoid problems when adding dependencies to the symbolic link name, thus the dependency will effectively be added
# to the binary name.
# this is why we build the binary and create symbolic link in the same recepie.
$(prorab_this_name): $(prorab_this_objs) $(prorab_ldargs_file) $(prorab_objs_file)
$(prorab_this_name): $(prorab_this_objs) $(prorab_ldargs_file) $(prorab_objs_file) $(prorab_private_dep_libs)
$(.RECIPEPREFIX)@test -t 1 && printf "\e[0;31mlink\e[0m $(patsubst $(prorab_root_dir)%,%,$(prorab_private_this_binary_name))\n" || printf "link $(patsubst $(prorab_root_dir)%,%,$(prorab_private_this_binary_name))\n"
$(.RECIPEPREFIX)$(a)mkdir -p $(d)$(prorab_private_out_dir)
$(.RECIPEPREFIX)$(a)(cd $(d) && $(this_cc) $(prorab_ldflags) $$(filter %.o,$$^) $(prorab_ldlibs) -o "$(prorab_private_this_binary_name)")
Expand Down
6 changes: 1 addition & 5 deletions tests/cli_args_paths/prj/app/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ this_cflags += -I ../lib
this_cxxflags += -ffile-prefix-map=$(d)=
this_cflags += -ffile-prefix-map=$(d)=

this_ldflags += -L ../lib/out

this_ldlibs += -lstdc++ -lstuff
this_ldlibs += -lstdc++ ../lib/out/libstuff$(dot_so)

$(eval $(prorab-build-app))

$(eval $(call prorab-depend, $(prorab_this_name), ../lib/out/libstuff$(dot_so) ))

$(eval $(call prorab-include, ../lib/makefile))
4 changes: 2 additions & 2 deletions tests/lib_depends_on_lib/src/lib2/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ this_cxxflags += -fPIC

this_no_install := true

$(eval $(prorab-build-lib))
this_ldlibs += ../lib1/build/liblib1$(dot_so)

$(eval $(call prorab-depend, $(prorab_this_name), ../lib1/build/liblib1$(dot_so)))
$(eval $(prorab-build-lib))

$(eval $(call prorab-include, ../lib1/makefile))
4 changes: 2 additions & 2 deletions wiki/Reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ $(eval $(prorab-build-app))
- `this_asflags` - assembler flags. Defaults to `$(ASFLAGS)`. Relative to `$(d)`.
- `this_as_supports_deps_gen` - enable dependency rules generation from `.include` assembler directives. Defaults to `true`.
- `this_ldflags` - linker flags. Defaults to `$(LDFLAGS)`. Relative to `$(d)`.
- `this_ldlibs` - linker libraries. Defaults to `$(LDLIBS) $(LIBS)`. Relative to `$(d)`.
- `this_ldlibs` - linker libraries as they are passed to the linker. Defaults to `$(LDLIBS) $(LIBS)`. Relative to `$(d)`. All libraries specified as a path to a file will be added as dependencies of the final binary which is being built.
- `this_cppflags` - preprocessor flags. Defaults to `$(CPPFLAGS)`. Relative to `$(d)`.
- `this_out_dir` - output directory. This is where all the build artefacts are to be stored. Relative to `$(d)`. Defaults to `./`.
- `this_no_install` - disable `install` targets. Can be `true` or `false`. Defaults to `false`.
Expand Down Expand Up @@ -651,7 +651,7 @@ $(eval $(prorab-build-lib))
- `this_asflags` - assembler flags. Defaults to `$(ASFLAGS)`. Relative to `$(d)`.
- `this_as_supports_deps_gen` - enable dependency rules generation for `.include` assembler directives. Defaults to `true`.
- `this_ldflags` - linker flags. Defaults to `$(LDFLAGS)`. Relative to `$(d)`.
- `this_ldlibs` - linker libraries. Defaults to `$(LDLIBS) $(LIBS)`. Relative to `$(d)`.
- `this_ldlibs` - linker libraries as they are passed to the linker. Defaults to `$(LDLIBS) $(LIBS)`. Relative to `$(d)`. All libraries specified as a path to a file will be added as dependencies of the final binary which is being built.
- `this_cppflags` - preprocessor flags. Defaults to `$(CPPFLAGS)`. Relative to `$(d)`.
- `this_out_dir` - output directory. This is where all the build artefacts are to be stored. Relative to `$(d)`. Defaults to `./`.
- `this_no_install` - disable `install` targets. Can be `true` or `false`. Defaults to `false`.
Expand Down

0 comments on commit a428420

Please sign in to comment.