Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a native C++ macro API + use it to replace manual macro locking #3408

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions build/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
#include <rpm/rpmfileutil.h>
#include "rpmbuild_internal.hh"
#include "rpmbuild_misc.hh"
#include "rpmmacro_internal.hh"

#include "debug.h"

using namespace rpm;

static rpm_time_t getBuildTime(void)
{
rpm_time_t buildTime = 0;
Expand Down Expand Up @@ -321,28 +324,27 @@ static int doCheckBuildRequires(rpmts ts, rpmSpec spec, int test)

static rpmRC doBuildDir(rpmSpec spec, int test, int inPlace, StringBuf *sbp)
{
char *doDir = rpmExpand("test -d '", spec->buildDir, "' && ",
"%{_fixperms} '", spec->buildDir, "'\n",
"%{__rm} -rf '", spec->buildDir, "'\n",
"%{__mkdir_p} '", spec->buildDir, "'\n",
"%{__mkdir_p} '%{specpartsdir}'\n",
NULL);
auto [ ign, doDir ] = macros().expand({
"test -d '", spec->buildDir, "' && ",
"%{_fixperms} '", spec->buildDir, "'\n",
"%{__rm} -rf '", spec->buildDir, "'\n",
"%{__mkdir_p} '", spec->buildDir, "'\n",
"%{__mkdir_p} '%{specpartsdir}'\n",
});

if (inPlace) {
/* note that pwd needs to be from parse, not build time */
char *buf = rpmExpand("%{__ln} -s %(pwd) %{builddir}/%{buildsubdir}", NULL);
doDir = rstrcat(&doDir, buf);
free(buf);
auto [ ign, buf ] = macros().expand("%{__ln} -s %(pwd) %{builddir}/%{buildsubdir}");
doDir += buf;
}

rpmRC rc = doScript(spec, RPMBUILD_MKBUILDDIR, "%mkbuilddir",
doDir, test, sbp);
doDir.c_str(), test, sbp);
if (rc) {
rpmlog(RPMLOG_ERR,
_("failed to create package build directory %s: %s\n"),
spec->buildDir, strerror(errno));
}
free(doDir);
return rc;
}

Expand Down
7 changes: 4 additions & 3 deletions build/rpmfc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@

#include "rpmfi_internal.hh" /* rpmfiles stuff for now */
#include "rpmbuild_internal.hh"
#include "rpmmacro_internal.hh"

#include "debug.h"

using std::string;
using std::vector;
using namespace rpm;

struct matchRule {
regex_t *path;
Expand Down Expand Up @@ -239,9 +241,8 @@ static rpmds rpmdsSingleNS(rpmstrPool pool,
{
rpmds ds = NULL;
if (namespc) {
char *NSN = rpmExpand(namespc, "(", N, ")", NULL);
ds = rpmdsSinglePool(pool, tagN, NSN, EVR, Flags);
free(NSN);
auto [ ign, NSN ] = macros().expand({namespc, "(", N, ")",});
ds = rpmdsSinglePool(pool, tagN, NSN.c_str(), EVR, Flags);
} else {
ds = rpmdsSinglePool(pool, tagN, N, EVR, Flags);
}
Expand Down
Loading
Loading