Skip to content

Commit

Permalink
[Android] Fix library files formatting in vcxproj
Browse files Browse the repository at this point in the history
  • Loading branch information
belkiss committed Apr 18, 2020
1 parent cffcb1a commit b535409
Showing 1 changed file with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Linq;
using Sharpmake.Generators;
using Sharpmake.Generators.VisualStudio;

Expand Down Expand Up @@ -65,26 +68,7 @@ public void SetupDynamicLibraryPaths(Project.Configuration configuration, Depend

public void SetupStaticLibraryPaths(Project.Configuration configuration, DependencySetting dependencySetting, Project.Configuration dependency)
{
if (dependency.Project.SharpmakeProjectType != Project.ProjectTypeAttribute.Export)
{
if (dependencySetting.HasFlag(DependencySetting.LibraryPaths))
configuration.AddDependencyBuiltTargetLibraryPath(dependency.TargetLibraryPath, dependency.TargetLibraryPathOrderNumber);

// Clang and GCC have trouble finding "Additional Dependencies" through "Additional Library Directories" when compiling
// for Android under VS. As a work around, we use rooted path for dependencies library files.
if (dependencySetting.HasFlag(DependencySetting.LibraryFiles))
configuration.AddDependencyBuiltTargetLibraryFile(dependency.TargetPath + "\\" + GetOutputFileNamePrefix(null, dependency.Output) + dependency.TargetFileFullName + "." + GetDefaultOutputExtension(dependency.Output), dependency.TargetFileOrderNumber);
}
else
{
if (dependencySetting.HasFlag(DependencySetting.LibraryPaths))
configuration.DependenciesOtherLibraryPaths.Add(dependency.TargetLibraryPath, dependency.TargetLibraryPathOrderNumber);

// Clang and GCC have trouble finding "Additional Dependencies" through "Additional Library Directories" when compiling
// for Android under VS. As a work around, we use rooted path for dependencies library files.
if (dependencySetting.HasFlag(DependencySetting.LibraryFiles))
configuration.DependenciesOtherLibraryFiles.Add(dependency.TargetPath + "\\" + dependency.TargetFileFullName, dependency.TargetFileOrderNumber);
}
DefaultPlatform.SetupLibraryPaths(configuration, dependencySetting, dependency);
}

public string GetDefaultOutputExtension(Project.Configuration.OutputType outputType)
Expand Down Expand Up @@ -326,6 +310,13 @@ public override void SelectLinkerOptions(IGenerationContext context)
);
}

public override void SelectPlatformAdditionalDependenciesOptions(IGenerationContext context)
{
// the libs must be prefixed with -l: in the additional dependencies field in VS
var additionalDependencies = context.Options["AdditionalDependencies"].Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
context.Options["AdditionalDependencies"] = string.Join(";", additionalDependencies.Select(d => "-l:" + d));
}

public override void SetupPlatformLibraryOptions(ref string platformLibExtension, ref string platformOutputLibExtension, ref string platformPrefixExtension)
{
platformLibExtension = ".a";
Expand Down

0 comments on commit b535409

Please sign in to comment.