Skip to content

Commit b8fb832

Browse files
authored
[Auditor] Remove libtool *.la files (#1105)
* [Auditor] Remove libtool *.la files * Add autotools build system for libfoo, test with it
1 parent f54beea commit b8fb832

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

src/Auditor.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,19 @@ function audit(prefix::Prefix, src_name::AbstractString = "";
184184
all_ok &= symlink_soname_lib(f; verbose=verbose, autofix=autofix)
185185
end
186186

187+
# remove *.la files generated by GNU libtool
188+
la_files = collect_files(prefix, endswith(".la"))
189+
for f in la_files
190+
# sanity check: first byte should be '#', first line should contain 'libtool'
191+
line = readline(f)
192+
if length(line) == 0 || line[1] != '#' || !occursin("libtool", line)
193+
continue
194+
end
195+
# remove it
196+
@info("removing libtool file $f")
197+
rm(f; force=true)
198+
end
199+
187200
if Sys.iswindows(platform)
188201
# We also cannot allow any symlinks in Windows because it requires
189202
# Admin privileges to create them. Orz

test/auditing.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,42 @@ end
281281
end
282282

283283

284+
@testset "Auditor - .la removal" begin
285+
for os in ["linux", "macos", "freebsd", "windows"]
286+
platform = Platform("x86_64", os)
287+
mktempdir() do build_path
288+
build_output_meta = nothing
289+
@test_logs (:info, r"removing libtool file .*/destdir/lib/libfoo.la$") match_mode=:any begin
290+
build_output_meta = autobuild(
291+
build_path,
292+
"libfoo",
293+
v"1.0.0",
294+
# Copy in the libfoo sources
295+
[DirectorySource(build_tests_dir)],
296+
# Build libfoo using autotools to create a real .la file,
297+
# and also create a fake .la file (which should not be removed)
298+
libfoo_autotools_script * "\ntouch \${prefix}/lib/libbar.la",
299+
# Build for our platform
300+
[platform],
301+
# The products we expect to be build
302+
libfoo_products,
303+
# No dependencies
304+
Dependency[]
305+
)
306+
end
307+
308+
@test haskey(build_output_meta, platform)
309+
tarball_path, tarball_hash = build_output_meta[platform][1:2]
310+
@test isfile(tarball_path)
311+
312+
# Test that `libfoo.la` has been removed but `libbar.la` hasn't
313+
contents = list_tarball_files(tarball_path)
314+
@test "lib/libbar.la" in contents
315+
@test !("lib/libfoo.la" in contents)
316+
end
317+
end
318+
end
319+
284320
@testset "Auditor - .dll moving" begin
285321
for platform in [Platform("x86_64", "windows")]
286322
mktempdir() do build_path

test/build_tests/libfoo/Makefile.am

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ACLOCAL_AMFLAGS = -I m4
2+
3+
lib_LTLIBRARIES = libfoo.la
4+
libfoo_la_SOURCES = libfoo.c
5+
libfoo_la_LDFLAGS = -no-undefined
6+
7+
bin_PROGRAMS = fooifier
8+
fooifier_SOURCES = fooifier.cpp
9+
fooifier_LDADD = libfoo.la

test/build_tests/libfoo/configure.ac

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
AC_PREREQ([2.69])
2+
AC_INIT([libfoo], [1.0])
3+
AC_CONFIG_MACRO_DIRS([m4])
4+
5+
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
6+
7+
AM_PROG_AR
8+
9+
LT_PREREQ([2.4.6])
10+
LT_INIT([dlopen])
11+
12+
#AC_CANONICAL_TARGET
13+
14+
AC_PROG_CC
15+
AC_PROG_CXX
16+
17+
AC_CONFIG_FILES([Makefile])
18+
AC_OUTPUT

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ fi
5757
install_license ${WORKSPACE}/srcdir/libfoo/LICENSE.md
5858
"""
5959

60+
libfoo_autotools_script = raw"""
61+
cd ${WORKSPACE}/srcdir/libfoo
62+
autoreconf -fiv
63+
./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} --disable-static
64+
make install
65+
install_license ${WORKSPACE}/srcdir/libfoo/LICENSE.md
66+
"""
67+
6068
# Run all our tests
6169
include("basic.jl")
6270
include("building.jl")

0 commit comments

Comments
 (0)