Skip to content

Commit

Permalink
Merge pull request #33 from membraneframework/fix/path-escaping
Browse files Browse the repository at this point in the history
Fix path escaping and bump version to v0.1.7
  • Loading branch information
bblaszkow06 authored Feb 6, 2019
2 parents 92d2669 + 632b718 commit f8413c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
14 changes: 6 additions & 8 deletions lib/bundlex/toolchain/gcc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ defmodule Bundlex.Toolchain.GCC do
use Bundlex.Toolchain

def compiler_commands(nif, app_name, nif_name) do
# FIXME escape quotes properly

includes_part =
nif.includes |> Enum.map(fn include -> "-I\"#{include}\"" end) |> Enum.join(" ")

Expand All @@ -23,19 +21,19 @@ defmodule Bundlex.Toolchain.GCC do
|> Enum.map(fn source ->
"gcc -fPIC -std=c11 -Wall -Wextra -O2 -g #{includes_part} #{libs_part} #{
pkg_config_cflags_part
} \"#{source_path(source)}\" -c -o \"#{object_path(source)}\""
} #{source_path(source)} -c -o #{object_path(source)}"
end)

commands_linker = [
"gcc -rdynamic -undefined -shared #{objects} #{libs_part} #{pkg_config_libs_part} -o #{
"gcc -rdynamic -undefined -shared #{objects} #{libs_part} #{pkg_config_libs_part} -o \"#{
Toolchain.output_path(app_name, nif_name)
}.so"
}.so\""
]

["mkdir -p #{Toolchain.output_path(app_name)}"] ++ commands_sources ++ commands_linker
["mkdir -p \"#{Toolchain.output_path(app_name)}\""] ++ commands_sources ++ commands_linker
end

defp source_path(source), do: source
defp source_path(source), do: "\"#{source}\""

defp object_path(source), do: "#{source}.o" |> String.replace(~r(\.c\.o$), ".o")
defp object_path(source), do: "\"#{source}.o\"" |> String.replace(~r(\.c\.o"$), ".o\"")
end
6 changes: 3 additions & 3 deletions lib/bundlex/toolchain/xcode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ defmodule Bundlex.Toolchain.XCode do
pkg_configs_part = Toolchain.pkg_config(nif, ["--cflags", "--libs"])

[
"mkdir -p #{Toolchain.output_path(app_name)}",
"cc -fPIC -Wall -Wextra -dynamiclib -undefined dynamic_lookup -o #{
"mkdir -p \"#{Toolchain.output_path(app_name)}\"",
"cc -fPIC -Wall -Wextra -dynamiclib -undefined dynamic_lookup -o \"#{
Toolchain.output_path(app_name, nif_name)
}.so #{includes_part} #{libs_part} #{pkg_configs_part} #{sources_part}"
}.so\" #{includes_part} #{libs_part} #{pkg_configs_part} #{sources_part}"
]
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Bundlex.Mixfile do
use Mix.Project

@version "0.1.6"
@version "0.1.7"

@github_url "https://github.com/membraneframework/bundlex"

Expand Down

0 comments on commit f8413c1

Please sign in to comment.