diff --git a/Project.toml b/Project.toml index 6aa154c6..550128c9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BinaryBuilderBase" uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e" authors = ["Elliot Saba "] -version = "0.6.5" +version = "0.6.6" [deps] CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" diff --git a/src/Runner.jl b/src/Runner.jl index 59e02fad..6bf6694a 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -126,10 +126,11 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr println(io) end - # If we're given compile-only flags, include them only if `-x assembler` is not provided + # If we're given compile-only flags, include them only if `-x assembler` is not provided, + # or no object files (*.o) are passed in input if !isempty(compile_only_flags) println(io) - println(io, "if [[ \" \${ARGS[@]} \" != *' -x assembler '* ]]; then") + println(io, "if [[ \" \${ARGS[@]} \" != *' -x assembler '* ]] && [[ \" \${ARGS[@]} \" != *'.o '* ]]; then") for cf in compile_only_flags println(io, " PRE_FLAGS+=( $cf )") end @@ -389,13 +390,12 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr ) end - function clang_wrapper(io::IO, tool::String, p::AbstractPlatform, extra_flags::Vector{String} = String[]) + function clang_wrapper(io::IO, tool::String, p::AbstractPlatform, compile_flags::Vector{String} = String[]) flags = clang_flags!(p) - append!(flags, extra_flags) return wrapper(io, "/opt/$(host_target)/bin/$(tool)"; flags=flags, - compile_only_flags=clang_compile_flags!(p), + compile_only_flags=clang_compile_flags!(p, compile_flags), link_only_flags=clang_link_flags!(p), no_soft_float=arch(p) in ("armv6l", "armv7l"), ) diff --git a/test/runners.jl b/test/runners.jl index 9eff61c2..e130be1d 100644 --- a/test/runners.jl +++ b/test/runners.jl @@ -148,6 +148,34 @@ end @test endswith(readchomp(iobuff), "Hello World!") end end + + @testset "Objective-C - $(platform)" for platform in filter(Sys.isapple, supported_platforms()) + ur = preferred_runner()(dir; platform=platform) + iobuff = IOBuffer() + test_objc = """ + #import + void test() { + @autoreleasepool { + NSLog(@"Hello, World!"); + } + } + """ + script = """ + echo '$(test_objc)' > test.m + # Build the shared library in two steps: first compile object file... + objc -c -o test.o test.m + # ...and then link it to a shared library. + objc -shared -o test.dylib -framework Foundation test.o + file test.dylib + """ + cmd = `/bin/bash -ec "$(script)"` + @test run(ur, cmd, iobuff; tee_stream=devnull) + seekstart(iobuff) + # Test that we get the output we expect + _arch = arch(platform) == "aarch64" ? "arm64" : arch(platform) + @test occursin("test.dylib: Mach-O $(_arch) dynamically linked shared library", readchomp(iobuff)) + end + end end