Skip to content

Commit 6221202

Browse files
author
Twarit Waikar
committed
Minor fixes to the build process
1 parent 528c53b commit 6221202

File tree

5 files changed

+70
-63
lines changed

5 files changed

+70
-63
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ Because of the extra effort the script performs, expect it to take orders of mag
138138
## Build
139139
140140
0. Pre-requisites
141-
* Install openssl (both 1.1.1 and 3 work)
141+
* Install zlib - `brew install zlib`
142+
* Install openssl (try 1.1.1, 3.x.x doesn't work with p4 API libs) - `brew install openssl@1.1`
142143
* Install CMake 3.16+.
143144
* Install g++ 11.2.0 (older versions compatible with C++11 are also supported).
144145
* Clone this repository or [get a release distribution](https://github.com/salesforce/p4-fusion/releases).

generate_cache.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ cmakeArgs=(
99
-DBUILD_SHARED_LIBS=OFF
1010
-DBUILD_CLAR=OFF
1111
-DBUILD_EXAMPLES=OFF
12-
-DUSE_BUNDLED_ZLIB=ON
12+
-DUSE_BUNDLED_ZLIB=OFF
1313
-DREGEX_BACKEND=builtin
1414
-DTHREADSAFE=ON
1515
-DUSE_SSH=OFF
1616
-DUSE_HTTPS=OFF
1717
-DUSE_THREADS=ON
18-
-DOPENSSL_ROOT_DIR=/usr/local/ssl
18+
-DOPENSSL_ROOT_DIR=/opt/homebrew/Cellar/openssl@1.1/1.1.1w
1919
-DCMAKE_C_COMPILER=/usr/bin/gcc
2020
-DCMAKE_CXX_COMPILER=/usr/bin/g++
2121
)

p4-fusion/git_api.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ std::string GitAPI::Commit(
263263
const std::string& user,
264264
const std::string& email,
265265
const int& timezone,
266-
const std::string& desc,
266+
std::string desc,
267267
const int64_t& timestamp,
268268
const std::string& mergeFromStream)
269269
{
@@ -278,6 +278,11 @@ std::string GitAPI::Commit(
278278
git_signature* author = nullptr;
279279
GIT2(git_signature_new(&author, user.c_str(), email.c_str(), timestamp, timezone));
280280

281+
STDHelpers::StripSurrounding(desc, '\n');
282+
STDHelpers::StripSurrounding(desc, '\r');
283+
STDHelpers::StripSurrounding(desc, ' ');
284+
STDHelpers::StripSurrounding(desc, '\t');
285+
281286
// -3 to remove the trailing "..."
282287
std::string commitMsg = cl + " - " + desc + "\n[p4-fusion: depot-paths = \"" + depotPath.substr(0, depotPath.size() - 3) + "\": change = " + cl + "]";
283288

p4-fusion/git_api.h

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
/*
2-
* Copyright (c) 2022 Salesforce, Inc.
3-
* All rights reserved.
4-
* SPDX-License-Identifier: BSD-3-Clause
5-
* For full license text, see the LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6-
*/
7-
#pragma once
8-
9-
#include <string>
10-
#include <vector>
11-
#include <utility>
12-
13-
#include "common.h"
14-
#include "git2/oid.h"
15-
16-
struct git_repository;
17-
18-
class GitAPI
19-
{
20-
git_repository* m_Repo = nullptr;
21-
git_index* m_Index = nullptr;
22-
git_oid m_FirstCommitOid;
23-
24-
std::string m_CurrentBranch = "";
25-
26-
public:
27-
GitAPI(bool fsyncEnable);
28-
~GitAPI();
29-
30-
bool InitializeRepository(const std::string& srcPath);
31-
void OpenRepository(const std::string& repoPath);
32-
33-
bool IsHEADExists();
34-
bool IsRepositoryClonedFrom(const std::string& depotPath);
35-
std::string DetectLatestCL();
36-
37-
git_oid CreateBlob(const std::vector<char>& data);
38-
39-
void CreateIndex();
40-
void SetActiveBranch(const std::string& branchName);
41-
void AddFileToIndex(const std::string& relativePath, const std::vector<char>& contents, const bool plusx);
42-
void RemoveFileFromIndex(const std::string& relativePath);
43-
44-
std::string Commit(
45-
const std::string& depotPath,
46-
const std::string& cl,
47-
const std::string& user,
48-
const std::string& email,
49-
const int& timezone,
50-
const std::string& desc,
51-
const int64_t& timestamp,
52-
const std::string& mergeFromStream);
53-
void CloseIndex();
54-
};
1+
/*
2+
* Copyright (c) 2022 Salesforce, Inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
* For full license text, see the LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
#pragma once
8+
9+
#include <string>
10+
#include <vector>
11+
#include <utility>
12+
13+
#include "common.h"
14+
#include "git2/oid.h"
15+
16+
struct git_repository;
17+
18+
class GitAPI
19+
{
20+
git_repository* m_Repo = nullptr;
21+
git_index* m_Index = nullptr;
22+
git_oid m_FirstCommitOid;
23+
24+
std::string m_CurrentBranch = "";
25+
26+
public:
27+
GitAPI(bool fsyncEnable);
28+
~GitAPI();
29+
30+
bool InitializeRepository(const std::string& srcPath);
31+
void OpenRepository(const std::string& repoPath);
32+
33+
bool IsHEADExists();
34+
bool IsRepositoryClonedFrom(const std::string& depotPath);
35+
std::string DetectLatestCL();
36+
37+
git_oid CreateBlob(const std::vector<char>& data);
38+
39+
void CreateIndex();
40+
void SetActiveBranch(const std::string& branchName);
41+
void AddFileToIndex(const std::string& relativePath, const std::vector<char>& contents, const bool plusx);
42+
void RemoveFileFromIndex(const std::string& relativePath);
43+
44+
std::string Commit(
45+
const std::string& depotPath,
46+
const std::string& cl,
47+
const std::string& user,
48+
const std::string& email,
49+
const int& timezone,
50+
std::string desc,
51+
const int64_t& timestamp,
52+
const std::string& mergeFromStream);
53+
void CloseIndex();
54+
};

p4-fusion/main.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,29 +313,30 @@ int Main(int argc, char** argv)
313313
ThreadPool::GetSingleton()->Initialize(networkThreads);
314314
SUCCESS("Created " << ThreadPool::GetSingleton()->GetThreadCount() << " threads in thread pool");
315315

316-
int startupDownloadsCount = 0;
317-
316+
318317
// Go in the chronological order
319318
size_t lastDownloadedCL = 0;
320319
for (size_t currentCL = 0; currentCL < changes.size() && currentCL < lookAhead; currentCL++)
321320
{
322321
ChangeList& cl = changes.at(currentCL);
323-
322+
324323
// Start gathering changed files with `p4 describe` or `p4 filelog`
325324
cl.PrepareDownload(branchSet);
326-
325+
327326
lastDownloadedCL = currentCL;
328327
}
329-
328+
330329
// This is intentionally put in a separate loop.
331330
// We want to submit `p4 describe` commands before sending any of the `p4 print` commands.
332331
// Gives ~15% perf boost.
332+
int startupDownloadsCount = 0;
333333
for (size_t currentCL = 0; currentCL <= lastDownloadedCL; currentCL++)
334334
{
335335
ChangeList& cl = changes.at(currentCL);
336336

337337
// Start running `p4 print` on changed files when the describe is finished
338338
cl.StartDownload(printBatch);
339+
startupDownloadsCount++;
339340
}
340341

341342
SUCCESS("Queued first " << startupDownloadsCount << " CLs up until CL " << changes.at(lastDownloadedCL).number << " for downloading");

0 commit comments

Comments
 (0)