Skip to content
Open
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
3 changes: 2 additions & 1 deletion ci/build-win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ steps:
- task: MSBuild@1
inputs:
solution: out/main.sln
msbuildArchitecture: $(arch)
platform: ${{ replace(variables['arch'], 'arm64', 'ARM64') }}
configuration: Default

- task: 1ES.PublishPipelineArtifact@1
displayName: 'Publish DLL'
Expand Down
1 change: 0 additions & 1 deletion config.gypi

This file was deleted.

52 changes: 13 additions & 39 deletions gyp_library.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,24 @@
#!/usr/bin/env python3
from __future__ import print_function
import ast
import os
import pprint
import sys

root = os.path.dirname(__file__)

sys.path.insert(0, os.path.join(root, 'node-gyp', 'gyp', 'pylib'))
import gyp

def edit_config_gypi(arch):
config_gypi = os.path.join(root, 'config.gypi')
with open(config_gypi, 'r') as f:
content = f.read()
config = ast.literal_eval(content)
v = config['variables']
v['target_arch'] = arch
with open(config_gypi, 'w+') as f:
f.write(pprint.pformat(config, indent=2))

def edit_main_gyp(arch):
main_gyp = os.path.join(root, 'main.gyp')
with open(main_gyp, 'r') as f:
content = f.read()
config = ast.literal_eval(content)
v = config['target_defaults']
v['msvs_configuration_platform'] = 'ARM64'
with open(main_gyp, 'w+') as f:
f.write(pprint.pformat(config, indent=2))

def run_gyp(arch, args):
edit_config_gypi(arch)
if arch == 'arm64':
edit_main_gyp(arch)

args.append('main.gyp')
args.extend(['-I', 'config.gypi'])
args.append('--depth=.')
args.append('--generator-output=out')
args.append('-Dlibrary=shared_library')

rc = gyp.main(args)
if rc != 0:
print('Error running GYP')
sys.exit(rc)
def run_gyp(arch, extra_args):
args = list(extra_args)
args.extend([
'main.gyp',
'--depth=.',
'--generator-output=out',
'-Dlibrary=shared_library',
f'-Dtarget_arch={arch}',
])

rc = gyp.main(args)
if rc:
sys.exit(rc)


if __name__ == '__main__':
Expand Down
24 changes: 14 additions & 10 deletions main.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,23 @@
'BufferSecurityCheck': 'true',
'ExceptionHandling': 1, # /EHsc
'EnableFunctionLevelLinking': 'true',
'Optimization': 3, # /Ox, full optimization
'Optimization': 3, # /Ox, full optimization
},
},
'libraries': [
'-ladvapi32.lib',
'-lruntimeobject.lib',
'-lshlwapi.lib',
'-lonecore.lib',
]
],
'conditions': [
['target_arch=="x64"', {
'msvs_configuration_platform': 'x64',
}],
['target_arch=="arm64"', {
'msvs_configuration_platform': 'ARM64',
}],
],
}],
],
},
Expand All @@ -57,14 +65,12 @@
[ 'OS=="win"', {
'conditions': [
['target_arch=="x64"', {
'TargetMachine' : 17, # /MACHINE:X64
'defines': [
'defines': [
'DLL_UUID="1C6DF0C0-192A-4451-BE36-6A59A86A692E"',
],
}],
['target_arch=="arm64"', {
'TargetMachine' : 18, # /MACHINE:ARM64 https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.vcprojectengine.machinetypeoption?view=visualstudiosdk-2022
'defines': [
'defines': [
'DLL_UUID="F5EA5883-1DA8-4A05-864A-D5DE2D2B2854"',
],
}],
Expand All @@ -82,14 +88,12 @@
[ 'OS=="win"', {
'conditions': [
['target_arch=="x64"', {
'TargetMachine' : 17, # /MACHINE:X64
'defines': [
'defines': [
'DLL_UUID="799F4F7E-5934-4001-A74C-E207F44F05B8"',
],
}],
['target_arch=="arm64"', {
'TargetMachine' : 18, # /MACHINE:ARM64
'defines': [
'defines': [
'DLL_UUID="7D34756D-32DD-4EE6-B99F-2691C0DAD875"',
],
}],
Expand Down