Skip to content

Commit

Permalink
Build emsdk from source (#343)
Browse files Browse the repository at this point in the history
* Add dependencies on various Microsoft-built versions of packages

* Use standardized build.sh etc, instead of modded repo version
  • Loading branch information
directhex authored Jul 12, 2023
1 parent afbff08 commit 96c6e0d
Show file tree
Hide file tree
Showing 19 changed files with 870 additions and 652 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ __pycache__
/spidermonkey
/binaryen

# MSFT ignores
/artifacts
/.dotnet
/.packages
41 changes: 41 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,45 @@
<PropertyGroup Condition="'$(StabilizePackageVersion)' == 'true'">
<StableVersion>$(VersionPrefix)</StableVersion>
</PropertyGroup>

<PropertyGroup>
<_hostArch>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant)</_hostArch>
<BuildArchitecture>$(_hostArch)</BuildArchitecture>
</PropertyGroup>

<!-- Common properties -->
<PropertyGroup>

<__ProjectDir Condition="'$(__ProjectDir)'==''">$(MSBuildThisFileDirectory)</__ProjectDir>
<ProjectDir>$(__ProjectDir)\</ProjectDir>
<RootRepoDir>$(ProjectDir)</RootRepoDir>
<ProjectDir Condition="'$(__ProjectDir)'==''">$(MSBuildThisFileDirectory)</ProjectDir>

<BaseIntermediateOutputPath>$(RootRepoDir)artifacts\obj\$(PlatformConfigPathPart)\</BaseIntermediateOutputPath>

<SourceDir>$(__SourceDir)\</SourceDir>
<SourceDir Condition="'$(__SourceDir)'==''">$(ProjectDir)src\</SourceDir>

<RootBinDir>$(__RootBinDir)\</RootBinDir>
<RootBinDir Condition="'$(__RootBinDir)'==''">$(RootRepoDir)artifacts\</RootBinDir>

<BinDir>$(__BinDir)\</BinDir>
<BinDir Condition="'$(__BinDir)'==''">$(RootBinDir)bin\$(PlatformConfigPathPart)\</BinDir>
</PropertyGroup>

<PropertyGroup>
<BinaryenDir>$(ProjectDir)\binaryen\$(VersionPrefix)</BinaryenDir>
<HostBinaryenDir Condition="'$(BuildArchitecture)' == '$(TargetArchitecture)'">$(BinaryenDir)</HostBinaryenDir>
<HostBinaryenDir Condition="'$(BuildArchitecture)' != '$(TargetArchitecture)'">$(BaseIntermediateOutputPath)\host\binaryen\$(BuildArchitecture)</HostBinaryenDir>
<NodeDir>$(ProjectDir)\node\$(VersionPrefix)</NodeDir>
<HostNodeDir Condition="'$(BuildArchitecture)' == '$(TargetArchitecture)'">$(NodeDir)</HostNodeDir>
<HostNodeDir Condition="'$(BuildArchitecture)' != '$(TargetArchitecture)'">$(BaseIntermediateOutputPath)\host\node\$(BuildArchitecture)</HostNodeDir>
<PythonDir>$(ProjectDir)\python\$(VersionPrefix)</PythonDir>
<HostPythonDir Condition="'$(BuildArchitecture)' == '$(TargetArchitecture)'">$(PythonDir)</HostPythonDir>
<HostPythonDir Condition="'$(BuildArchitecture)' != '$(TargetArchitecture)'">$(BaseIntermediateOutputPath)\host\python\$(BuildArchitecture)</HostPythonDir>
<LLVMDir>$(ProjectDir)\llvm\$(VersionPrefix)</LLVMDir>
<HostLLVMDir Condition="'$(BuildArchitecture)' == '$(TargetArchitecture)'">$(LLVMDir)</HostLLVMDir>
<HostLLVMDir Condition="'$(BuildArchitecture)' != '$(TargetArchitecture)'">$(BaseIntermediateOutputPath)\host\llvm\$(BuildArchitecture)</HostLLVMDir>
<EmscriptenDir>$(ProjectDir)\emscripten\$(VersionPrefix)</EmscriptenDir>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
<add key="dotnet8-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8-transport/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
Expand Down
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ setlocal
set _args=%*
if "%~1"=="-?" set _args=-help

powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0eng\common\build.ps1" -restore -build -pack %_args%
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0eng\build.ps1" %_args%
exit /b %ERRORLEVEL%
42 changes: 17 additions & 25 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

source="${BASH_SOURCE[0]}"

function is_cygwin_or_mingw()
{
case $(uname -s) in
CYGWIN*) return 0;;
MINGW*) return 0;;
*) return 1;;
esac
}

# resolve $SOURCE until the file is no longer a symlink
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
Expand All @@ -12,30 +21,13 @@ while [[ -h $source ]]; do
[[ $source != /* ]] && source="$scriptroot/$source"
done

usage()
{
echo "Common settings:"
echo " --help Print help and exit (short: -h)"
echo ""
}

inner_args=
properties=

while [[ $# > 0 ]]; do
opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')"
case "$opt" in
-help|-h)
usage
exit 0
;;
*)
inner_args="$inner_args $1"
;;
esac
shift
done

scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"

"$scriptroot/eng/common/build.sh" --restore --build --pack $inner_args $properties
if is_cygwin_or_mingw; then
# if bash shell running on Windows (not WSL),
# pass control to powershell build script.
scriptroot=$(cygpath -d "$scriptroot")
powershell -c "$scriptroot\\build.cmd" $@
else
"$scriptroot/eng/build.sh" $@
fi
8 changes: 5 additions & 3 deletions emsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1616,9 +1616,9 @@ def installation_path(self):
def installation_dir(self):
dir = self.installation_path()
if path_points_to_directory(dir):
return dir
return os.path.normpath(dir)
else:
return os.path.dirname(dir)
return os.path.dirname(os.path.normpath(dir))

# Returns the configuration item that needs to be added to .emscripten to make
# this Tool active for the current user.
Expand Down Expand Up @@ -1719,7 +1719,9 @@ def is_installed(self, skip_version_check=False):
content_exists = False

if hasattr(self, 'custom_is_installed_script'):
if self.custom_is_installed_script == 'is_optimizer_installed':
if self.custom_is_installed_script == 'lie_and_say_yes':
return True
elif self.custom_is_installed_script == 'is_optimizer_installed':
return is_optimizer_installed(self)
elif self.custom_is_installed_script == 'is_binaryen_installed':
return is_binaryen_installed(self)
Expand Down
Loading

0 comments on commit 96c6e0d

Please sign in to comment.