Skip to content

Commit 0082faa

Browse files
authored
Merge pull request #1 from Unity-Technologies/fix-linux-build
Fix the linux build for Unity.
2 parents c194d80 + 56edb87 commit 0082faa

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

3rdparty/Perl/lib/SDKDownloader.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ sub PrepareSDK
113113
# Load in the SDK specific perl module
114114
my $module = "SDK.pm";
115115
delete($INC{$module});
116-
push(@INC, catdir(($dir, $repo_name)));
116+
push(@INC, catdir(($cwd, $dir, $repo_name)));
117117
require $module;
118118

119119
# Obtain default SDK configuration so we can fill out values

RadeonRays/src/accelerator/bvh2.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,21 @@ namespace RadeonRays
3535
inline
3636
void *Align(std::size_t alignment, std::size_t size, std::size_t space, void *ptr)
3737
{
38+
#if !defined(__GNUC__) || __GNUC__ >= 5
3839
return std::align(alignment, size, ptr, space);
40+
#else
41+
// gcc4 doesn't have std::align
42+
const auto intptr = reinterpret_cast<uintptr_t>(ptr);
43+
const auto aligned = (intptr - 1u + alignment) & -alignment;
44+
const auto diff = aligned - intptr;
45+
if ((size + diff) > space)
46+
return nullptr;
47+
else
48+
{
49+
space -= diff;
50+
return ptr = reinterpret_cast<void*>(aligned);
51+
}
52+
#endif
3953
}
4054

4155
#ifdef __GNUC__

RadeonRays/src/intersector/intersector_2level.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ namespace RadeonRays
261261
// Create actual BVH objects
262262
for (int i = 0; i < nummeshes + 1; ++i)
263263
{
264-
m_bvhs[i] = std::make_unique<Bvh>(traversal_cost, num_bins, use_sah);
264+
m_bvhs[i] = std::unique_ptr<Bvh>(new Bvh(traversal_cost, num_bins, use_sah));
265265
m_cpudata->bvhptrs[i] = m_bvhs[i].get();
266266
}
267267

@@ -589,7 +589,7 @@ namespace RadeonRays
589589
use_sah = true;
590590
}
591591

592-
m_bvhs[nummeshes] = std::make_unique<Bvh>(traversal_cost, num_bins, use_sah);
592+
m_bvhs[nummeshes] = std::unique_ptr<Bvh>(new Bvh(traversal_cost, num_bins, use_sah));
593593
m_bvhs[nummeshes]->Build(&object_bounds[0], nummeshes + numinstances);
594594
m_cpudata->bvhptrs[nummeshes] = m_bvhs[nummeshes].get();
595595

RadeonRays/src/intersector/intersector_hlbvh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ namespace RadeonRays
148148
std::vector<int> mesh_faces_start_idx(numshapes);
149149

150150
//
151-
m_bvh = std::make_unique<Hlbvh>(m_device);
151+
m_bvh = std::unique_ptr<Hlbvh>(new Hlbvh(m_device));
152152

153153
// Here we now that only Meshes are present, otherwise 2level strategy would have been used
154154
for (int i = 0; i < numshapes; ++i)

build.pl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
use Archive::Zip;
1111
use SDKDownloader;
1212

13+
my $buildCommandPrefix = '';
1314
sub CheckInstallSDK
1415
{
1516
print 'Setting up the Linux SDK';
16-
SDKDownloader::PrepareSDK('linux-sdk', '20180907', "artifacts");
17+
SDKDownloader::PrepareSDK('linux-sdk', '20180928', "artifacts");
18+
$buildCommandPrefix = "schroot -c $ENV{LINUX_BUILD_ENVIRONMENT} --";
1719
}
1820

1921
my $err; # used by CheckFileError
@@ -25,14 +27,14 @@ sub CheckInstallSDK
2527
sub BuildRadeonRays
2628
{
2729
my $cmakeString = shift;
28-
system($cmakeString) && die("cmake failed");
30+
system("$buildCommandPrefix $cmakeString") && die("cmake failed");
2931
if ($Config{osname} eq "MSWin32")
3032
{
3133
system("\"C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/devenv.exe\" RadeonRaysSDK.sln /Build RelWithDebInfo");
3234
}
3335
else
3436
{
35-
system("make") && die("Failed make");
37+
system("$buildCommandPrefix make") && die("Failed make");
3638
}
3739
}
3840

0 commit comments

Comments
 (0)