Skip to content

Commit

Permalink
Factor out xcodebuild loop into function
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoesters committed Sep 10, 2024
1 parent 188c9b4 commit 1bda971
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions constructor/osxpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,37 @@ def pkgbuild_prepare_installation(info):


def create_plugins(pages: list = None, codesigner: CodeSign = None):
def _build_xcode_projects(xcodeporj_dirs: list[Path]):
xcodebuild = shutil.which("xcodebuild")
if not xcodebuild:
raise RuntimeError(
"Plugin directory contains an uncompiled project,"
" but xcodebuild is not available."
)
try:
subprocess.run([xcodebuild, "--help"], check=True, capture_output=True)
except subprocess.CalledSubprocessError:
raise RuntimeError(
"Plugin directory contains an uncompiled project, "
"but xcodebuild requires XCode to compile plugins."
)
for xcodeproj in xcodeproj_dirs:
build_cmd = [
xcodebuild,
"-project",
str(xcodeproj),
f"CONFIGURATION_BUILD_DIR={PLUGINS_DIR}",
# do not create dSYM debug symbols directory
"DEBUG_INFORMATION_FORMAT=",
]
explained_check_call(build_cmd)

if not pages:
return
elif isinstance(pages, str):
pages = [pages]

fresh_dir(PLUGINS_DIR)
xcodebuild = None

for page in pages:
xcodeproj_dirs = [
Expand All @@ -441,30 +465,7 @@ def create_plugins(pages: list = None, codesigner: CodeSign = None):
if file.suffix == ".xcodeproj"
]
if xcodeproj_dirs:
if not xcodebuild:
xcodebuild = shutil.which("xcodebuild")
if not xcodebuild:
raise RuntimeError(
"Plugin directory contains an uncompiled project,"
" but xcodebuild is not available."
)
try:
subprocess.run([xcodebuild, "--help"], check=True, capture_output=True)
except subprocess.CalledSubprocessError:
raise RuntimeError(
"Plugin directory contains an uncompiled project, "
"but xcodebuild requires XCode to compile plugins."
)
for xcodeproj in xcodeproj_dirs:
build_cmd = [
xcodebuild,
"-project",
str(xcodeproj),
f"CONFIGURATION_BUILD_DIR={PLUGINS_DIR}",
# do not create dSYM debug symbols directory
"DEBUG_INFORMATION_FORMAT=",
]
explained_check_call(build_cmd)
_build_xcode_projects(xcodeproj_dirs)
else:
plugin_name = os.path.basename(page)
page_in_plugins = join(PLUGINS_DIR, plugin_name)
Expand Down

0 comments on commit 1bda971

Please sign in to comment.